<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: sarthak bhardwaj</title>
    <description>The latest articles on DEV Community by sarthak bhardwaj (@sarthak_bhardwaj_05aba55d).</description>
    <link>https://dev.to/sarthak_bhardwaj_05aba55d</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2541640%2F9914d46e-38b2-4dab-9213-80896e20e73a.jpg</url>
      <title>DEV Community: sarthak bhardwaj</title>
      <link>https://dev.to/sarthak_bhardwaj_05aba55d</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sarthak_bhardwaj_05aba55d"/>
    <language>en</language>
    <item>
      <title>My least accurate LLM router was 60% cheaper. Every mistake counted as savings.</title>
      <dc:creator>sarthak bhardwaj</dc:creator>
      <pubDate>Tue, 24 Nov 2026 07:15:11 +0000</pubDate>
      <link>https://dev.to/sarthak_bhardwaj_05aba55d/my-least-accurate-llm-router-was-60-cheaper-every-mistake-counted-as-savings-46i9</link>
      <guid>https://dev.to/sarthak_bhardwaj_05aba55d/my-least-accurate-llm-router-was-60-cheaper-every-mistake-counted-as-savings-46i9</guid>
      <description>&lt;p&gt;I benchmarked three ways to route prompts between a cheap model and a strong one. My results file sums it up as "a router matches most oracle choices at about half the cost." Both halves of that sentence are true. Reading the 24 rows behind them changed what I think they mean.&lt;/p&gt;

&lt;p&gt;Among the routers that actually make a decision, projected cost runs in exact reverse order of accuracy. The cheapest, a Gemini 3.1 Flash-Lite classifier, projects a 60% saving and got 3 of 24 prompts wrong. The only perfect router, Claude Haiku 4.5 with the same prompt, projects 48%. Every mistake those routers made went the same way: a hard prompt sent to the cheap model. My cost metric counts each of those as money saved. And the "about half" comes from how I labeled the prompts.&lt;/p&gt;

&lt;p&gt;This is from &lt;a href="https://github.com/SarthakB11/agentic-patterns" rel="noopener noreferrer"&gt;agentic-patterns&lt;/a&gt;, where I implement agent patterns in plain Python and measure them against live models.&lt;/p&gt;

&lt;h2&gt;
  
  
  The setup
&lt;/h2&gt;

&lt;p&gt;Twenty-four prompts, labeled by me: 12 cheap ("What is the capital of Australia?", "Convert 'hello world' to uppercase.") and 12 hard (a break-even price derivation, a multi-tenant billing schema, a proof that the square root of 2 is irrational). Three routers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;semantic: embed the prompt with Gemini embeddings and compare it with five example prompts per tier&lt;/li&gt;
&lt;li&gt;LLM classifier: the chat model reads a two-line rubric and replies &lt;code&gt;ROUTE: cheap&lt;/code&gt; or &lt;code&gt;ROUTE: hard&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;always strong: send everything to the strong tier&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Nothing gets answered. The benchmark scores each routing decision against my label, then projects what answering all 24 would cost under that router's choices, using a fixed size per tier:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;_ANSWER_TOKENS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;tuple&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"cheap"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;150&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="c1"&gt;# (input, output) tokens for a short factual/format task&lt;/span&gt;
    &lt;span class="s2"&gt;"hard"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;600&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    &lt;span class="c1"&gt;# a multi-step or analytical answer runs longer&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At the list prices in the harness (Flash-Lite for the cheap tier, Gemini 3.5 Flash for the hard one) that is $0.000275 per cheap answer and $0.006 per hard one. A hard answer costs about 22 times a cheap one.&lt;/p&gt;

&lt;h2&gt;
  
  
  The rows
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fx0bfsh73e531z3qv8zre.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fx0bfsh73e531z3qv8zre.png" alt="Projected cost per router with its accuracy: the cheaper the router, the more prompts it got wrong" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Router&lt;/th&gt;
&lt;th&gt;Accuracy&lt;/th&gt;
&lt;th&gt;Sent to cheap&lt;/th&gt;
&lt;th&gt;Projected cost&lt;/th&gt;
&lt;th&gt;Saving vs always strong&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Always strong&lt;/td&gt;
&lt;td&gt;0.50&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;$0.1440&lt;/td&gt;
&lt;td&gt;0%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Oracle (my labels)&lt;/td&gt;
&lt;td&gt;1.00&lt;/td&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;td&gt;$0.0753&lt;/td&gt;
&lt;td&gt;48%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Haiku 4.5 classifier&lt;/td&gt;
&lt;td&gt;1.00&lt;/td&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;td&gt;$0.0753&lt;/td&gt;
&lt;td&gt;48%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Semantic router&lt;/td&gt;
&lt;td&gt;0.96&lt;/td&gt;
&lt;td&gt;13&lt;/td&gt;
&lt;td&gt;$0.0696&lt;/td&gt;
&lt;td&gt;52%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Flash-Lite classifier&lt;/td&gt;
&lt;td&gt;0.88&lt;/td&gt;
&lt;td&gt;15&lt;/td&gt;
&lt;td&gt;$0.0581&lt;/td&gt;
&lt;td&gt;60%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The semantic router uses the same Gemini embeddings in both model runs, so it gets one row. The table rebuilds from the committed results with the benchmark's own cost function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;benchmarks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bench_routing&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;_projected_cost&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"benchmarks/results/routing.json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"benchmarks/results/haiku/routing.json"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"tasks"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;router&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"semantic"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"llm_classifier"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;routes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;router&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;misses&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"label"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;router&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;router&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"label"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;router&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;routes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"cheap"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;misses&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;_projected_cost&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;routes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;results semantic 13 [('hard', 'cheap')] 0.06957
results llm_classifier 15 [('hard', 'cheap'), ('hard', 'cheap'), ('hard', 'cheap')] 0.05812
haiku semantic 13 [('hard', 'cheap')] 0.06957
haiku llm_classifier 12 [] 0.0753
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every miss is &lt;code&gt;('hard', 'cheap')&lt;/code&gt;. Neither the semantic router nor either classifier sent a single cheap prompt to the strong model.&lt;/p&gt;

