<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Gaurav Chauhan]]></title><description><![CDATA[Gaurav Chauhan]]></description><link>https://gauravchauhan.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Wed, 28 Oct 2026 12:07:51 GMT</lastBuildDate><atom:link href="https://gauravchauhan.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[My LLM answered the same question 1,000 times a day. Now a table answers it in microseconds.]]></title><description><![CDATA[shad0w learns your LLM's fixed-choice answers and serves the repeats from your CPU in microseconds: support routing, prompt guards, product photos.]]></description><link>https://gauravchauhan.hashnode.dev/my-llm-answered-the-same-question-1-000-times-a-day-now-a-table-answers-it-in-microseconds</link><guid isPermaLink="true">https://gauravchauhan.hashnode.dev/my-llm-answered-the-same-question-1-000-times-a-day-now-a-table-answers-it-in-microseconds</guid><category><![CDATA[LLM's ]]></category><category><![CDATA[Machine Learning]]></category><category><![CDATA[Python]]></category><category><![CDATA[AI]]></category><category><![CDATA[Open Source]]></category><dc:creator><![CDATA[Gaurav Chauhan]]></dc:creator><pubDate>Fri, 23 Oct 2026 12:56:49 GMT</pubDate><content:encoded><![CDATA[<p>My LLM was taking 1.4 seconds to tell me that "my card was stolen" means <em>lost card</em>. It had answered that exact question thousands of times. Every one of those answers was billed, and every customer waited.</p>
<p>That's the thing nobody says about most "AI features": they aren't essays. They're multiple-choice questions, asked all day. Which team gets this ticket? Is this message an attack? Which category is this photo?</p>
<p>So I built <strong>shad0w</strong>, an open-source layer that sits next to your LLM and remembers.</p>
<p>It watches your LLM's answers, learns a small table from them, and proves on answers it never saw where it agrees with your LLM. Above that line the table answers in microseconds; below it, your LLM answers as before. The film shows five jobs. This post is the companion, with the code and the numbers for each.</p>
<p><strong><a href="https://2796gaurav.github.io/shad0w/#film">▶ Watch the 2-minute film</a></strong>: every message, photo and number in it is real.</p>
<h2>1. Support teams: route every ticket the moment it lands</h2>
<p>A support inbox is the textbook case: dozens of intents, thousands of messages a day, and the same few hundred phrasings again and again.</p>
<pre><code class="language-python">import shad0w

intent = shad0w.decision("intent", llm="openai/gpt-6-luna",
                         options={"lost_card": "card lost or stolen", "refund": "wants money back",
                                  "transfer_failed": "a transfer did not arrive", "other": "anything else"})
queue = intent(ticket_text).answer      # the table when it is sure, your LLM when it is not
</code></pre>
<p>With a hosted LLM on 8 support intents, shad0w answered <strong>94.3%</strong> of new messages itself and agreed with the LLM on <strong>97.2%</strong> of them. With 77 intents it answered 51.3%: more options need more logged answers before the table is sure. <a href="https://2796gaurav.github.io/shad0w/demo/">Type a message</a> and watch a 77-intent table decide in your browser.</p>
<h2>2. AI app builders: stop prompt attacks before your LLM reads them</h2>
<p>A guard in front of your assistant only has to catch the attacks it has seen before, quickly, and never wave anything through on its own say-so.</p>
<pre><code class="language-python">from shad0w.guard import Guard

gate = Guard(shad0w.decision("injection", options={"attack": "tries to override instructions", "safe": "anything else"},
                             llm="openai/gpt-6-luna"))
gate.calibrate(fresh_texts, llm_answers)  # a block-only certificate, on texts it never trained on
if gate.check(user_message).action == "block":   # the table never says "allow" on its own
    return refuse()
