|
76 | 76 | "metadata": {}, |
77 | 77 | "outputs": [], |
78 | 78 | "source": [ |
79 | | - "# Level 1: Binary exact match (simplest)\n", |
| 79 | + "# Metriken werden immer raffinierter\n", |
80 | 80 | "from IPython.display import display, HTML\n", |
81 | 81 | "from dspy_tasks.calculations import token_f1\n", |
82 | 82 | "\n", |
83 | | - "f1_val = token_f1(['apple','banana'], ['apple','cherry'])\n", |
| 83 | + "f1_val = token_f1([\"apple\", \"banana\"], [\"apple\", \"cherry\"])\n", |
84 | 84 | "\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 | + " ‘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>\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=[‘apple’, ‘banana’], pred=[‘apple’, ‘cherry’] → <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 “was am wichtigsten ist”\n", |
| 104 | + "</div></div></div>\n", |
| 105 | + "\"\"\"))\n", |
103 | 106 | "\n", |
104 | 107 | "display_insight(\"Der Kern-Insight\",\n", |
105 | 108 | " \"Deine Metrik-Funktion IST deine Produkt-Spezifikation. \"\n", |
106 | 109 | " \"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" |
108 | 111 | ] |
109 | 112 | }, |
110 | 113 | { |
|
0 commit comments