&lt;h2&gt;
  
  
  A wrong route was priced as a saving
&lt;/h2&gt;

&lt;p&gt;Each hard prompt sent to the cheap tier swaps a $0.006 answer for a $0.000275 one, so the projection drops by $0.005725 per mistake. The metric has no term for what happens next. A strong model answering an easy prompt wastes money but still answers it. A cheap model answering "Derive the break-even unit price given a fixed cost of $50,000, a variable cost of $12 per unit, and a target volume of 5,000 units" might get it wrong, and the benchmark never finds out, because it doesn't answer anything.&lt;/p&gt;

&lt;p&gt;The Flash-Lite classifier sits $0.017175 under the oracle. That is exactly three misroutes. It sent cheap the break-even derivation, "A store offers 20% off, then an additional 10% off the discounted price, then charges 8% sales tax; what percentage of the original price does a customer pay?", and a request to critique an argument for a logical fallacy. Haiku, given the same system prompt, routed all three hard.&lt;/p&gt;

&lt;h2&gt;
  
  
  Half the cost was in my labels
&lt;/h2&gt;

&lt;p&gt;I chose 12 cheap and 12 hard. With hard answers at about 22 times the price, routing exactly by my labels costs $0.0753 against $0.144 for always strong, a 48% cut. Hard prompts are 96% of that oracle bill. That 48% is the most a correct router can save on this set. Anything a router reports beyond it is mistakes, and anything short of it is cheap prompts sent to the strong model.&lt;/p&gt;

&lt;p&gt;So "about half the cost" describes the split I picked. The same function says an oracle on 20 cheap and 4 hard prompts would save 80%, and on 4 cheap and 20 hard, 16%.&lt;/p&gt;

&lt;h2&gt;
  
  
  Was the semantic router copying?
&lt;/h2&gt;

&lt;p&gt;I also checked the 0.96 for a second problem. Four of the five hard examples I gave the semantic router are shortened versions of four test prompts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="s2"&gt;"Derive the break-even price given fixed cost, variable cost, and volume."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s2"&gt;"Compare the tax implications of two acquisition structures and recommend one."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s2"&gt;"Optimize the marketing budget allocation across three channels to maximize ROI."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s2"&gt;"Prove that the sum of the first n odd numbers equals n squared."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s2"&gt;"Analyze the second-order effects of a price change and recommend a decision."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The router scores a prompt by its best cosine match against each tier's examples. (My results file calls this nearest-centroid. The code takes the maximum over examples, so a single close example decides.) The embeddings from the July run were still in the gitignored cache on my disk. I replayed the benchmark with an embedder and a chat provider that raise on any cache miss: 0 network calls, and every route matched the committed results. Then I measured each prompt's margin, the best hard match minus the best cheap match.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0nfz2mrvblbtn97udb8t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0nfz2mrvblbtn97udb8t.png" alt="Per-prompt margin of the semantic router; the four hard prompts with near-copies among the examples have by far the largest margins" width="800" height="544"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The four near-copies score 0.80 to 0.89 against their example, with margins of +0.30 to +0.35. Two cheap prompts follow the same template as an example ("capital of Australia" next to "capital of Japan", uppercase next to lowercase) and sit at -0.26 and -0.24. The other 18 prompts all have margins under 0.18. "What is 12 plus 7?" went cheap by 0.0027.&lt;/p&gt;

&lt;p&gt;Then I removed each copy from the examples and re-scored its prompt against the other nine. All four still routed hard, with margins of +0.05 to +0.09. So the copies didn't change a single route. They inflated four margins in a set where most decisions are a few hundredths apart. The one miss, the discount prompt, was nearest to "What is 15% of 200?", a cheap example, by 0.025.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limits
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;N is 24, one labeler (me), and a 12/12 split I chose.&lt;/li&gt;
&lt;li&gt;Costs are projected from assumed answer sizes and the July 2026 list prices in the harness. Nothing was answered, so I don't know whether Flash-Lite would have solved the misrouted prompts. If it would, those mistakes really are savings, and my labels are what needs questioning.&lt;/li&gt;
&lt;li&gt;One run per model at temperature 0. In the cache, all 48 classifier replies are exactly &lt;code&gt;ROUTE: cheap&lt;/code&gt; or &lt;code&gt;ROUTE: hard&lt;/code&gt;, so no parse fallback was involved.&lt;/li&gt;
&lt;li&gt;The router's own calls aren't in the projection. From the cached token counts, the 24 classifier calls cost $0.0008 on Flash-Lite and $0.0039 on Haiku at list price, about 5% of the oracle's bill for Haiku.&lt;/li&gt;
&lt;li&gt;The margins come from embeddings cached on my machine. The routes they produce match the committed results, but the margins themselves are not in the repo.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I would do differently
&lt;/h2&gt;

&lt;p&gt;Report routing errors by direction. "0.88" hides that all three misses sent hard work to the cheap model, and that is the direction that risks wrong answers.&lt;/p&gt;

&lt;p&gt;Measure savings against the oracle as well as against always strong. A router that is always right costs exactly the oracle's number, so one that comes in under it has misrouted something.&lt;/p&gt;

