<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://akbted.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://akbted.github.io/" rel="alternate" type="text/html" /><updated>2026-08-08T12:20:00+00:00</updated><id>https://akbted.github.io/feed.xml</id><title type="html">Anantha Krishna B — AI/ML Engineer</title><subtitle>Portfolio and blog of Anantha Krishna B — AI/ML Engineer building agentic AI, RAG systems and computer vision pipelines. Writing about AI, systems design and machine learning.</subtitle><author><name>Anantha Krishna B</name></author><entry><title type="html">It’s Not All About Model Training — Inference Does the Heavy Lifting</title><link href="https://akbted.github.io/blog/2026/08/03/llm-inference/" rel="alternate" type="text/html" title="It’s Not All About Model Training — Inference Does the Heavy Lifting" /><published>2026-08-03T00:00:00+00:00</published><updated>2026-08-03T00:00:00+00:00</updated><id>https://akbted.github.io/blog/2026/08/03/llm-inference</id><content type="html" xml:base="https://akbted.github.io/blog/2026/08/03/llm-inference/"><![CDATA[<p>Creating a model from scratch is a time-consuming process, and we don’t do that every single day. Even if we did, what really changes across models are two things — the data it’s trained on, and the underlying architecture and its functionality, like tool calling, image generation, or whether it’s plain text-to-text or fully multimodal.</p>

<p>What we <em>do</em> often work with as part of our daily tasks is inferencing. Inferencing as a topic is pretty vast, but lately I’ve been working on projects where I have to scale up inferencing for LLMs, and it’s forced me to actually sit down and understand what’s happening under the hood.</p>

<p>To better understand inferencing in LLMs, there are two key terms that need to be understood: <strong>Prefill</strong> and <strong>Decode</strong>. These two stages are also essential to understanding the KV cache, or the memory requirement, of a model during generation.</p>

<p><strong>Disclaimer</strong> -&gt; This is specific to decoder-based architectures (autoregressive models).</p>

<h2 id="a-quick-detour-sampling-parameters">A quick detour: Sampling Parameters</h2>

<p>A brief understanding of sampling parameters will also help with the overall picture. For example:</p>
<ul>
  <li><strong>Temperature</strong> -&gt; increases the overall spread of the output distribution and randomness, commonly (and loosely) called “creativity.”</li>
  <li><strong>Top-k</strong> -&gt; restricts sampling to only the k most likely next tokens.</li>
  <li><strong>Top-p (nucleus sampling)</strong> -&gt; restricts sampling to the smallest set of tokens whose cumulative probability crosses p.</li>
  <li><strong>max_tokens</strong> -&gt; caps how many tokens the model is allowed to generate.</li>
</ul>

<p><strong>Why do we even need this?</strong> -&gt; To avoid pure greedy search (always picking the single most probable next token, which makes outputs repetitive and robotic), to give the model some personality/variation in tone, and to stay within safety guardrails.</p>

<p>A bit off-topic, but useful context. Let’s get back to the two stages.</p>

<h2 id="what-really-happens-when-we-send-an-input-prompt-to-an-llm">What really happens when we send an input prompt to an LLM</h2>

<p><strong>Tokenization</strong> -&gt; Each model comes with its own unique tokenizer, which converts the input text into token IDs.</p>

<p>Once tokenized, the request is placed in a waiting queue. There are two types of requests that can exist in this queue:</p>
<ul>
  <li><strong>Prefill request</strong> (waiting request)</li>
  <li><strong>Decode request</strong> (running request)</li>
</ul>

<h3 id="what-is-prefill">What is Prefill?</h3>

<p>The model processes all the prompt tokens together, in one parallel pass. It builds the KV cache and produces the first output token.</p>

<p><em>The below diagram shows an example -&gt;</em></p>

<p><img src="/assets/images/prefill.png" alt="Prefill phase example" /></p>

<p>The metric to keep in mind here is <strong>TTFT (Time To First Token)</strong> — this could be something like 42ms, for example, depending on prompt length and hardware.</p>

<p>The <strong>KV cache</strong> is essentially a set of context vectors stored from each transformer layer, computed during this pass. It exists so the next token generation step can reuse this context instead of recomputing everything the model already worked out once before.</p>

<p>The KV cache is stored in GPU VRAM (in memory regions often referred to as “blocks”).</p>

<h3 id="what-is-decode-then">What is Decode, then?</h3>

<p>During decode, the model generates only one new token per pass. That token is fed back into the model as input to generate the next one — this feedback loop is the “autoregressive” part.</p>

