Skip to content

Commit 2de56ef

Browse files
abossardCopilot
andcommitted
Fix HTML string escaping in NB01 metrics cell
Use triple-quoted f-string and HTML entities (&lsquo;) instead of raw single quotes inside single-quoted strings. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent fad59aa commit 2de56ef

1 file changed

Lines changed: 24 additions & 21 deletions

File tree

notebooks/01_evaluation.ipynb

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -76,35 +76,38 @@
7676
"metadata": {},
7777
"outputs": [],
7878
"source": [
79-
"# Level 1: Binary exact match (simplest)\n",
79+
"# Metriken werden immer raffinierter\n",
8080
"from IPython.display import display, HTML\n",
8181
"from dspy_tasks.calculations import token_f1\n",
8282
"\n",
83-
"f1_val = token_f1(['apple','banana'], ['apple','cherry'])\n",
83+
"f1_val = token_f1([\"apple\", \"banana\"], [\"apple\", \"cherry\"])\n",
8484
"\n",
85-
"display(HTML(\n",
86-
" '<div style=\"margin:8px 0\">'\n",
87-
" '<div style=\"padding:12px; background:#f3f2f1; border-radius:8px; margin-bottom:8px; border-left:4px solid #107c10\">'\n",
88-
" '<b style=\"font-size:1.05em\">Level 1: Exact Match</b>'\n",
89-
" '<div style=\"margin-top:6px; font-family:monospace; font-size:0.95em\">'\n",
90-
" ' 'positive' == 'positive' → <span style=\"color:#107c10; font-weight:bold\">1.0</span><br>'\n",
91-
" ' 'positive' == 'POSITIVE' → <span style=\"color:#107c10; font-weight:bold\">1.0</span> <span style=\"color:#605e5c\">(normalized)</span><br>'\n",
92-
" ' 'positive' == 'negative' → <span style=\"color:#d13438; font-weight:bold\">0.0</span></div></div>'\n",
93-
" '<div style=\"padding:12px; background:#f3f2f1; border-radius:8px; margin-bottom:8px; border-left:4px solid #0078d4\">'\n",
94-
" '<b style=\"font-size:1.05em\">Level 2: Token F1</b>'\n",
95-
" f'<div style=\"margin-top:6px; font-family:monospace; font-size:0.95em\">'\n",
96-
" f' gold=['apple','banana'], pred=['apple','cherry'] → <span style=\"color:#0078d4; font-weight:bold\">{f1_val:.3f}</span></div></div>'\n",
97-
" '<div style=\"padding:12px; background:#f3f2f1; border-radius:8px; border-left:4px solid #8764b8\">'\n",
98-
" '<b style=\"font-size:1.05em\">Level 3: Composite (ticket routing)</b>'\n",
99-
" '<div style=\"margin-top:6px; font-size:0.95em\">'\n",
100-
" ' Priority correct (<b>40%</b>) + Category correct (<b>35%</b>) + Team correct (<b>25%</b>)<br>'\n",
101-
" ' = Weighted specification of \"what matters most\"</div></div></div>'\n",
102-
"))\n",
85+
"display(HTML(f\"\"\"\n",
86+
"<div style=\"margin:8px 0\">\n",
87+
"<div style=\"padding:12px; background:#f3f2f1; border-radius:8px; margin-bottom:8px; border-left:4px solid #107c10\">\n",
88+
"<b style=\"font-size:1.05em\">Level 1: Exact Match</b>\n",
89+
"<div style=\"margin-top:6px; font-family:monospace; font-size:0.95em\">\n",
90+
" &lsquo;positive&rsquo; == &lsquo;positive&rsquo; &rarr; <span style='color:#107c10; font-weight:bold'>1.0</span><br>\n",
91+
" &lsquo;positive&rsquo; == &lsquo;POSITIVE&rsquo; &rarr; <span style='color:#107c10; font-weight:bold'>1.0</span> <span style='color:#605e5c'>(normalized)</span><br>\n",
92+
" &lsquo;positive&rsquo; == &lsquo;negative&rsquo; &rarr; <span style='color:#d13438; font-weight:bold'>0.0</span>\n",
93+
"</div></div>\n",
94+
"<div style=\"padding:12px; background:#f3f2f1; border-radius:8px; margin-bottom:8px; border-left:4px solid #0078d4\">\n",
95+
"<b style=\"font-size:1.05em\">Level 2: Token F1</b>\n",
96+
"<div style=\"margin-top:6px; font-family:monospace; font-size:0.95em\">\n",
97+
" gold=[&lsquo;apple&rsquo;, &lsquo;banana&rsquo;], pred=[&lsquo;apple&rsquo;, &lsquo;cherry&rsquo;] &rarr; <span style='color:#0078d4; font-weight:bold'>{f1_val:.3f}</span>\n",
98+
"</div></div>\n",
99+
"<div style=\"padding:12px; background:#f3f2f1; border-radius:8px; border-left:4px solid #8764b8\">\n",
100+
"<b style=\"font-size:1.05em\">Level 3: Composite (Ticket Routing)</b>\n",
101+
"<div style=\"margin-top:6px; font-size:0.95em\">\n",
102+
" Priority korrekt (<b>40%</b>) + Kategorie korrekt (<b>35%</b>) + Team korrekt (<b>25%</b>)<br>\n",
103+
" = Gewichtete Spezifikation von &ldquo;was am wichtigsten ist&rdquo;\n",
104+
"</div></div></div>\n",
105+
"\"\"\"))\n",
103106
"\n",
104107
"display_insight(\"Der Kern-Insight\",\n",
105108
" \"Deine Metrik-Funktion IST deine Produkt-Spezifikation. \"\n",
106109
" \"Wenn du die Gewichte änderst, änderst du, wofür das System optimiert. \"\n",
107-
" \"Deshalb ist 'Evaluation die Software der Zukunft'.\")"
110+
" \"Deshalb ist Evaluation die Software der Zukunft.\")\n"
108111
]
109112
},
110113
{

0 commit comments

Comments
 (0)