&lt;p&gt;Put a price on a misroute. The honest version answers the misrouted hard prompts with the cheap model and grades them. A rougher one charges each misroute the strong model's price as well, as if a later check had escalated it.&lt;/p&gt;

&lt;p&gt;Write the router's examples from a separate pool than the test prompts, and report the margin next to the route.&lt;/p&gt;

&lt;p&gt;Count the router's own calls in the cost.&lt;/p&gt;

&lt;p&gt;The routing code, prompts and per-prompt routes for both models are in &lt;a href="https://github.com/SarthakB11/agentic-patterns" rel="noopener noreferrer"&gt;github.com/SarthakB11/agentic-patterns&lt;/a&gt;, in &lt;code&gt;benchmarks/bench_routing.py&lt;/code&gt;, &lt;code&gt;patterns/routing/semantic.py&lt;/code&gt; and &lt;code&gt;benchmarks/results/&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>agents</category>
      <category>python</category>
    </item>
    <item>
      <title>My agent's verifier rejected 0 of 11 answers, and the score still dropped</title>
      <dc:creator>sarthak bhardwaj</dc:creator>
      <pubDate>Mon, 16 Nov 2026 22:29:36 +0000</pubDate>
      <link>https://dev.to/sarthak_bhardwaj_05aba55d/my-agents-verifier-rejected-0-of-11-answers-and-the-score-still-dropped-383o</link>
      <guid>https://dev.to/sarthak_bhardwaj_05aba55d/my-agents-verifier-rejected-0-of-11-answers-and-the-score-still-dropped-383o</guid>
      <description>&lt;p&gt;I added a verify-before-finish gate to a ReAct agent: before the loop accepts a final answer, a second model call checks whether the trajectory supports it. On 15 two-hop questions with Gemini 3.1 Flash-Lite, plain ReAct solved 10 and ReAct with the gate solved 9. In my results file I explained the drop as the price of verification: the extra check eats into a fixed iteration budget. (That paragraph is corrected now.)&lt;/p&gt;

&lt;p&gt;That explanation was wrong. The verifier ran 11 times and accepted all 11 answers. It never rejected anything, so it never cost the loop a step. The gap came from somewhere else, and so did most of the failures.&lt;/p&gt;

&lt;p&gt;This is from &lt;a href="https://github.com/SarthakB11/agentic-patterns" rel="noopener noreferrer"&gt;agentic-patterns&lt;/a&gt;, where I implement agent patterns in plain Python and measure them against live models.&lt;/p&gt;

&lt;h2&gt;
  
  
  The setup
&lt;/h2&gt;

&lt;p&gt;The benchmark uses an invented knowledge base of 20 facts about rivers, mountains and countries that don't exist, so the model can't answer from memory. Every question takes two hops. "What is the capital of the country the Kelvorin River flows through?" needs the river's country first, then that country's capital. The agent writes Thought/Action text, has &lt;code&gt;search&lt;/code&gt; and &lt;code&gt;lookup&lt;/code&gt; tools, and gets 6 steps.&lt;/p&gt;

&lt;p&gt;The verify variant runs the same loop with one sentence appended to the system prompt:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;system_prompt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{FEW_SHOT_SYSTEM_PROMPT}\n\nNote: a verifier checks every Finish against the trajectory "&lt;/span&gt;
    &lt;span class="s2"&gt;"before accepting it, so only finish once your observations actually support the answer."&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The docstring gives a second reason for that sentence: it keeps the two variants' first requests from colliding in the on-disk response cache. That detail matters later.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Foalpvzzbtddvr5i3om2p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Foalpvzzbtddvr5i3om2p.png" alt="Tasks solved by variant for Gemini 3.1 Flash-Lite and Claude Haiku 4.5" width="800" height="448"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Reading the steps
&lt;/h2&gt;

&lt;p&gt;The results JSON keeps each task's final answer and call count, not the steps. The response cache from the July run was still on my disk, though (it's gitignored). I replayed both models through the benchmark code with a provider that raises on any cache miss. That made 0 network calls, and all 60 ReAct rows (15 tasks, 2 variants, 2 models) came back identical to the committed results. So I could read every step the agents took.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the one task went
&lt;/h2&gt;

&lt;p&gt;When the verifier accepts, the verify loop behaves exactly like the plain one. With zero rejections, the only thing different between the two Gemini runs was that sentence in the prompt. The searches drifted apart anyway. The verify variant lost t03 and t14, both about Lake Azurine, and won t02, which the plain loop lost. Net result: one task down.&lt;/p&gt;

&lt;p&gt;On t14 the verify agent searched for "Lake Azurine", "Lake Azure", "What is Lake Azurine?", "\"Lake Azurine\"", "Lake Azurine location" and "What country is Lake Azurine in?". Six searches, six "No results found", budget gone. The plain agent tried plain "Azurine" on its second step and got the fact.&lt;/p&gt;

&lt;h2&gt;
  
  
  The search tool was the real problem
&lt;/h2&gt;

&lt;p&gt;Here is the matching logic:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;_FACTS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;_FACTS&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;fact_key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fact_value&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;_FACTS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;fact_key&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;fact_key&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;fact_value&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"No results found for '{query}'."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The fact is stored under "azurine lake". "lake azurine" isn't a substring of that key, and the key isn't a substring of it. "capital of Ostrenia" misses "ostrenia capital" the same way, while bare "Ostrenia" hits because it sits inside the key. The tool rewards short, oddly ordered queries and punishes the way people (and models) phrase things.&lt;/p&gt;

&lt;p&gt;Across both Gemini variants the model made 125 search calls and no lookup calls; the one worked example in the prompt only uses &lt;code&gt;search&lt;/code&gt;. 64 of the 125 searches came back empty. Each of Gemini's 8 budget stops spent at least 3 of its 6 steps on empty searches. In 3 of them the fact the agent needed arrived on step 6, with no step left to answer.&lt;/p&gt;