<p><em>The below diagram shows an example -&gt;</em></p>

<video controls="" autoplay="" muted="" loop="" playsinline="" width="100%">
  <source src="/assets/videos/decode.mp4" type="video/mp4" />
</video>

<p>The metric to keep in mind here is <strong>TPOT (Time Per Output Token)</strong> — this could be something like 9ms per token, for example.
.
Put together: total latency for a generation roughly works out to <code class="language-plaintext highlighter-rouge">TTFT + (number of output tokens × TPOT)</code>. So for a 42ms TTFT and 4 tokens generated at ~9ms each, you’re looking at ~78ms end to end — a good chunk of which comes from decode once you’re generating longer outputs, even though decode is the “lighter” step per token.</p>

<h2 id="inference-engines">Inference Engines</h2>

<p>To improve inference speed, or to better optimize it for the GPU, there are different inference engines and serving frameworks out there. Examples: vLLM, SGLang, TensorRT-LLM, Triton Inference Server, etc.</p>

<p>Maybe that’s a topic for another post.</p>

<p>Hope to deep-dive into inference engines like vLLM and SGLang soon. I’ll also share a detailed post on Transformers and the attention mechanism soon.</p>]]></content><author><name>Anantha Krishna B</name></author><category term="ai" /><category term="llm" /><category term="inference" /><summary type="html"><![CDATA[A breakdown of how LLM inference actually works — the Prefill and Decode phases, why the KV cache exists, and the metrics (TTFT, TPOT) that actually determine how fast a response feels.]]></summary></entry><entry><title type="html">Anthropic’s New Models, and the Heat Engineering Teams Are Taking</title><link href="https://akbted.github.io/blog/2026/08/02/anthropic-new-models-and-the-heat/" rel="alternate" type="text/html" title="Anthropic’s New Models, and the Heat Engineering Teams Are Taking" /><published>2026-08-02T00:00:00+00:00</published><updated>2026-08-02T00:00:00+00:00</updated><id>https://akbted.github.io/blog/2026/08/02/anthropic-new-models-and-the-heat</id><content type="html" xml:base="https://akbted.github.io/blog/2026/08/02/anthropic-new-models-and-the-heat/"><![CDATA[<p>Every week, models get better. Demos get smoother. Benchmarks go up.</p>

<p>But inside companies, the conversation is shifting from <em>“Can we build it?”</em> to <em>“Who’s going to own it when it goes wrong?”</em></p>

<p>Because deploying AI at scale is not like shipping a feature. When AI fails, it does not just return an error—it can break your SLA, your compliance posture, or your customer’s trust. And regulators are now asking companies to <strong>prove how they govern AI systems</strong>, not just whether they work on demo day.</p>

<hr />

<h2 id="a-real-problem-processing-3-lakh-videos-a-day">A Real Problem: Processing 3 Lakh Videos a Day</h2>

<p>Let’s make this concrete.</p>

<p>You need to process <strong>300,000 videos per day</strong>. That is about <strong>3.5 videos per second</strong> (300k ÷ 86,400 seconds). Sounds manageable—until you realize this isn’t a <em>“write some Python”</em> problem. It’s a <strong>Big Data Architecture</strong> problem.</p>

<p>The first question everyone asks: <em>“Which AI model should I use?”</em></p>

<p>But the real questions are:</p>

<ul>
  <li>Streaming or batch?</li>
  <li>Who decides the trade-offs?</li>
  <li>What happens when the system is wrong?</li>
  <li>How much does the company lose?</li>
</ul>

<hr />

<h2 id="cctv-vs-upload--two-different-architectures">CCTV vs. Upload — Two Different Architectures</h2>

<p>Here’s where design judgment matters.</p>

<h3 id="scenario-1-live-cctv-monitoring-security-traffic-proctoring">Scenario 1: Live CCTV Monitoring <em>(Security, Traffic, Proctoring)</em></h3>

<p>You need real-time answers. A person fell—alert security <em>now</em>.</p>

<p>→ Use <strong>streaming</strong>: <code class="language-plaintext highlighter-rouge">RTSP/WebRTC → Media Server → Kafka → AI Workers</code></p>

<h3 id="scenario-2-user-uploads-insurance-claims-medical-records">Scenario 2: User Uploads <em>(Insurance Claims, Medical Records)</em></h3>

<p>Videos arrive in bursts. Users don’t expect instant answers.</p>