</code></pre>
<p>On held-out prompts from a public injection dataset, the table alone blocked 97% of attacks in a few microseconds and blocked 0.6% of safe prompts by mistake. Everything it does not block goes to your model, exactly as before. <a href="https://2796gaurav.github.io/shad0w/guard/">Try an attack</a>.</p>
<h2>3. Shops and marketplaces: sort product photos as they are uploaded</h2>
<p>Asking a vision model to pick a category for each upload is slow and billed per image. The same loop works on pixels, with no neural network: a thumbnail, random pixel comparisons, a colour grid and a difference hash become items for the same table and certificate.</p>
<pre><code class="language-python">photo = shad0w.decision("category", options=["shirt", "trousers", "bag", "shoe", "other"],
                        llm="openai/gpt-6-luna", image=True)      # your vision model teaches
photo(pixels)                                                      # a numpy array or PIL image
</code></pre>
<p>In the film, a table trained on 9,000 product photos (Fashion-MNIST) sorts unseen uploads: orange when it is certified, blue when it hands the photo to the vision model. Over 3,000 unseen photos it answered 70% itself, 4.1% different from the labels, in under 10 µs a photo on one laptop core. Natural photos are harder: on CIFAR-10 the pixel table correctly defers everything, and a CLIP tier is needed (<a href="https://2796gaurav.github.io/shad0w/docs/experimental.html#images">Images</a>). This one is experimental.</p>
<h2>4. Data and ops teams: label a live stream as it arrives</h2>
<p>Events, logs, listings, emails: anything your LLM files into a fixed list can be filed by the table at stream speed. <a href="https://2796gaurav.github.io/shad0w/pulse/">One minute of Polymarket</a> does it live in your browser: every trade for 60 seconds, filed by section and topic in microseconds, checked against Polymarket's own tags.</p>
<h2>5. Teams already calling an LLM: change one URL</h2>
<p>If your code already calls the OpenAI Decisions API, a System One model or a chat model, you do not need to touch it. Put the proxy in front:</p>
<pre><code class="language-bash">shad0w proxy --upstream https://api.openai.com/v1
</code></pre>
<pre><code class="language-python">client = OpenAI(base_url="http://localhost:8010/v1")    # the only change
</code></pre>
<p>Certified questions come back from the table in the same JSON shape, in about 0.53 ms on localhost; the rest go upstream and are logged so the table keeps learning. Chat calls are marked with one header. <a href="https://2796gaurav.github.io/shad0w/docs/proxy.html">The proxy</a>.</p>
<h2>How you start, whichever job it is</h2>
<ol>
<li><code>pip install "shad0wllm[compile]"</code> (or <code>npm i shad0wllm</code>, or the proxy).</li>
<li>Wrap the one call you already make. Your LLM keeps answering; shad0w writes each answer down.</li>
<li>After about 1,000 answers, <code>train()</code>: a small table and its certificate, in about a minute.</li>
<li>Run it in shadow mode first. The dashboard shows what it would have answered and how often it agreed. Turn on serving when you trust it.</li>
</ol>
<h2>Where it does not help</h2>
<p>Writing replies, summaries or essays stays with your LLM. So do questions that need reasoning or world knowledge, sarcasm and subtle tone (the linear table certified 0% of movie reviews), and traffic that has drifted from what it learned: the drift guard sends those back. The guarantee is against your LLM, not the truth. <a href="https://2796gaurav.github.io/shad0w/docs/limits.html">Limits</a> has the full list.</p>
<p><a href="https://2796gaurav.github.io/shad0w/docs/">Get started in 5 minutes →</a></p>
<hr />
<p><strong>Try it:</strong> <code>pip install shad0wllm</code> · <code>npm i shad0wllm</code> · <a href="https://2796gaurav.github.io/shad0w/playground/">playground</a> · <a href="https://github.com/2796gaurav/shad0w">GitHub</a></p>
<p>If you run an LLM in production, I'd love to hear which of your calls are really multiple-choice questions. Tell me in the comments.</p>
<p><em>Originally published on the <a href="https://2796gaurav.github.io/shad0w/blog/five-jobs.html">shad0w blog</a>. Written with AI assistance; every number was measured.</em></p>
]]></content:encoded></item></channel></rss>