&lt;p&gt;So 10/15 against 9/15 measures how a model wanders through a brittle tool under two slightly different prompts. It tells me nothing about verification.&lt;/p&gt;

&lt;h2&gt;
  
  
  On Haiku the verifier blocked right answers
&lt;/h2&gt;

&lt;p&gt;The same code against Claude Haiku 4.5 scored 5/15 plain and 1/15 with the gate. Here the verifier was busy: 14 calls, 10 rejections. Half of those rejections hit answers the grader counts as right (Marveth once, drenn twice, Vessic twice).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0ji4digw5m5n01qrtdd4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0ji4digw5m5n01qrtdd4.png" alt="Verifier verdicts per model" width="800" height="352"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Haiku often wrote out a whole imagined trajectory in one reply, observations included. 96 of its 105 search arguments contain the text "Observation:". My parser:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;_ACTION_RE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"Action:\s*(\w+)\[(.*)\]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;DOTALL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The greedy &lt;code&gt;.*&lt;/code&gt; with &lt;code&gt;DOTALL&lt;/code&gt; runs to the last &lt;code&gt;]&lt;/code&gt; in the reply, so the invented text became the search argument and stayed in the trajectory. On t01 in the verify run, Haiku's first search argument starts like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Kelvorin River]

Observation: The Kelvorin River is a river in Scotland.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The real tool replied that the river flows through Ostrenia, the agent went on to find Marveth, and the verifier rejected Marveth. Its reason: "The trajectory contains a critical inconsistency". It had read "Scotland" and "Ostrenia" as two observations that contradict each other. Given what it was shown, it had a point. My parser had polluted the trajectory it was judging.&lt;/p&gt;

&lt;p&gt;The loose matcher makes it worse. A long argument full of invented text still contains a fact key like "sablewood forest", so search keeps handing back the first-hop fact while the agent asks for the capital.&lt;/p&gt;

&lt;h2&gt;
  
  
  The one direct success is a grading bug
&lt;/h2&gt;

&lt;p&gt;Answering directly with no tools scored 1/15 on both models, and it was the same task each time:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"t12"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Which country's capital is Northarrow, given it contains Cindrapass?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
 &lt;span class="s2"&gt;"Northarrow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"cindrapass"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"grendale capital"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The question asks for a country, and the gold answer is the capital. Gemini's direct reply began "There is no country with a capital named Northarrow" and passed the substring check. All four ReAct runs on t12 answered "Grendale", which is right, and were scored wrong. The true direct score is 0/15, and every ReAct number above is one task low. I have since fixed the task and regraded the stored answers, so the repo now reports 11/15 and 10/15 for Gemini and 6/15 and 2/15 for Haiku, with the first grading kept in a table beside them. The numbers in this post are the ones I first published.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limits
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;N is 15, with one run per variant per model. A one-task gap is noise until it repeats.&lt;/li&gt;
&lt;li&gt;I can't separate the prompt sentence from ordinary drift. The results file itself notes that the ReAct loop "is not perfectly deterministic at temperature 0". Either way the cause isn't verification, and that is the only claim I'm making about the gap.&lt;/li&gt;
&lt;li&gt;The step-level claims come from a cache that lives on my machine. The committed results agree row for row, but a reader can't check the steps without rerunning.&lt;/li&gt;
&lt;li&gt;The verifier is the same model as the agent. A separate verifier model might behave differently.&lt;/li&gt;
&lt;li&gt;"Right" here means the benchmark's lenient substring grader, t12 bug included.&lt;/li&gt;
&lt;li&gt;I haven't rerun anything with a fixed tool or parser, so I don't know what the scores would be.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I would do differently
&lt;/h2&gt;

&lt;p&gt;Read the steps before writing the explanation. My results paragraph told a reasonable story that one look at the steps would have killed.&lt;/p&gt;

&lt;p&gt;Save steps in the results file. I got lucky that the cache survived.&lt;/p&gt;

&lt;p&gt;Report the verifier as its own metric: how often it rejects, and how often a rejected answer was right. 0 of 11 says the gate never acted. 5 of 10 says it is blocking good answers.&lt;/p&gt;

&lt;p&gt;Match tool keys by words. I checked a version that returns a fact when every word of its key appears in the query. It would have answered 49 of Gemini's 64 empty searches, each with the right fact:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;benchmarks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;bench_react&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;_FACTS&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;words&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kt"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findall&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"[a-z]+"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;search_by_words&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"""Return the first fact whose key words all appear in the query."""&lt;/span&gt;
    &lt;span class="n"&gt;q&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;words&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fact&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;_FACTS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;words&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;fact&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Stop parsing the action at the first &lt;code&gt;]&lt;/code&gt;, so a model that writes its own observations can't smuggle them into the trajectory.&lt;/p&gt;

&lt;p&gt;Let both variants share the cache. I changed the prompt to avoid collisions, but a collision is what I wanted: with identical prompts, identical requests get identical responses, and the verify run would split from the plain run only at a rejection. That is the comparison the benchmark was meant to make.&lt;/p&gt;