<p>→ Use <strong>batch processing</strong> with presigned URLs:
<code class="language-plaintext highlighter-rouge">Client uploads → S3 → SQS trigger → GPU workers pull from queue</code></p>

<blockquote>
  <p><strong>The queue is your shock absorber.</strong> When 10,000 uploads land at once, your system bends instead of breaking.</p>
</blockquote>

<hr />

<h2 id="can-ai-decide-this-for-you">Can AI Decide This for You?</h2>

<p><strong>No.</strong></p>

<p>AI can’t tell you whether to use streaming or batch. It can’t weigh your latency SLA against your budget. It can’t know whether your compliance team will accept a 2% false positive rate.</p>

<blockquote>
  <p><em>AI can write the code. It cannot design the system.</em></p>
</blockquote>

<p>Architecture decisions require judgment about trade-offs: cost vs. speed, explainability vs. accuracy, risk vs. scale. These are <strong>business and operational decisions</strong>, not just technical ones. And when things go wrong—when the model drifts, when a critical edge case fails—<strong>someone human has to own the consequences</strong>.</p>

<p>This is why system design remains a core competency, even as AI automates more of the coding.</p>

<hr />

<h2 id="two-techniques-that-change-the-economics">Two Techniques That Change the Economics</h2>

<p>If you try to run AI on every pixel of 300,000 videos, you’ll burn your GPU budget and still miss your SLA.</p>

<p><strong>The secret is filtration, not brute force.</strong></p>

<h3 id="1-keyframe-extraction">1. Keyframe Extraction</h3>

<p>Process only the frames that change (e.g., scene cuts, motion events).</p>

<ul>
  <li>A 1-minute video has ~1,800 frames</li>
  <li>Extract just 5 keyframes → <strong>99% reduction in compute cost</strong></li>
</ul>

<h3 id="2-cascade-filtering">2. Cascade Filtering</h3>

<p>Don’t send everything to your expensive model. Filter in stages:</p>

<table>
  <thead>
    <tr>
      <th>Stage</th>
      <th>Processor</th>
      <th>Question</th>
      <th>Action</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>1</td>
      <td>CPU</td>
      <td>Is there motion?</td>
      <td>No → discard</td>
    </tr>
    <tr>
      <td>2</td>
      <td>Tiny model</td>
      <td>Is there a person?</td>
      <td>No → discard</td>
    </tr>
    <tr>
      <td>3</td>
      <td>Heavy model</td>
      <td>Is the person doing X?</td>
      <td>Only ~5% of data reaches here</td>
    </tr>
  </tbody>
</table>

<hr />

<h3 id="but-which-technique-should-you-use">But which technique should you use?</h3>

<p>AI can’t answer that. You need to know:</p>

<ul>
  <li><strong>What are you detecting?</strong> (anomalies, people, weapons, text?)</li>
  <li><strong>What’s the cost of a false negative?</strong> (safety, money, reputation?)</li>
  <li><strong>What’s your latency budget?</strong></li>
</ul>

<p>That decision is <strong>architecture judgment</strong>, not prompt engineering.</p>

<hr />

<h2 id="the-ai-goes-wrong-question-the-one-nobody-wants-to-own">The “AI Goes Wrong” Question <em>(The One Nobody Wants to Own)</em></h2>

<p>This is where the real heat shows up. When your AI makes a mistake at scale:</p>

<ul>
  <li>Who decides whether to trust the output: engineering, product, compliance, or the customer?</li>
  <li>What’s the rollback plan when the model drifts?</li>
  <li>What’s the cost of false positives vs. false negatives—in rupees, time, brand, and legal exposure?</li>
</ul>

<hr />

<h2 id="my-takeaway">My Takeaway</h2>

<p>New models (from Anthropic and others) are making it easier to <strong>start</strong>. But the hard problems are still human problems:</p>

<ul>
  <li><strong>Who decides?</strong></li>
  <li><strong>What if it goes wrong?</strong></li>
  <li><strong>How much do we lose?</strong></li>
</ul>

<p>AI can automate the coding. It can suggest optimizations. But it can’t make the architectural trade-offs or carry the accountability.</p>

<p><strong>Designing these systems will remain a core competency—maybe not the coding, but the judgment.</strong></p>]]></content><author><name>Anantha Krishna B</name></author><category term="ai" /><category term="systems-design" /><category term="rag" /><category term="engineering" /><summary type="html"><![CDATA[Models keep getting better, but deploying AI at scale is a human problem. Thoughts on system design, cascade filtering, and who owns the consequences.]]></summary></entry></feed>