&lt;p&gt;The results files record $0.0097 for the Gemini ReAct run and $0.2576 for Haiku's. The code and per-task results are in &lt;a href="https://github.com/SarthakB11/agentic-patterns" rel="noopener noreferrer"&gt;github.com/SarthakB11/agentic-patterns&lt;/a&gt;, in &lt;code&gt;benchmarks/bench_react.py&lt;/code&gt;, &lt;code&gt;patterns/react/verify.py&lt;/code&gt; and &lt;code&gt;benchmarks/results/&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>agents</category>
      <category>python</category>
    </item>
    <item>
      <title>My LLM judge failed "Paris." as the capital of France. The rubric was grading the wrong thing.</title>
      <dc:creator>sarthak bhardwaj</dc:creator>
      <pubDate>Fri, 13 Nov 2026 21:06:21 +0000</pubDate>
      <link>https://dev.to/sarthak_bhardwaj_05aba55d/my-llm-judge-failed-paris-as-the-capital-of-france-the-rubric-was-grading-the-wrong-thing-1m9l</link>
      <guid>https://dev.to/sarthak_bhardwaj_05aba55d/my-llm-judge-failed-paris-as-the-capital-of-france-the-rubric-was-grading-the-wrong-thing-1m9l</guid>
      <description>&lt;p&gt;My LLM judge agreed with my hand labels on 12 of 20 answers: 0.60 accuracy, Cohen's kappa 0.20. Same model, same 20 answers, one system prompt changed, and it agreed on 19 of 20: 0.95, kappa 0.90. The model was fine. I had handed it a rubric that graded something my labels never asked about, and the clearest sign was a one-word answer it refused to pass.&lt;/p&gt;

&lt;p&gt;This came out of &lt;a href="https://github.com/SarthakB11/agentic-patterns" rel="noopener noreferrer"&gt;agentic-patterns&lt;/a&gt;, a repo where I implement 12 agent patterns in plain Python and then measure each one against a live model. The evaluation pattern has an LLM-as-judge, so the benchmark for it asks the obvious question: does the judge agree with a person?&lt;/p&gt;

&lt;h2&gt;
  
  
  The setup
&lt;/h2&gt;

&lt;p&gt;Twenty question and answer pairs, ten good and ten bad, labeled by me. A good answer is correct and answers what was asked. A bad answer is wrong or off topic. I made them easy on purpose so the label would not be up for debate:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nc"&gt;JudgeItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"q05"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"What is the capital of France?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Paris."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nc"&gt;JudgeItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"q06"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"What is the capital of France?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Lyon."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nc"&gt;JudgeItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"q17"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"What is 12 multiplied by 12?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"144."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="nc"&gt;JudgeItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"q18"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"What is 12 multiplied by 12?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"121."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The judge is Gemini 3.1 Flash-Lite. It reasons through named steps, then ends with a &lt;code&gt;SCORE&lt;/code&gt; line (0 to 10) and a &lt;code&gt;VERDICT&lt;/code&gt; line, pass at 7 or above. I report three numbers: accuracy against my labels, Cohen's kappa, and position consistency from a pairwise check where 5 better/worse pairs are shown in both orders.&lt;/p&gt;

&lt;h2&gt;
  
  
  The first run
&lt;/h2&gt;

&lt;p&gt;0.60 accuracy, kappa 0.20. Every one of the 8 errors went the same way: the judge failed an answer I had marked good. It passed none of the bad answers, so it passed 2 of 20 answers overall, where my labels pass 10.&lt;/p&gt;

&lt;p&gt;One of the failures was "Paris." for "What is the capital of France?"&lt;/p&gt;

&lt;p&gt;The reason was sitting in the system prompt. For the first run I reused the pattern's default pointwise judge, and that judge was written for a support bot:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;_RUBRIC_SYSTEM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s2"&gt;"You grade a support bot's reply. Evaluation steps: (1) check factual "&lt;/span&gt;
    &lt;span class="s2"&gt;"accuracy against any reference given, (2) check the reply names a "&lt;/span&gt;
    &lt;span class="s2"&gt;"concrete next step, (3) check tone is professional and concise. "&lt;/span&gt;
    &lt;span class="s2"&gt;"Reason through each step briefly, then end with a SCORE line (0-10) "&lt;/span&gt;
    &lt;span class="s2"&gt;"and a VERDICT line (pass if SCORE &amp;gt;= 7, else fail)."&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Read step 2 and "Paris." fails every time. There is no next step in "Paris." The judge was doing its job well. Its job had nothing to do with my labels, which only ask whether the answer is right.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix
&lt;/h2&gt;

&lt;p&gt;I gave the benchmark its own judge, one that grades what the labels grade:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;_CORRECTNESS_SYSTEM&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s2"&gt;"You grade whether a reply correctly and relevantly answers a question. "&lt;/span&gt;
    &lt;span class="s2"&gt;"Evaluation steps: (1) check the reply is factually accurate, (2) check "&lt;/span&gt;
    &lt;span class="s2"&gt;"the reply is directly responsive to what was asked, on-topic and not "&lt;/span&gt;
    &lt;span class="s2"&gt;"evasive. Ignore tone, phrasing style, length, and whether a next step "&lt;/span&gt;
    &lt;span class="s2"&gt;"or extra context is offered; a short, correct, on-topic reply is a "&lt;/span&gt;
    &lt;span class="s2"&gt;"pass. Reason through each step briefly, then end with a SCORE line "&lt;/span&gt;
    &lt;span class="s2"&gt;"(0-10) and a VERDICT line (pass if SCORE &amp;gt;= 7, else fail)."&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The verdict parser and the SCORE/VERDICT format stayed the same, so the only thing that changed between runs is the question the judge was asked. I also ran the same code against Claude Haiku 4.5 with no change to the library:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Gemini 3.1 Flash-Lite&lt;/th&gt;
&lt;th&gt;Claude Haiku 4.5&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Accuracy (N=20)&lt;/td&gt;
&lt;td&gt;0.95&lt;/td&gt;
&lt;td&gt;0.85&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cohen's kappa&lt;/td&gt;
&lt;td&gt;0.90&lt;/td&gt;
&lt;td&gt;0.70&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Position consistency (5 pairs)&lt;/td&gt;
&lt;td&gt;1.00&lt;/td&gt;
&lt;td&gt;1.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Judge pass rate (labels: 0.50)&lt;/td&gt;
&lt;td&gt;0.55&lt;/td&gt;
&lt;td&gt;0.45&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Items it got wrong&lt;/td&gt;
&lt;td&gt;q12&lt;/td&gt;
&lt;td&gt;q03, q11, q12&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft4pzh9slsqwyywyq02c2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft4pzh9slsqwyywyq02c2.png" alt="Bar charts of judge accuracy and Cohen's kappa: Gemini before 0.60 and 0.20, Gemini after 0.95 and 0.90, Haiku 4.5 after 0.85 and 0.70" width="799" height="373"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The miss that is left
&lt;/h2&gt;

&lt;p&gt;Both models got q12 "wrong":&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nc"&gt;JudgeItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"q12"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"What is the status of order 48213?"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="s2"&gt;"I don't have any information about that."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I labeled it bad because it does not answer the question. Both judges passed it. The more I look at it, the more I think the judges have a point: an assistant that has no data on an order and says so is behaving correctly, and my rubric's own words ("not evasive") could go either way on it. This one is a label problem, and I have left it in the results as a miss because changing a label after seeing the judge disagree is the kind of thing that makes a benchmark lie to you.&lt;/p&gt;

&lt;p&gt;Haiku's other two misses (q03, the cancel steps, and q11, "Order 48213 shipped on July 2.") are the old pattern in a milder form: correct answers failed. The results file keeps verdicts only, so I can't tell you what it objected to.&lt;/p&gt;

&lt;h2&gt;
  
  
  Kappa told me nothing here
&lt;/h2&gt;

&lt;p&gt;I report kappa because raw agreement flatters a judge that leans toward one verdict. On this set it added no information at all. With labels split exactly 10 and 10, chance agreement is 0.5 whatever the judge does, so kappa is always 2 x accuracy minus 1. I checked every way 8 errors can split between false passes and false fails using the repo's own &lt;code&gt;cohens_kappa&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;patterns&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;evaluation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;meta&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cohens_kappa&lt;/span&gt;

&lt;span class="n"&gt;human&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;  &lt;span class="c1"&gt;# 10 good, 10 bad&lt;/span&gt;
&lt;span class="n"&gt;good&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;human&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;bad&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;human&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="c1"&gt;# fn false fails, 8 - fn false passes&lt;/span&gt;
    &lt;span class="n"&gt;judge&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;human&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;good&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;judge&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;bad&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;judge&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;cohens_kappa&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;judge&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;human&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It prints 0.2 nine times. 0.95 accuracy gives 0.90 and 0.85 gives 0.70, which is the table above. Kappa earns its place when the labels are skewed. With 18 good and 2 bad, a judge that passes everything scores 0.90 accuracy and 0.0 kappa. On a balanced set the number that would have told me fastest was the judge's pass rate: 0.10 against a label rate of 0.50 says "this judge is grading something stricter than you are" before you read a single verdict.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limits
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;N is 20. The items are deliberately unambiguous, so these numbers say the judge can follow a correctness rubric on easy cases. They say nothing about long answers or answers where people disagree.&lt;/li&gt;
&lt;li&gt;One labeler, me. I never measured my own agreement with a second person, so I don't know the human ceiling.&lt;/li&gt;
&lt;li&gt;I wrote the fixed rubric after seeing the first run fail, and scored it on the same 20 items. That is tuning on the test set. A held-out set would make 0.95 mean more.&lt;/li&gt;
&lt;li&gt;The first run never made it into the repo as a per-item file. What survives is the aggregate and the "Paris." example in RESULTS.md.&lt;/li&gt;
&lt;li&gt;One run per model at temperature 0. No test-retest.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I would do differently
&lt;/h2&gt;

&lt;p&gt;Write the judge's rubric from the label definition before the first run, and diff the two texts. The mismatch here was visible in plain English; I just never put the two side by side.&lt;/p&gt;

&lt;p&gt;Save every run's per-item output, including the bad ones. The most useful run of this benchmark is the one I can't show you item by item.&lt;/p&gt;

&lt;p&gt;Put the judge's pass rate in the report next to accuracy. It is one division and it points at the direction of the bias.&lt;/p&gt;

&lt;p&gt;Hold out half the items before touching the rubric, and get a second person to label them.&lt;/p&gt;

&lt;p&gt;The Gemini run of this benchmark is 30 short calls (20 pointwise, 10 pairwise) and cost $0.0035. The per-item verdicts for both models, with the fixed prompt, are in the repo: &lt;a href="https://github.com/SarthakB11/agentic-patterns" rel="noopener noreferrer"&gt;github.com/SarthakB11/agentic-patterns&lt;/a&gt;, in &lt;code&gt;benchmarks/bench_evaluation.py&lt;/code&gt; and &lt;code&gt;RESULTS.md&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>python</category>
      <category>testing</category>
    </item>
    <item>
      <title>Turning Music Into Art — Building a Synesthesia Simulator with Gemini</title>
      <dc:creator>sarthak bhardwaj</dc:creator>
      <pubDate>Sun, 14 Sep 2025 18:54:05 +0000</pubDate>
      <link>https://dev.to/sarthak_bhardwaj_05aba55d/turning-music-into-art-building-a-synesthesia-simulator-with-gemini-3459</link>
      <guid>https://dev.to/sarthak_bhardwaj_05aba55d/turning-music-into-art-building-a-synesthesia-simulator-with-gemini-3459</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/google-ai-studio-2025-09-03"&gt;Google AI Studio Multimodal Challenge&lt;/a&gt;&lt;/em&gt;  &lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;I built the &lt;strong&gt;Synesthesia Simulator&lt;/strong&gt;, an AI-powered applet designed to translate sound and imagery into a unified, cross-sensory artistic experience. It creatively simulates the neurological trait of synesthesia, allowing users to &lt;em&gt;see music as color&lt;/em&gt; and &lt;em&gt;hear pictures as melodies&lt;/em&gt;.  &lt;/p&gt;

&lt;p&gt;The applet provides a creative and exploratory space for users to discover novel connections between their senses. You can upload an &lt;strong&gt;audio file&lt;/strong&gt;, an &lt;strong&gt;image file&lt;/strong&gt;, or both, and the AI generates:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A Descriptive Scene&lt;/strong&gt; – A vivid, artistic narrative describing the blended sensory experience.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Creative Prompts&lt;/strong&gt; – Inspiring ideas for writing, art, or reflection based on the output.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A Generated Vision&lt;/strong&gt; – A unique AI-generated image visually representing the fusion of sound and/or visuals.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Creative Chat&lt;/strong&gt; – An interactive chat session with a creative AI assistant, primed with the context of your generated experience, to explore ideas further.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My goal was to create a tool that not only showcases advanced AI but also serves as a source of inspiration — particularly for creative and neurodiverse individuals who may naturally think in cross-sensory ways. It's not a medical tool, but a &lt;strong&gt;canvas for imagination&lt;/strong&gt;.  &lt;/p&gt;




&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Live Applet Link:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
➡️ &lt;a href="https://ai.studio/apps/drive/1Zc-tOnjDSxIu59zuIDHLcKzF-EHAjA2n" rel="noopener noreferrer"&gt;Launch the Synesthesia Simulator Here&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Screenshots &amp;amp; Walkthrough:&lt;/strong&gt;  &lt;/p&gt;

&lt;p&gt;Here’s the main interface where you can upload an audio file and an image:&lt;br&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fexzof70lp0jfpu3m8bft.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fexzof70lp0jfpu3m8bft.png" alt="Synesthesia Simulator Upload" width="799" height="477"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;After processing, the applet presents the AI's synesthetic interpretation alongside a newly generated piece of art. The app includes a built-in audio visualizer that reacts to your music, with customizable color schemes:&lt;br&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo7c0vip9y94ovvn0opek.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo7c0vip9y94ovvn0opek.png" alt="Synesthesia Simulator Output &amp;amp; Visualizer" width="800" height="414"&gt;&lt;/a&gt;      &lt;/p&gt;

&lt;p&gt;Other features and showing the experience with a context-aware creative AI assistant:&lt;br&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feceeys5kxysd2qn1fox6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feceeys5kxysd2qn1fox6.png" alt="Synesthesia Chat" width="800" height="412"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkgsj1m8j8dmq7p3murmq.png" alt="History" width="800" height="414"&gt;
&lt;/h2&gt;

&lt;h2&gt;
  
  
  How I Used Google AI Studio
&lt;/h2&gt;

&lt;p&gt;Google AI Studio and the Gemini API power this entire experience. I combined multiple models in a seamless pipeline to handle complex multimodal tasks:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Gemini 2.5 Flash (Multimodal Understanding):&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Core of the simulator.
&lt;/li&gt;
&lt;li&gt;Handles system prompt + user prompt + audio file bytes + image file bytes all in one request.
&lt;/li&gt;
&lt;li&gt;Outputs a structured JSON (descriptiveScene, creativePrompts, imageGenerationInstruction) for reliable integration into the UI.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Imagen 4.0 (Image Generation):&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Translates the imageGenerationInstruction from Gemini into tangible artwork.
&lt;/li&gt;
&lt;li&gt;Creates visuals that embody the cross-sensory interpretation.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Gemini 2.5 Flash (Conversational AI):&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Powers the &lt;strong&gt;Creative Chat&lt;/strong&gt;.
&lt;/li&gt;
&lt;li&gt;A new chat session is initialized with descriptiveScene + creativePrompts as context.
&lt;/li&gt;
&lt;li&gt;Turns the assistant into a creative partner, offering deeper exploration of the user’s generated experience.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Multimodal Features
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;multimodal capabilities of Gemini&lt;/strong&gt; are what make this applet possible:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Cross-Modal Understanding:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Goes beyond analyzing audio and images separately.
&lt;/li&gt;
&lt;li&gt;Interprets emotional tone of melodies, maps rhythms to textures, and links color palettes to musical patterns.
&lt;/li&gt;
&lt;li&gt;Produces the descriptive scene that defines the synesthetic simulation.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Sense-Blending for Generation:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Uses cross-modal insights to drive Imagen prompts.
&lt;/li&gt;
&lt;li&gt;Example: &lt;em&gt;“Abstract glowing waves of violet and silver flowing in rhythm with deep piano chords.”&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Generates true synthesis of sound + visual inputs.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Contextual Conversation:&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creative Chat expands the experience.
&lt;/li&gt;
&lt;li&gt;Users can ask: &lt;em&gt;“What does the color red sound like in this song?”&lt;/em&gt; or &lt;em&gt;“Tell me a story based on the third creative prompt.”&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;The assistant responds with context-aware, imaginative answers.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;✨ Thank you for checking out my project!  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Submission by:&lt;/strong&gt; &lt;a href="https://dev.to/sarthak_bhardwaj_05aba55d"&gt;@sarthak_bhardwaj_05aba55d&lt;/a&gt;  &lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>googleaichallenge</category>
      <category>ai</category>
      <category>gemini</category>
    </item>
    <item>
      <title>Prove Your Health Status, Not Your Identity: Building ZK-VCR on Midnight</title>
      <dc:creator>sarthak bhardwaj</dc:creator>
      <pubDate>Mon, 08 Sep 2025 03:45:01 +0000</pubDate>
      <link>https://dev.to/sarthak_bhardwaj_05aba55d/prove-your-health-status-not-your-identity-building-zk-vcr-on-midnight-1l01</link>
      <guid>https://dev.to/sarthak_bhardwaj_05aba55d/prove-your-health-status-not-your-identity-building-zk-vcr-on-midnight-1l01</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/midnight-2025-08-20"&gt;Midnight Network "Privacy First" Challenge&lt;/a&gt; - Protect That Data prompt&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;I built &lt;strong&gt;ZK-VCR (Verifiable Credential Oracle)&lt;/strong&gt;, a decentralized application that pioneers a new standard for privacy in on-chain transactions. It allows users to prove they meet specific health criteria (like having a low cardiovascular risk score) to a smart contract without ever revealing their underlying personal health information.&lt;/p&gt;

&lt;p&gt;The project solves the "Leaky Bucket" problem of modern data privacy, where users are forced to hand over sensitive data to multiple services, risking exposure with every new interaction. ZK-VCR replaces this with an "Airlock" model, built on the philosophy of &lt;strong&gt;Privacy for the User, Transparency for the Algorithm, and Governance for the Source.&lt;/strong&gt; A user's data never leaves their device; instead, a Zero-Knowledge proof is generated locally and sent to the chain for verification.&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;The complete source code and detailed documentation are available on GitHub:&lt;br&gt;
&lt;strong&gt;&lt;a href="https://github.com/SarthakB11/zk-vcr" rel="noopener noreferrer"&gt;Source Code &amp;amp; Complete Documentation&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here is a live recording of the ZK-VCR Command-Line Interface (CLI) in action, demonstrating the complete end-to-end flow from a clinic generating a credential to a user privately verifying it on-chain.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/user-attachments/assets/1b93a224-a133-44aa-903a-e9bb0911e9a8" rel="noopener noreferrer"&gt;Watch the ZK-VCR Demo&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How I Used Midnight's Technology
&lt;/h2&gt;

&lt;p&gt;This project is built from the ground up using Midnight's core technology stack:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Compact Language:&lt;/strong&gt; The entire on-chain logic, including the smart contract and all ZK circuits, is written in Compact. I used it to define the contract's state (like the &lt;code&gt;owner&lt;/code&gt; and the &lt;code&gt;trustedIssuers&lt;/code&gt; map) and to implement the complex, privacy-preserving logic inside the &lt;code&gt;submitHealthProof&lt;/code&gt; circuit. Key features like &lt;code&gt;persistentHash&lt;/code&gt; were used to create a ZK-friendly signature scheme.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;MidnightJS SDK:&lt;/strong&gt; The entire off-chain portion of the DApp—the user CLI, administrator panel, and issuer tool—is built in TypeScript and uses the &lt;code&gt;MidnightJS&lt;/code&gt; SDK. This library was essential for all blockchain interactions, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Deploying and finding contracts on the testnet.&lt;/li&gt;
&lt;li&gt;Managing wallets and private state.&lt;/li&gt;
&lt;li&gt;Constructing and submitting transactions to call the contract's circuits.&lt;/li&gt;
&lt;li&gt;Querying the public on-chain state to display it to the user.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Private Witnesses:&lt;/strong&gt; The core of the DApp's privacy model relies on Compact's witness system. The user's sensitive &lt;code&gt;VerifiableCredential&lt;/code&gt; and the administrator's &lt;code&gt;ownerSecretKey&lt;/code&gt; are passed as private witnesses, meaning they are used in the ZK proof computation but never revealed on-chain.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Data Protection as a Core Feature
&lt;/h2&gt;

&lt;p&gt;Data protection isn't just a feature of ZK-VCR; it is the central design principle.&lt;/p&gt;

&lt;p&gt;The "Airlock" model ensures that the user's personal health information (PHI) &lt;strong&gt;never leaves their local machine&lt;/strong&gt;. When a user wants to prove their eligibility for a service, the &lt;code&gt;submitHealthProof&lt;/code&gt; ZK circuit is executed locally. The only artifact that is ever sent to the public blockchain is the anonymous ZK proof itself.&lt;/p&gt;

&lt;p&gt;This proof mathematically demonstrates three things without revealing the underlying data:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; The health data came from a trusted source (verified via a cryptographic signature).&lt;/li&gt;
&lt;li&gt; The health data meets the publicly defined criteria (the "AI" model was run on it).&lt;/li&gt;
&lt;li&gt; The proof is fresh and not being replayed (verified via a challenge-nonce).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The smart contract learns only a single binary fact: "An anonymous user has successfully proven they are low-risk." It learns nothing about their cholesterol, their blood pressure, or whether they smoke. This provides powerful, mathematically guaranteed privacy that is fundamentally superior to policy-based promises.&lt;/p&gt;

&lt;h2&gt;
  
  
  Set Up Instructions / Tutorial
&lt;/h2&gt;

&lt;p&gt;The following is a complete, step-by-step guide to setting up the development environment and running the full ZK-VCR demo.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/SarthakB11/zk-vcr/blob/master/TUTORIAL.md" rel="noopener noreferrer"&gt;View the Full Tutorial on GitHub&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Submission by: &lt;a href="https://dev.to/sarthak_bhardwaj_05aba55d"&gt;@sarthak_bhardwaj_05aba55d&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>midnightchallenge</category>
      <category>web3</category>
      <category>blockchain</category>
    </item>
  </channel>
</rss>
