<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Siddhant Gupta on Medium]]></title>
        <description><![CDATA[Stories by Siddhant Gupta on Medium]]></description>
        <link>https://medium.com/@siddhantg314?source=rss-7a0b7dc45619------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*SmRpFA6lRVGYKGh5</url>
            <title>Stories by Siddhant Gupta on Medium</title>
            <link>https://medium.com/@siddhantg314?source=rss-7a0b7dc45619------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 15:47:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@siddhantg314/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[I stopped judging coding agents by demos. Here is what actually makes them useful.]]></title>
            <link>https://medium.com/@siddhantg314/i-stopped-judging-coding-agents-by-demos-here-is-what-actually-makes-them-useful-b21b65de9000?source=rss-7a0b7dc45619------2</link>
            <guid isPermaLink="false">https://medium.com/p/b21b65de9000</guid>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[openai-codex]]></category>
            <category><![CDATA[vibe-coding]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Siddhant Gupta]]></dc:creator>
            <pubDate>Tue, 24 Mar 2026 03:15:28 GMT</pubDate>
            <atom:updated>2026-03-24T03:15:28.673Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t_HOmqW0Z8bWfAx6b31elQ.png" /></figure><p>For a while, I judged coding agents the same way most people did.</p><p>I looked at the demo. I watched the model open files, write some code, maybe run a test, maybe even fix a bug. If it looked smooth, I came away impressed.</p><p>I do not think that way anymore.</p><p>Now I care about a much more boring question. Can I actually trust this thing inside a real repo, on a real task, with real consequences?</p><p>That is the line that matters.</p><p>A coding agent does not become useful when it can impress me for two minutes. It becomes useful when I can hand it a scoped task, let it work, review what it did, understand why it did it, and decide what to keep without feeling nervous the whole time.</p><p>And honestly, the current tools are starting to reflect that shift. OpenAI’s Codex now runs tasks in isolated environments, supports parallel work, shows terminal logs and test outputs, and uses repo level instruction files through AGENTS.md. The Codex CLI also exposes explicit approval modes instead of pretending every task should be fully autonomous. Anthropic’s Claude Code has similar ideas around project memory, permissions, and deterministic hooks. GitHub Copilot code review also treats AI review as advisory, not as a real approval, which I think is the right instinct. (<a href="https://openai.com/index/introducing-codex/?utm_source=chatgpt.com">OpenAI</a>)</p><p>That tells me something important. The real problem is no longer just model quality. It is how people and agents actually work together.</p><p>So when I think about what coding agents need to be useful, I keep coming back to six things.</p><h3>Approvals</h3><p>The first thing I want is a real approvals model.</p><p>Not fake control. Real control.</p><p>I do not want one extreme where the agent asks me before breathing. And I do not want the other extreme where it can rewrite half the repo, install random packages, and run shell commands like it owns the machine.</p><p>I want levels.</p><p>Sometimes I want the agent to stay in suggestion mode. Read the code, tell me what it would change, and wait. Sometimes I want it to edit files but still ask before running commands. And sometimes, for a tightly scoped task in a safe environment, I want it to go end to end.</p><p>That is why approval modes matter so much. In Codex CLI, OpenAI splits this into Suggest, Auto Edit, and Full Auto, with Full Auto running inside a sandboxed, network disabled environment scoped to the current directory. The newer Codex app also keeps secure defaults and lets teams define project rules for what can run with elevated permissions. That is much closer to how useful autonomy should work in practice. (<a href="https://help.openai.com/en/articles/11096431?utm_source=chatgpt.com">OpenAI Help Center</a>)</p><p>A good coding agent should not force me to choose between babysitting and blind trust. It should let me choose the right level for the task.</p><h3>Sandboxing</h3><p>This one is non negotiable.</p><p>If an agent can read, write, execute, and reach the network, then sandboxing is not a nice feature. It is the product.</p><p>The safer the environment is, the more freedom I can actually give the agent.</p><p>That sounds backwards, but it is true.</p><p>The reason I am comfortable letting an agent do more is not because I believe it will always behave well. It is because I know the blast radius is contained. Separate worktrees help. Isolated cloud environments help. Network disabled by default helps. Clear folder boundaries help. Easy rollback helps.</p><p>OpenAI’s Codex product leans into this pretty hard. Cloud tasks run in separate isolated environments preloaded with the repo, and the Codex app uses system level sandboxing with limited file access by default. That is the right direction because autonomy without containment is just anxiety with good branding.</p><p>When people say a coding agent feels trustworthy, a lot of the time what they really mean is this. I knew what it was allowed to touch.</p><h3>Diff review</h3><p>A lot of people still talk about model output as if the final answer is the product.</p><p>It is not.</p><p>For coding agents, the diff is the product.</p><p>That is where trust gets built or lost.</p><p>I do not care if the agent sounds confident in chat. I care whether I can open the changes, inspect them quickly, see what files moved, understand the reasoning, and connect that reasoning to something concrete like logs, tests, or comments.</p><p>OpenAI seems to understand this. Codex surfaces terminal logs and test outputs as evidence for what it did. The app is built around reviewing diffs, commenting on them, and letting multiple agents work in isolated copies without trashing the local git state. GitHub Copilot code review also stays in its lane. It leaves comments and suggestions, but it does not count as an approval for merge requirements. That separation matters. AI can help review code, but human signoff still has a different weight.</p><p>To me, a useful coding agent should make diff review feel easier, not heavier.</p><p>If I need to reverse engineer what the agent changed, or if the patch is messy, or if it touched unrelated files, the agent did not save me time. It just moved the work.</p><h3>Memory</h3><p>Memory sounds impressive until it becomes vague.</p><p>I do not want a coding agent that “remembers me.” I want one that remembers the right things, in the right place, for the right scope.</p><p>Project instructions are useful. Personal preferences are useful. Team conventions are useful. But all of them need boundaries.</p><p>This is where I think the best tools are getting more practical. Codex uses AGENTS.md files in the repository to tell the agent how to navigate the codebase, what commands to run, and how to follow project conventions. Claude Code uses layered memory through files like project level CLAUDE.md and user level CLAUDE.md, and those files are automatically loaded with hierarchy and scope.</p><p>That is the kind of memory I actually want.</p><p>Not a giant fuzzy brain. A small set of instructions that answer questions like these.</p><p>How do I run tests here<br>What style rules matter in this repo<br>Which folders are sensitive<br>What should never be changed automatically<br>What does a good PR look like for this team</p><p>That kind of memory makes agents more useful because it reduces avoidable mistakes. It also makes teams less dependent on heroic prompts.</p><h3>Repo context</h3><p>People often talk about context windows as if bigger automatically means better.</p><p>I do not buy that.</p><p>In real codebases, useful context is usually structured, not merely large.</p><p>An agent needs the shape of the repo. It needs the commands that matter. It needs the architecture notes that explain why something is weird. It needs to know which tests are fast, which ones are flaky, and which ones are expensive. It needs to know whether touching one file means also updating three others. It needs to know whether this service talks to another one through an event contract that should not be casually broken.</p><p>That is not a token problem. That is a context design problem.</p><p>The best repo context is opinionated. It says, start here. Use this command. Avoid this path. Read this doc before editing that module.</p><p>That is one reason I think repo instruction files matter more than flashy benchmark wins. They turn a coding agent from a smart stranger into a decently onboarded contributor.</p><h3>Deterministic guardrails</h3><p>Another thing I have started caring about more is this. Some behavior should not depend on whether the model “remembers” to do it.</p><p>If formatting must run after edits, make it automatic. If the agent should never touch production config without approval, enforce it. If every bash command should be logged, wire it in. If editing certain directories should trigger a warning or block, do not leave that up to vibes.</p><p>Anthropic’s Claude Code hooks are a good example of this kind of thinking. They let teams attach commands to tool events, including before or after reads, writes, edits, and bash calls. That means some important rules can become deterministic instead of prompt based.</p><p>I think this is underrated.</p><p>A useful coding agent is not just a strong model. It is a model inside a system that has guardrails where guardrails belong.</p><h3>When humans should step in</h3><p>I do not think useful agents remove humans from the loop. I think they move humans to better points in the loop.</p><p>For me, the handoff points are pretty simple.</p><p>First, I scope the task.<br>Second, I let the agent explore and draft.<br>Third, I step in on risky choices, unclear tradeoffs, or broad file changes.<br>Fourth, I make the final decision on what ships.</p><p>That is the model I trust.</p><p>The human should not be approving every tiny move. But the human also should not disappear until the merge button.</p><p>This is another reason I like that GitHub Copilot’s review comments behave like comments, not approvals. It reinforces the right mental model. AI is a reviewer, helper, or collaborator. It is not the accountable owner.</p><h3>What I think people actually want</h3><p>I do not think most developers want magic.</p><p>I think they want relief.</p><p>They want help with the annoying parts, the repetitive parts, the scattered parts, the parts that eat focus. They want an agent that can read the repo, understand the task, make a clean attempt, run the obvious checks, show the work, and stop short of pretending it deserves unconditional trust.</p><p>That is why I have stopped judging coding agents by demos.</p><p>The flashy part is easy to notice. Open a file. write some code. run a command. Done.</p><p>The useful part is quieter.</p><p>Approvals that match the task.<br>Sandboxing that limits risk.<br>Clean diffs.<br>Scoped memory.<br>Good repo context.<br>Deterministic guardrails.<br>Human review in the right places.</p><p>That is what makes a coding agent feel real to me.</p><p>Not a bot that can code once. A system I would actually let near a codebase I care about.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b21b65de9000" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[True Random Numbers, Sheldon Cooper, and Why This Actually Matters]]></title>
            <link>https://medium.com/@siddhantg314/true-random-numbers-sheldon-cooper-and-why-this-actually-matters-5014386e8127?source=rss-7a0b7dc45619------2</link>
            <guid isPermaLink="false">https://medium.com/p/5014386e8127</guid>
            <category><![CDATA[the-big-bang-theory]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[Siddhant Gupta]]></dc:creator>
            <pubDate>Mon, 09 Feb 2026 20:36:37 GMT</pubDate>
            <atom:updated>2026-02-09T20:36:37.768Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iz2I7d2AtKFuwCc3soDaPw.jpeg" /><figcaption>Generated using Nano Banana Pro</figcaption></figure><p>So I’m on my fifth rewatch of The Big Bang Theory, there’s this moment in Season 12 (Episode 1, I think) where Amy and Sheldon are bickering about schedules. Sheldon says he’ll generate a pseudorandom schedule. Amy claps back with something like, “The generation of true random numbers remains an unsolved problem in computer science.”</p><p>It’s a great line. Got a laugh out of me. But it also got stuck in my head, because… is that actually true?</p><p>Kind of. But also not really. It depends on what you mean by “true random,” and that distinction is way more interesting than it sounds.</p><h3>Okay, so what do people mean by “true random”?</h3><p>In my experience, when someone says “true random,” they’re usually thinking one of two things:</p><ol><li>Randomness that software creates entirely on its own, from scratch.</li><li>Randomness that comes from something physical and messy, noise, quantum weirdness, thermal jitter, that sort of thing.</li></ol><p>These are <em>very</em> different conversations.</p><h3>Why software can’t just… be random</h3><p>Here’s the thing. A regular computer program is deterministic. You give it the same inputs, same starting state, and it spits out the same outputs. Every time. That’s kind of the whole point of computers.</p><p>So if I write a function that outputs “random” numbers, it’s not actually random. It’s just a rule that produces a sequence. A very convincing sequence, sure, but a sequence that’s fully determined by whatever seed I started with.</p><p>That’s a pseudorandom number generator. And honestly? For most things, it’s totally fine. Games, simulations, shuffling a playlist, PRNG handles all of that without breaking a sweat.</p><h3>The three flavors of random (as I think about them)</h3><p><strong>PRNG</strong> — Your standard deterministic generator. Looks random, isn’t really. Works great for anything that doesn’t need to be secure. If you know the seed, you know everything.</p><p><strong>CSPRNG</strong> — The cryptographically secure version. Still deterministic under the hood, but designed so that even if you know the algorithm, you can’t predict the output without knowing the internal state. This is what your OS reaches for when it needs to generate keys or tokens.</p><p><strong>TRNG</strong> — True random number generator, in the hardware sense. It samples some physical process that’s genuinely hard to predict, then turns that into bits.</p><p>That last one is the key. When people in computing say “true randomness,” they almost always mean “entropy harvested from physics.”</p><h3>Where this actually matters</h3><p>Security. That’s the big one.</p><p>Every time your device generates a private key, it needs unpredictable bits. Every session token, every nonce, every salt, all of it depends on randomness being, well, actually random.</p><p>And when it’s not? Things get bad quietly. That’s the scary part.</p><p>There was a pretty infamous case with Debian’s OpenSSL package where a Debian-specific change accidentally made the random number generator predictable. Debian’s own advisory called it a “predictable random number generator.” The result was that key material, the stuff protecting encrypted connections, could potentially be guessed.</p><p>Nobody noticed right away. That’s the nightmare scenario with randomness. When it breaks, it doesn’t throw an error. It just… keeps going, looking perfectly fine, while everything it protects becomes paper-thin.</p><h3>How this works in practice (it’s a hybrid)</h3><p>Real systems don’t just pick one approach and call it a day. They layer things.</p><p>The general idea is: collect entropy from the environment and hardware, feed it into a cryptographic generator, and let that generator serve random bytes to whatever software needs them.</p><p>Linux does this pretty well. /dev/urandom gives you bytes from a pseudorandom generator that&#39;s seeded from an entropy pool. Reads don&#39;t block. It just works.</p><p>So what’s actually happening when you read random bytes isn’t “pure true randomness every single time.” It’s more like:</p><ul><li>Gather real-world noise over time (interrupts, disk timing, whatever)</li><li>Mix it into an internal pool</li><li>Use that pool to seed and periodically refresh a strong generator</li><li>Serve random bytes fast when software asks</li></ul><p>This hybrid approach is why you can generate cryptographic keys quickly, even though physical randomness is slow and messy. Pretty elegant, honestly.</p><h3>What counts as an entropy source</h3><p>This is where it gets practical.</p><p>Entropy sources are things like electrical noise, oscillator jitter, timing variations between clock cycles, thermal noise , and sometimes dedicated hardware blocks on the chip that are specifically designed to measure something unpredictable.</p><p>Not all sources are equal, though. Some are better than others. Some are easier to tamper with. Some fail in weird edge cases (like a freshly booted VM with no hardware entropy available, that’s a real headache).</p><p>This is also why standards like NIST SP 800–90B exist. They lay out design principles for entropy sources and describe how to validate that your source is actually producing the randomness you think it is. It’s less about solving randomness philosophically and more about treating it as an engineering system that can and will break if you’re not careful.</p><h3>The lava lamp thing (yes, it’s real)</h3><p>If you’ve ever heard someone mention “lava lamps for encryption,” that’s not a joke. Cloudflare actually built a setup where a camera watches a wall of lava lamps, and the chaotic pixel changes get processed as an additional entropy source for their randomness pipeline.</p><p>I love this example for two reasons. First, it makes the whole concept tangible, real-world messiness being turned into bits. Second, it shows the right engineering mindset. They don’t rely on it as their <em>only</em> source. It’s a backup, an extra layer. Defense in depth, even for randomness.</p><h3>So… is the problem solved or not?</h3><p>If the question is “can software alone generate true randomness on a deterministic machine?”, no. That’s mathematically off the table.</p><p>If the question is “can we get high-quality randomness in practice?” yeah, we can. But it’s never a set-it-and-forget-it thing.</p><p>The honest answer looks something like this:</p><ul><li>We can measure physical processes that are genuinely hard to predict</li><li>We can build TRNGs around those measurements</li><li>We can continuously test them and mix them with cryptographic generators</li><li>We still have to assume that any of this can fail, and design accordingly</li></ul><p>The engineering details matter way more than the philosophy here.</p><h3>What Amy got right (and what the joke misses)</h3><p>Her line works as comedy because it sounds deep and absolute. And the core idea is legit, you really can’t just write an algorithm and conjure true randomness out of thin air.</p><p>But what the joke glosses over is that we <em>do</em> have ways to harvest real entropy from the physical world, and modern operating systems already do a ton of work to turn that entropy into something safe, fast, and usable.</p><p>If I had to rephrase it, I’d say something like: true randomness isn’t something you can guarantee from software alone, but you can absolutely build systems that pull entropy from the real world and produce numbers that are unpredictable enough for whatever you’re doing.</p><p>And honestly? That’s usually what you actually need.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5014386e8127" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Defeating nondeterminism in LLM inference, in practice]]></title>
            <link>https://medium.com/@siddhantg314/defeating-nondeterminism-in-llm-inference-in-practice-38a7dd1e4112?source=rss-7a0b7dc45619------2</link>
            <guid isPermaLink="false">https://medium.com/p/38a7dd1e4112</guid>
            <category><![CDATA[nondeterminism]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[inference]]></category>
            <category><![CDATA[thinking-machines-lab]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Siddhant Gupta]]></dc:creator>
            <pubDate>Fri, 19 Sep 2025 18:54:57 GMT</pubDate>
            <atom:updated>2025-09-19T18:54:57.741Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sHwFlnXuU9V-F7GJbSCMtQ.png" /></figure><p>I wanted temperature 0 to mean one thing, the same output every time. It did not. The Thinking Machines Lab post by Horace He explains why, and more importantly, shows a path to make inference deterministic without turning off GPUs or giving up speed entirely. Here is my take, plus a hands on checklist I can apply today.</p><h3>What I mean by deterministic</h3><p>I care about three levels.</p><ol><li>Run to run. Same code, same inputs, same machine, same outputs.</li><li>Request to request on a server. Same prompt and params, same output, regardless of what else the server is doing.</li><li>Version and hardware are stable. Same outputs across software versions and different GPUs.</li></ol><p>Most people only get part 1 right, and even that fails under real load. Part 2 is the crux for serving. The Thinking Machines Lab post argues that many LLM servers are not deterministic from a user’s point of view because outputs change with batch size, which changes with traffic. That is the key idea.</p><h3>The usual story, and what it misses</h3><p>People often say GPUs run many threads, floating point math is not associative, so small numeric changes snowball into different tokens. That story is not fully wrong, but it points at the wrong layer for inference. In a typical LLM forward pass we do not rely on atomic adds in the hot path, so the individual kernels you care about are run to run deterministic for a fixed shape and schedule. The nondeterminism leaks in because the server groups requests into different batches over time, and several kernels are not batch invariant. Change the batch, change the math path, change the result.</p><p>Thinking Machines Lab shows a simple PyTorch demo where a matrix vector multiply gives a different value than slicing out the first row from a matrix matrix result. Same data, different batch framing, different numerics. That is batch non invariance in action.</p><h3>The real fix, batch invariant kernels</h3><p>Make the kernels produce the same per example result no matter how many other examples run beside it. Thinking Machines Lab breaks it down to three ops that matter in transformers.</p><ul><li>RMSNorm</li><li>Matmul</li><li>Attention</li></ul><p>Pointwise ops are fine. The work is in reductions and how they get parallelized. The recipe is simple to state.</p><ul><li>Keep each reduction inside one core when possible.</li><li>Avoid split reductions that change accumulation order based on batch size.</li><li>Use a single kernel configuration even when that leaves some FLOPs on the table.</li><li>For attention, make the reduction order match between prefill and decode, and between KV cache and new tokens. That means unifying how you touch KV data and using a fixed split size for FlashDecode, not a variable number of splits.</li></ul><p>Thinking Machines Lab ships a proof of concept using PyTorch FlexAttention and a small library of batch invariant ops. They plug it into vLLM and, with these kernels, get identical completions at temperature 0 under load. Without it, you see many unique completions even with greedy decoding.</p><h3>Why temperature 0 and a seed are not enough</h3><p>Docs and issues across vLLM and SGLang show that temperature 0 and a fixed seed help, but do not guarantee identical outputs once batching and scheduling vary. In vLLM, the recommended flags and seeds improve things, but users still report drift when concurrency changes. SGLang has similar reports for temp 0. This matches the batch size story.</p><p>PyTorch also warns that full reproducibility is not guaranteed across versions or hardware, even with deterministic algorithms turned on. So if I need the exact same answers across boxes, I must control software stacks and often raise precision.</p><p>A recent study on precision shows BF16 is touchy for greedy decoding. If I need rock solid runs for evals, FP32 helps. That said, their approach focuses on invariance to batching, which I still need even at FP32.</p><h3>What I can do today</h3><p>Here is a practical checklist that works with common stacks.</p><h4>1. Lock sampling to greedy</h4><ul><li>Use temperature 0, top_p 1, and top_k 1 or -1 depending on the server.</li><li>Disable penalties and randomness knobs.</li><li>Set a seed per process or per request if the server supports it. Primary goal is to keep the RNG state from leaking across requests. vLLM documents seeds and has flags to control scheduling.</li></ul><h4>2. Reduce scheduler noise in vLLM</h4><ul><li>Prefer single worker per GPU.</li><li>In V1, turn off multiprocessing to stabilize scheduling.</li><li>Pin the global seed and the SamplingParams seed.</li></ul><p>Example from vLLM docs.</p><pre>import os<br>os.environ[&quot;VLLM_ENABLE_V1_MULTIPROCESSING&quot;] = &quot;0&quot;  # V1 only<br># also pass --seed 0 or set seed in SamplingParams</pre><p>This helps, but it does not solve batch non invariance by itself.</p><h4>3. Use batch invariant ops</h4><p>They published a small library using torch. Library to swap in batch invariant implementations for RMSNorm, matmul, and attention, and a vLLM demo that makes responses identical under load. This is the core step to fix request level nondeterminism.</p><h4>4. Accept a modest speed hit</h4><p>Thinking Machines Lab’s measurements show their unoptimized deterministic path roughly doubles time on a single GPU for Qwen 3 8B, and an improved attention kernel reduces the extra cost. Given the stability win, this trade can be fine for eval, A/B tests, or sensitive prod paths.</p><h4>5. Control versions and precision</h4><ul><li>Pin CUDA, PyTorch, and inference engine versions.</li><li>Consider FP32 for critical eval when you need the strongest stability across systems.</li><li>Keep tokenizers fixed and in sync between offline and online.</li></ul><p>PyTorch notes no promise of reproducibility across versions or across CPU and GPU even with deterministic flags. Precision choice matters.</p><h4>6. Watch attention kernels</h4><p>FlashAttention variants and FlexAttention differ in algorithmic details, backends, and masks. If your server mixes kernels based on shape or batch, numerics can change. Their post calls out how handling KV cache separately breaks invariance. Use one consistent attention path and unify KV reduction order.</p><h4>7. Plan for multi GPU details</h4><p>Multi GPU collectives are another place people worry about determinism. Thinking Machines Lab notes NVLink SHARP in switch reductions are deterministic on Hopper and Blackwell with CUDA 12.8 or newer. If you rely on cross GPU reductions, confirm your NCCL and CUDA versions match that path. NVIDIA’s Blackwell and CUDA 12.8 notes are good context while you verify.</p><h3>A short mental model</h3><ul><li>Floating point is order sensitive.</li><li>Most forward pass kernels are deterministic for a fixed shape and schedule.</li><li>The server changes shapes and schedules as load changes.</li><li>If a kernel’s numerics depend on batch size or chunking, outputs shift with traffic.</li><li>Fix the kernels to be batch invariant. Then server load no longer leaks into user visible tokens.</li></ul><h3>Why this matters</h3><ul><li>Fair eval. If a benchmark run picks different tokens across trials due to server load, your reported scores can bounce for the wrong reason.</li><li>On policy RL. If sampling and training use different numerics, you slip into off policy behavior. Thinking Machines Lab shows bitwise identical sampler and trainer make KL zero, and training is stable without importance weighting.</li></ul><h3>A minimal recipe I can copy</h3><ol><li>Serve with vLLM, single worker per GPU. Lock seeds and disable V1 multiprocessing.</li><li>Install Thinking Machines Lab’s batch invariant ops. Use their FlexAttention path.</li><li>Force one attention backend for both prefill and decode. Keep a fixed split size for decode.</li><li>Keep top_k 1 and top_p 1 with temperature 0.</li><li>Pin framework versions. Use FP32 when stability beats speed.</li><li>Test under high concurrency, not just a local loop.</li></ol><p>Their repo and blog post have working examples and details.</p><p>Thinking Machines Lab’s Repo: <a href="https://github.com/thinking-machines-lab/batch_invariant_ops">https://github.com/thinking-machines-lab/batch_invariant_ops</a></p><pre>He, Horace and Thinking Machines Lab, &quot;Defeating Nondeterminism in LLM Inference&quot;,<br>Thinking Machines Lab: Connectionism, Sep 2025.</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38a7dd1e4112" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GRPO vs GSPO]]></title>
            <link>https://medium.com/@siddhantg314/grpo-vs-gspo-45e8c50ab15b?source=rss-7a0b7dc45619------2</link>
            <guid isPermaLink="false">https://medium.com/p/45e8c50ab15b</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[gspo]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[grpo]]></category>
            <dc:creator><![CDATA[Siddhant Gupta]]></dc:creator>
            <pubDate>Mon, 04 Aug 2025 19:45:32 GMT</pubDate>
            <atom:updated>2025-08-04T19:45:32.421Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sFsZyHuLRTAJGqcBJQOM8A.png" /><figcaption>Image generated using Imagen</figcaption></figure><h3>Introduction</h3><p>Language models have become powerful tools for reasoning, coding and other complex tasks. After pre‑training on large text corpora, these models are often aligned with human preferences using reinforcement learning (RL). In RL fine‑tuning a policy (the language model) is updated to maximise a reward signal that reflects quality or user preference. Most RL algorithms used for language models, like Proximal Policy Optimization (PPO), rely on a separate value network to estimate future rewards. This value network consumes memory and compute, so researchers have been looking for alternatives that scale better with model size.</p><p>Group Relative Policy Optimization (GRPO) appeared as one such alternative. It removes the need for a separate value function and instead compares the quality of responses within a group of samples. More recently, Group Sequence Policy Optimization (GSPO) has emerged as an improvement on GRPO. While GRPO estimates importance ratios at the token level, GSPO shifts the focus to entire sequences. This blog explains how GRPO works, why GSPO was proposed, and what you need to know when choosing between them. Citations come from publicly available sources such as the Qwen team’s blog and technical documentation.</p><h3>Why reinforcement learning matters for language models</h3><p>In supervised fine‑tuning, a model learns from examples of correct answers. However, many tasks require open‑ended responses and subtle judgements that are hard to capture in a single correct label. RL fits naturally in these situations: the model generates responses, a reward model scores them, and the policy updates itself to produce better responses in the future. A family of policy optimisation algorithms, including PPO, DPO, ORPO and GRPO, has been developed to make this process stable.</p><p>Policy optimisation algorithms maintain two policies: the old policy that generated the current batch and the new policy that will be updated. They also use an <strong>importance ratio</strong>, the ratio of the new policy’s probability of producing a response to the old policy’s probability. This ratio is multiplied by an advantage value (how much a response is better or worse than a baseline) and then clipped to prevent large updates. The challenge is to compute the importance ratio and advantage in a way that leads to stable and efficient learning.</p><h3>What is GRPO?</h3><h3>Core idea</h3><p>Group Relative Policy Optimization is designed to train large language models without an additional value network. Instead of relying on a separate network to estimate future rewards, GRPO generates several candidate responses for each prompt and scores them with a reward model. The average score across the group is used as a baseline, and each response’s <em>advantage</em> is the difference between its reward and this group average. The policy then updates itself to favour responses with higher advantages while staying close to the previous policy. Because the group average plays the role of a baseline, the algorithm reduces variance and saves memory.</p><h3>Training steps</h3><p>In practice, GRPO proceeds through the following steps:</p><ul><li><strong>Sample multiple responses.</strong> For each prompt, the current policy produces several possible answers.</li><li><strong>Score responses.</strong> A reward model assigns a numeric score to each answer (for example, awarding higher scores for correct mathematical derivations).</li><li><strong>Compute the average reward.</strong> The average score across all answers for a prompt becomes the baseline for that prompt.</li><li><strong>Calculate advantages.</strong> The advantage of each response is its score minus the average. Responses above the average have positive advantages, and those below have negative advantages.</li><li><strong>Update the policy.</strong> The policy multiplies the importance ratio at each token with the advantage and then applies a clipping procedure similar to PPO. A regularisation term, often a Kullback–Leibler (KL) divergence penalty, prevents the new policy from drifting too far from the old one.</li></ul><p>This process eliminates the value network but still provides a direction for improvement. The memory savings make GRPO attractive for large models and tasks requiring many samples.</p><h3>Strengths</h3><ul><li><strong>Memory efficiency.</strong> By removing the separate value network, GRPO reduces the memory footprint of RL fine‑tuning.</li><li><strong>Group baseline reduces variance.</strong> Using the group’s average reward as a baseline helps stabilise updates and improves performance, as seen in models like DeepSeek R1 for math and coding tasks.</li><li><strong>Simple implementation.</strong> GRPO’s steps mirror PPO but omit the value network, making it easier to implement on existing training pipelines.</li></ul><h3>Limitations</h3><p>Despite its advantages, GRPO has practical issues:</p><ul><li><strong>Token‑level importance ratios.</strong> The importance ratio is computed at each token. This means that the ratio is a product of per‑token probabilities over the entire sequence. Token‑level sampling happens only once per token and can introduce high‑variance noise. The resulting noise destabilises gradient estimates and may cause training collapse over long runs.</li><li><strong>Instability in Mixture‑of‑Experts models.</strong> When GRPO is used on Mixture‑of‑Experts (MoE) architectures, expert activation patterns can fluctuate. Training with GRPO often fails to converge without extra strategies like <strong>routing replay</strong>, which reuses past routing decisions to compute importance ratios. Routing replay adds memory and communication overhead and limits the model’s capacity.</li><li><strong>Sensitivity to precision.</strong> Because token‑level ratios amplify small differences across long sequences, GRPO is sensitive to numerical precision. This sensitivity can complicate infrastructure choices and may require recomputations on different hardware.</li></ul><p>These limitations motivated the development of GSPO, which addresses GRPO’s weaknesses by changing the unit of optimisation from tokens to sequences.</p><h3>How GSPO differs from GRPO</h3><h3>Sequence‑level importance ratios</h3><p>In GRPO, the importance ratio is computed at the token level. However, the Qwen team observed that this approach produces high‑variance noise, making it ineffective for proper distribution corrections. Tokens are sampled only once, so the importance ratio can fluctuate widely across a sequence. Moreover, rewards are typically assigned at the sequence level (for the entire response), so aligning the unit of optimisation with the unit of reward makes more sense.</p><p>GSPO shifts the importance ratio computation from tokens to entire sequences. Instead of multiplying per‑token probabilities, it computes the ratio based on the likelihood of the whole generated sequence. It then applies clipping, reward weighting, and optimisation at the sequence level. This design results in several benefits:</p><ul><li><strong>Higher training efficiency.</strong> GSPO achieves higher training efficiency than GRPO. Experiments on a cold‑start model showed that GSPO attained better performance under the same training cost. Increasing compute, refreshing the query set, and extending sequence length yielded continuous performance improvements.</li><li><strong>Stable training.</strong> Sequence‑level ratios smooth out noise and remove the volatility inherent in token‑level products. GSPO resolves the instability issues seen in GRPO and prevents model collapse during long training sessions.</li><li><strong>Infrastructure friendliness.</strong> Because GSPO uses the likelihood of entire sequences, it is less sensitive to minor precision discrepancies. It can directly use likelihoods computed by inference engines for optimisation without recomputing them on training hardware.</li><li><strong>No routing replay.</strong> GRPO requires routing replay for MoE models. GSPO’s sequence‑level design makes routing replay unnecessary, simplifying the training pipeline and freeing memory for larger model capacity.</li></ul><h3>Clipped token fractions</h3><p>One interesting observation in the Qwen experiments is that GSPO clips a higher fraction of tokens than GRPO, two orders of magnitude more. Despite this aggressive clipping, GSPO still delivers higher training efficiency, highlighting the inefficiency of token‑level updates. The sequence‑level approach provides a stronger learning signal even when more clipping occurs.</p><h3>Performance and empirical results</h3><p>The Qwen team evaluated GSPO and GRPO on multiple benchmarks, including AIME’24 (a math competition), LiveCodeBench, and CodeForces. Using a cold‑start model fine‑tuned from Qwen3‑30B‑A3B‑Base, they compared reward curves and performance metrics. Key findings include:</p><ul><li><strong>GSPO outperforms GRPO under equal compute.</strong> For the same training budget, GSPO achieved higher rewards and better benchmark scores.</li><li><strong>Scalability with more compute.</strong> When training compute was increased and the query set refreshed, GSPO continued to improve, showing no signs of plateauing. GRPO, on the other hand, often plateaued or even collapsed at longer training horizons.</li><li><strong>Reduced need for routing replay.</strong> In MoE models, GRPO required routing replay to achieve convergence. GSPO removed this dependency, making training more straightforward and less resource‑intensive.</li></ul><p>These empirical results suggest that GSPO is a more reliable choice for large models and long training runs, particularly when working with MoE architectures or limited infrastructure.</p><h3>Practical considerations</h3><h3>When to use GRPO</h3><ul><li><strong>Resource‑constrained environments.</strong> If memory is extremely limited and training runs are short, GRPO still offers an advantage over PPO because it does not require a value network. For small models or quick experiments, token‑level variance may not severely affect stability.</li><li><strong>Familiarity and existing tooling.</strong> GRPO has been implemented in several open‑source frameworks and integrated into training tools. If your current pipeline already uses GRPO and you are training on relatively simple tasks, it may remain sufficient.</li></ul><h3>When to choose GSPO</h3><ul><li><strong>Long training runs.</strong> Sequence‑level optimisation avoids the cumulative noise that arises from token‑level ratios. For projects requiring many RL steps or large query sets, GSPO is more stable and produces consistent improvements.</li><li><strong>Mixture‑of‑Experts models.</strong> MoE architectures are sensitive to routing patterns. GSPO’s design eliminates the need for routing replay and thus removes a significant source of overhead.</li><li><strong>Infrastructure simplicity.</strong> Because GSPO can use sequence likelihoods directly from inference engines, it reduces the need to recompute log probabilities on training devices. This can simplify the training‑inference pipeline and make RL fine‑tuning easier to scale across heterogeneous hardware.</li></ul><h3>Broader context and future directions</h3><p>The development of GRPO and GSPO reflects a wider trend in RL for language models: aligning the optimisation objective with the nature of the reward. Since reward models typically assess complete responses, it makes sense to operate at the sequence level. Token‑level methods may still have niche applications, but the trajectory of research points toward sequence‑level or even sub‑sequence‑level approaches. Some researchers have proposed subsequence‑level clipping methods to balance the granularity between tokens and full sequences, suggesting that GSPO is not the end of the road but a step along the path.</p><p>As models grow and tasks become more complex, the demands on RL algorithms will increase. Future work may explore adaptive clipping schemes, better variance reduction techniques, and algorithms that combine the strengths of GRPO and GSPO. For now, GSPO stands out as a practical and robust choice for training large language models with reinforcement learning.</p><h3>Key points :</h3><ul><li><strong>GRPO</strong> uses group averages to estimate advantages and computes importance ratios at the token level. It is memory‑efficient but suffers from high variance and instability, especially on long sequences and MoE models.</li><li><strong>GSPO</strong> introduces sequence‑level importance ratios and clipping. This change yields higher training efficiency, greater stability, and better scalability.</li><li><strong>Empirical results</strong> show that GSPO outperforms GRPO under equal compute and continues to improve with more compute, while GRPO can collapse during long training runs.</li><li><strong>Infrastructure benefits</strong> include the removal of routing replay for MoE models and better tolerance to numerical precision, making GSPO more infrastructure‑friendly.</li></ul><p>Understanding the trade‑offs between GRPO and GSPO helps practitioners make informed choices when fine‑tuning language models with reinforcement learning. For most large‑scale applications, GSPO is likely to be the better default due to its stability and efficiency, while GRPO may still be useful in constrained settings where memory savings outweigh the risks of instability.</p><h3>References:</h3><ol><li><a href="https://arxiv.org/pdf/2402.03300">https://arxiv.org/pdf/2402.03300</a></li><li><a href="https://arxiv.org/pdf/2507.18071">https://arxiv.org/pdf/2507.18071</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45e8c50ab15b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RAG that Actually Runs in Production]]></title>
            <link>https://medium.com/@siddhantg314/rag-that-actually-runs-in-production-87cea955ec3e?source=rss-7a0b7dc45619------2</link>
            <guid isPermaLink="false">https://medium.com/p/87cea955ec3e</guid>
            <category><![CDATA[evaluation]]></category>
            <category><![CDATA[retrieval-augmented-gen]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Siddhant Gupta]]></dc:creator>
            <pubDate>Wed, 04 Jun 2025 19:43:54 GMT</pubDate>
            <atom:updated>2025-06-04T19:43:54.181Z</atom:updated>
            <content:encoded><![CDATA[<p>Most teams can stitch together a Retrieval-Augmented Generation demo in a weekend. The problems start when users hit the system at scale. Latency creeps up, recall drops, hallucinations show up, and safety reviews stall the rollout. I’ll walk through a production-ready pattern that fixes those pain points. You’ll see a full pipeline, guardrail-LLMs, real-world evaluation loops, and a checklist you can copy into your own project.</p><h3>1. Anatomy of a Production RAG</h3><p>First, here’s the big picture in plain English.<br>The retriever finds candidate passages, a reranker sorts them, the language model writes an answer citing the passages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*i0EVzTozn4khcB1Wy4khYg.png" /></figure><p>Hybrid retriever mixes dense vector search with BM25 keyword search. Dense search handles semantics, BM25 rescues rare, exact terms.</p><h3>2. Data flow that doesn’t clog</h3><h4>2.1 Chunking</h4><p>A <em>chunk</em> is a slice of text stored in the index. Start at 512 tokens with twenty-percent overlap. Shorter chunks raise recall but cost more to index, longer chunks lower costs yet risk losing context. Benchmarks show 512-token chunks keep latency under fifty milliseconds at ten million vectors.</p><h4>2.2 Embeddings</h4><p>An <em>embedding</em> turns a chunk into a high-dimensional vector. Cheap models cost about $0.0001 per thousand tokens, premium multilingual models four times that. Two million chunks at 800 tokens run $160–$640 up front — plan for it.</p><h4>2.3 Index refresh</h4><p>Nightly batch jobs keep static docs fresh. When data changes often, a streaming pipeline can push new rows through an embedding service and straight into the vector store in seconds.</p><h3>3. Retrieval that scales</h3><p>Dense search finds semantic matches, BM25 rescues rare exact terms, then a lightweight cross-encoder reranker scores the top fifty and keeps five. Target numbers:</p><ul><li>Vector search, ninety-fifth percentile latency &lt; 50 ms</li><li>Reranker &lt; 20 ms</li><li>Complete answer &lt; 600 ms</li></ul><p>Public latency studies back those thresholds at a ten-million-vector scale.</p><h3>4. Guardrails: keep it safe</h3><p>Guardrails are filters that inspect prompts going in and answers coming out. They catch disallowed content or structural errors.</p><ul><li><strong>Llama Guard</strong> uses a safety taxonomy to tag risky text, run it locally in four lines of Python.</li><li><strong>Guardrails YAML policies</strong> validate structure or profanity without touching your main model code.</li><li><strong>Programmable guardrail frameworks</strong> let you write custom policies in a domain-specific language.</li></ul><h4>How to wire a guardrail-</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JavH6H5Z4YTvTfAEJ2xLyQ.png" /></figure><p>If either check fails, return a refusal or rewrite the answer. Always log the trace ID, stripped of personal data, so you can audit later.</p><h3>5. Evaluation that lasts</h3><h4>5.1 Offline retrieval scores</h4><ul><li><strong>Recall@5</strong>, was the right doc in the top five?</li><li><strong>MRR</strong>, average first-hit rank.</li><li><strong>nDCG</strong>, rewards correct ordering.</li></ul><p>Generate 200–500 labeled questions, then run Ragas to compute all three in one call.</p><h4>5.2 Model-based checks</h4><p>Ragas and TruLens let a judge-model grade real traces. They return <strong>faithfulness</strong> (answer grounded in sources) and <strong>answer relevancy</strong> scores without human labels.</p><h4>5.3 Synthetic Q&amp;A</h4><p>Create a question, ask a stronger model for a ground-truth answer, let your RAG system answer, then judge the result. OpenAI Evals automates that loop.</p><h4>5.4 Online signals</h4><ul><li>Time to first token &lt; 300 ms.</li><li>User rephrase rate, track how often people ask again in thirty seconds.</li><li>Cost per thousand requests, alert if it jumps twenty-five percent.</li></ul><h4>5.5 Continuous loop</h4><p>A tracing tool can stream production traces into nightly Ragas runs and fire a Slack alert when faithfulness dips below ninety percent.</p><h3>6. Observability</h3><p>Dashboards matter. Monitor:</p><ul><li>Vector search latency</li><li>Reranker latency</li><li>Token usage</li><li>Guardrail rejects</li><li>Embed job failures</li></ul><p>Example stacks wire tracing into Grafana so data ops can spot spikes early.</p><h3>7. Deployment checklist</h3><ul><li>Recall@5 ≥ 0.8 on the dev set</li><li>Faithfulness ≥ 0.9 by model-based eval</li><li>p95 latency &lt; 800 ms end-to-end</li><li>Cost per thousand queries &lt; $0.40</li><li>Logs kept thirty days, redacted, rollback tested</li></ul><p>Copy, paste, tweak to fit your constraints.</p><h3>8. Common traps</h3><p>Teams often slice text into tiny 100-token chunks, then choke on vector-store bills. Others embed once, never refresh, and watch the model cite stale policy PDFs. Some skip the reranker to save twenty milliseconds, then wonder why answers cite footnotes. Test at scale, rerank, refresh, guard, and you’ll avoid those headaches.</p><h3>Wrap-up</h3><p>Strong RAG isn’t magic. It’s solid plumbing, steady evaluation, and clear safety gates. Follow the steps here, keep an eye on the numbers, and your system stays fast, accurate, and safe long after launch.</p><h3>Sources-</h3><ol><li>Llama Guard safety model, <a href="https://arxiv.org/abs/2312.06674?utm_source=chatgpt.com">arxiv.org</a></li><li>Guardrails YAML policy, <a href="https://www.guardrailsai.com/blog/guardrails-litellm-validate-llm-output?utm_source=chatgpt.com">guardrailsai.com</a></li><li>NeMo Guardrails, <a href="https://docs.nvidia.com/nemo-guardrails/index.html?utm_source=chatgpt.com">docs.nvidia.com</a></li><li>Ragas metric guide, <a href="https://docs.ragas.io/en/v0.1.21/concepts/metrics/?utm_source=chatgpt.com">docs.ragas.io</a></li><li>Vector search metrics, <a href="https://milvus.io/ai-quick-reference/how-do-i-evaluate-vector-search-performance?utm_source=chatgpt.com">milvus.io</a></li><li>Real-time embedding stream, <a href="https://www.striim.com/blog/real-time-rag-streaming-vector-embeddings-and-low-latency-ai-search/?utm_source=chatgpt.com">striim.com</a></li><li>Chunk size study, <a href="https://www.llamaindex.ai/blog/evaluating-the-ideal-chunk-size-for-a-rag-system-using-llamaindex-6207e5d3fec5?utm_source=chatgpt.com">llamaindex.ai</a></li><li>Langfuse–Ragas integration guide, <a href="https://langfuse.com/guides/cookbook/evaluation_of_rag_with_ragas?utm_source=chatgpt.com">langfuse.com</a></li><li>Langfuse evaluation docs, <a href="https://docs.ragas.io/en/v0.1.21/howtos/integrations/langfuse.html?utm_source=chatgpt.com">docs.ragas.io</a></li><li>Open-source RAG observability note, <a href="https://www.llamaindex.ai/blog/one-click-open-source-rag-observability-with-langfuse?utm_source=chatgpt.com">llamaindex.ai</a></li></ol><p>No single vendor drives this pattern. They’re just examples you can swap for whatever tools you prefer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87cea955ec3e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reinforcement Learning: A Friendly Take, Inspired by DeepSeek R1]]></title>
            <link>https://medium.com/@siddhantg314/reinforcement-learning-a-friendly-take-inspired-by-deepseek-r1-3e9ea78d5aa5?source=rss-7a0b7dc45619------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e9ea78d5aa5</guid>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[deepseek]]></category>
            <category><![CDATA[reinforcement-learning]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Siddhant Gupta]]></dc:creator>
            <pubDate>Mon, 03 Feb 2025 22:55:01 GMT</pubDate>
            <atom:updated>2025-02-03T22:55:01.705Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Reinforcement Learning" src="https://cdn-images-1.medium.com/max/1024/1*Y_Tpih2s4eyPXnO25l4S4g.jpeg" /></figure><p>I’ve been following AI projects for a while, and one thing that always stood out was how many large language models are trained like they’re cramming for a final exam — memorize the “right” answer, then spit it back. That might work in certain cases, but it can also lead to static, limited behavior once training is done. A newer approach, sometimes used by models like DeepSeek R1, takes a different route: it learns through exploration and trial, similar to how we learn from everyday experiences. That’s reinforcement learning in a nutshell, and I’m going to share what it is, why it matters, and how DeepSeek R1 shows it in action.</p><h3>Training by Experimenting</h3><p>Reinforcement learning hinges on the idea that a model (or an agent, if you prefer) is rewarded for doing something correctly and nudged away from less-effective choices. Picture teaching a puppy to sit: you offer a treat whenever it stays put, so it eventually understands that sitting on command gets it a reward.</p><p>DeepSeek R1 tries a similar style of self-improvement. Instead of only depending on a giant labeled dataset, it also refines its reasoning by comparing new attempts to older ones. If the model figures out a better way to arrive at the right answer, it “tells itself,” “Hey, that worked better. I’ll do that next time.” This process unfolds over many rounds of trial and update, and the end result is a system that keeps polishing its own abilities.</p><h3>Step-by-Step Reasoning</h3><p>DeepSeek R1 doesn’t just guess a final answer. It often goes through a chain of steps — some folks call it “thinking out loud.” That means it lists each step of its logic, which helps with:</p><ol><li><strong>Spotting Errors:</strong> If there’s a goof in step three, you can catch it early instead of ending up with a total mismatch at the end.</li><li><strong>Seeing Improvements:</strong> The model can look back and say, “That part was off. Let’s do it differently next time.”</li></ol><p>I’ve found it reassuring to see each stage in the model’s thought process. It feels less like a black box when you can watch how it connects the dots.</p><h3>Beyond One-Size-Fits-All</h3><p>Big models are powerful but can be unwieldy. DeepSeek R1 showed that you can train a large model with reinforcement learning, then compress (or distill) it into smaller versions that keep much of the original’s smarts. It’s a bit like having an expert tutor break down a topic into digestible chunks for a group of students. The tutor is the full model, and those students are the smaller ones. Sometimes the apprentice even picks up new ways of explaining things that make it look surprisingly good. That means you get high-level performance without breaking the bank on hardware.</p><h3>Why It’s a Step Forward</h3><p>Here’s what I find appealing about this approach:</p><ul><li><strong>Adaptability:</strong> A reinforcement-learning-based model can improve once it’s deployed, if you set it up that way. Traditional models often stay stuck at their final training state.</li><li><strong>Clarity:</strong> The chain-of-thought technique helps us see a breakdown of its ideas. That alone can make it easier to check for flaws.</li><li><strong>Scaled-Down Versions:</strong> By distilling the giant model into more compact ones, more people have access, not just well-funded labs with unlimited GPUs.</li></ul><p>These factors, taken together, make me think that reinforcement learning will probably stick around in the world of AI for a long time.</p><h3>Where to Go from Here</h3><p>If you’re curious about trying reinforcement learning in your own projects, you don’t necessarily need the biggest cluster of machines. There are plenty of open-source libraries and frameworks that let you experiment with reward-based training. You can create a simple game environment, for instance, and let your model figure out how to navigate it. Once it understands the basics of collecting “rewards,” you can scale up to more complex tasks.</p><h3>A Final Thought</h3><p>I see DeepSeek R1 as proof that you can combine a more experimental mindset with step-by-step logic — and then trim the final result so it’s easier to use. That’s the heart of why I think reinforcement learning is popping up in more AI conversations. We’re shifting from “Here’s a pile of correct answers, memorize them” to “Try this, see if it works, keep the good stuff.” If you haven’t taken a look at reinforcement learning, there’s a lot you can pick up from models like DeepSeek R1 — both the code that’s out there and the broader training strategies. It’s a reminder that maybe letting a system learn from its own mistakes can produce better results than we’d get from static training alone.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e9ea78d5aa5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RAG 101]]></title>
            <link>https://medium.com/@siddhantg314/rag-101-3466de8d2ab8?source=rss-7a0b7dc45619------2</link>
            <guid isPermaLink="false">https://medium.com/p/3466de8d2ab8</guid>
            <category><![CDATA[vector-database]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[retrieval-augmented-gen]]></category>
            <dc:creator><![CDATA[Siddhant Gupta]]></dc:creator>
            <pubDate>Wed, 15 Jan 2025 19:40:10 GMT</pubDate>
            <atom:updated>2025-01-15T19:40:10.854Z</atom:updated>
            <content:encoded><![CDATA[<p>Retrieval-Augmented Generation, or RAG, is a way to make large language models (LLMs) more reliable and up-to-date by giving them access to external data. It’s helpful for anyone who has wondered why an AI chatbot can sometimes produce strange or outdated answers, especially when asked questions about new or highly specific topics.</p><h3>Why LLMs Need Extra Help</h3><p>Many LLMs (like those behind popular AI chatbots) rely on knowledge from large training datasets. These datasets often can’t capture the newest information, or they might lack the details that a business requires for custom answers. This means the chatbot:</p><ul><li>Might share incorrect or made-up facts (often referred to as “hallucinations”).</li><li>Doesn’t provide the most recent updates about current events, product changes, or recent company policies.</li><li>Lacks references to show where its answers come from, which makes it hard to verify the information.</li></ul><p>RAG is a solution to these issues. With RAG, the model retrieves the latest and most relevant data from a preselected knowledge source before generating a response. This approach helps you keep costs lower than more complex methods like retraining or fine-tuning an entire LLM on your own data.</p><h3>What Makes RAG Different?</h3><ul><li><strong>Access to Fresh Information</strong><br>RAG-powered AI looks up data from a live or frequently updated source. For instance, instead of responding with general or outdated text, it can reference your company’s documents, recent news, or product manuals.</li><li><strong>Enhanced Accuracy</strong><br>Traditional LLMs sometimes fill gaps with invented text. RAG-based systems anchor responses in real documents, so the output is more trustworthy.</li><li><strong>Visibility into Sources</strong><br>RAG gives the option to cite or link to relevant files or database entries. This helps users verify where an answer came from.</li><li><strong>Fewer Expensive Processes</strong><br>RAG doesn’t require you to rebuild or retrain the entire model on your private data. Instead, you store your data in a system the model can call upon as needed.</li></ul><h3>How RAG Works</h3><ol><li><strong>Preparing Your Data</strong><br>You start by gathering the specific information you want your AI to reference (for example, PDFs, policy docs, or the latest product info). Text embeddings convert these materials into numeric representations that machines can understand.</li><li><strong>Creating a Vector Database</strong><br>These numeric representations (embeddings) are stored in a vector database. This database can be rapidly searched for relevant snippets of text, images, or other media.</li><li><strong>Retrieving Relevant Information</strong><br>When a user asks a question (“How do I configure device XYZ?”), that question is turned into a numeric representation, and the database finds content closely matching the question. This step is often called semantic search.</li><li><strong>Augmenting the Prompt</strong><br>The model is given both the user’s question and the retrieved data. Because the model sees the most relevant parts of your private or external library, it can produce a better response.</li><li><strong>Generating a Final Answer</strong><br>The model returns an answer that references the newly provided details. It can also show which document or link was used to form the response.</li></ol><h3>RAG in Real Life</h3><ul><li><strong>Customer Support</strong><br>A user messages a chatbot about a refund policy. Instead of guessing, the chatbot pulls the latest policy from your database. The user receives an accurate answer, and the chatbot can provide a link to the specific policy page.</li><li><strong>Employee Q&amp;A</strong><br>Someone in the company wants to know about health benefits or scheduling time off. With RAG, the chatbot retrieves relevant HR documents, ensuring personalized and correct answers for each employee.</li><li><strong>Research and Analysis</strong><br>If you manage large research libraries or archives, RAG can sift through them. It returns only the most relevant passages, helping subject-matter experts focus on the right data.</li></ul><h3>Comparing Other Methods</h3><ul><li><strong>Fine-Tuning</strong>: Retraining a model on your specific data can be time-consuming and expensive. It’s also hard to keep up when your content changes frequently.</li><li><strong>Prompt Engineering</strong>: Crafting very detailed instructions sometimes helps, but it won’t solve the issue of missing facts or updates.</li><li><strong>Building Your Own LLM</strong>: Training a massive model from scratch is far beyond the scope of most organizations in both time and money.</li></ul><p>RAG, on the other hand, keeps the model “as is” and simply supplies it with extra data on the fly. This approach is generally more practical.</p><h3>What to Remember</h3><ul><li><strong>Your Data</strong>: Decide which documents or databases matter most. If the data is stale or incorrect, it will affect your chatbot’s responses.</li><li><strong>Storage and Indexing</strong>: A reliable vector database is necessary for quick retrieval. Embedding models help the system understand how text from different sources fits together.</li><li><strong>Model Choice</strong>: You can use a foundation model from various providers and plug it into a RAG pipeline. The choice depends on cost, speed, and support for your use case.</li><li><strong>Governance and Quality</strong>: Regularly update your data and watch for inaccuracies. Occasional human reviews can ensure the system maintains a good standard.</li></ul><h3>Final Thoughts</h3><p>RAG helps AI systems move beyond guessing and lean on real data. It’s an approach that blends the creativity of LLMs with factual content from your own data sources. Whether it’s a help desk chatbot that references current policies or an internal system that keeps employees informed, RAG is an easier and more cost-friendly route to strong AI performance.</p><h3>Additional Resources</h3><ul><li>For a more in-depth look at RAG, check out our whitepaper: <a href="https://drive.google.com/file/d/1HhzOs38pVmGrESdR-mfw5be4OcdSx1jG/view">RAG Whitepaper</a>.</li></ul><h3>Connect with Me</h3><p>I’d love to hear your thoughts! Feel free to reach out to me:</p><ul><li><strong>Website</strong>: <a href="https://guptasiddhant.me/">guptasiddhant.me</a></li><li><strong>LinkedIn</strong>: <a href="https://www.linkedin.com/in/siddhantgupta4/">Siddhant Gupta</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3466de8d2ab8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Behind the Scenes: Presenting at the IEEE Cyber Threat Intelligence Workshop]]></title>
            <link>https://medium.com/@siddhantg314/behind-the-scenes-presenting-at-the-ieee-cyber-threat-intelligence-workshop-0b62ea785fe6?source=rss-7a0b7dc45619------2</link>
            <guid isPermaLink="false">https://medium.com/p/0b62ea785fe6</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[conference]]></category>
            <category><![CDATA[academia]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Siddhant Gupta]]></dc:creator>
            <pubDate>Sat, 04 Jan 2025 22:50:25 GMT</pubDate>
            <atom:updated>2025-01-04T22:50:25.914Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*htayvyqRrR9w2tiWF-o8Rw.jpeg" /></figure><p>I just got back from the 7th Annual Workshop on Cyber Threat Intelligence and Hunting at IEEE Big Data 2024 in Washington, DC. It was my first time presenting at this particular workshop, and it felt both rewarding and nerve-racking to share our research on “Living off the Analyst: Harvesting Features from Yara Rules for Malware Detection.” Being able to show how YARA rule sub-signatures can be repurposed for malware classification was an interesting challenge, especially knowing that the audience included folks who write and maintain these types of signatures every day.</p><h3>Preparation and Teamwork</h3><p>Leading up to the conference, my co-authors and I spent a good deal of time revisiting all the details in our manuscript. We double-checked the approach we took — extracting sub-signatures from public YARA rules — and made sure we had fresh insights to share on how these features can offer an extra layer of utility when applied to larger datasets like EMBER 2018. I had regular check-ins with my mentors and co-authors — Fred Lu, Andrew Barlow, Edward Raff, Francis Ferraro, Cynthia Matuszek, Charles Nicholas, and James Holt — who helped me refine our slides, anticipate questions, and structure the main talking points.</p><p>On a personal note, it was a relief to have such a supportive team. I’m lucky to work with mentors who encouraged me to step up and deliver the presentation. They also gave me plenty of feedback on how to handle the Q&amp;A, which turned out to be a big help once I was up on stage.</p><h3>The Presentation Itself</h3><p>I arrived at the workshop venue a bit early to make sure the audiovisual setup was working. My talk centered on the idea that malicious actors sometimes “live off the land” by using benign files and tools that already exist on a system. Our study explored whether anti-virus developers could do something similar — repurposing the knowledge embedded in publicly available YARA rules. One of our key discoveries was the presence of sub-signatures that either appear often across many malware samples or are very particular to certain families. I tried to keep the discussion balanced between technical depth and clarity, so that both experts and newcomers could follow along.</p><p>What surprised me most was the audience’s engagement. They asked about the different ways these sub-signatures could be transferred to other malware detection pipelines, and whether there might be limitations in rule-based approaches once attackers pivot or evolve their code patterns. I appreciated these questions because they pointed out future directions for the work.</p><h3>Lessons Learned</h3><ul><li><strong>Flexible Approaches Matter</strong>: One takeaway was the value of hybrid methods. While we focused on signature-based approaches through YARA, a combination of behavioral and statistical techniques might catch threats that signatures alone miss.</li><li><strong>Know Your Audience</strong>: Before heading to the workshop, I did some research on the types of professionals who typically attend. This helped me tailor the talk to emphasize both the practical aspects (how to incorporate extracted features into antivirus workflows) and the broader research perspective (how these sub-signatures stack up against more conventional features).</li><li><strong>Bring Extra Context</strong>: I included slides on the origins of YARA rules, so the audience could see how certain sub-signatures are written for a narrow purpose while others have multiple uses. That extra context improved the Q&amp;A since listeners could follow the logic behind our approach more closely.</li></ul><h3>Navigating an Academic Conference</h3><p>Conferences can be overwhelming, but they’re a great chance to meet peers who share your interests. I found the workshop atmosphere to be a good mix of research and hands-on practice, which led to solid networking opportunities. A few strategies worked well for me:</p><ol><li><strong>Arrive Early</strong>: Being in the room before the sessions start helps you get comfortable and gives you time to test any technical setup. It also gives you a moment to relax or chat with other early arrivals.</li><li><strong>Plan Your Questions</strong>: If you’re planning to talk to specific authors or if you have targeted questions, jot them down. It’s easy to forget once you’re in the thick of things.</li><li><strong>Follow Up</strong>: You may have short conversations during breaks or poster sessions. If you want to collaborate in the future, grab a business card (or connect on LinkedIn) and follow up soon after the event.</li></ol><h3>Looking Ahead</h3><p>I’m grateful to the University of Maryland Baltimore County, Booz Allen Hamilton, and the Laboratory for Physical Sciences for supporting our collaboration. Presenting our paper showed me fresh ways to refine our approach and think about new research paths. The energy in the room reminded me that the cybersecurity community is filled with folks who are eager to learn from each other. I’m hoping to integrate the feedback we received into the next phase of our work on advanced malware detection.</p><p>Thanks for reading about my experience! I’m already looking forward to what comes next and how we can build on what we shared at the conference. If you’re ever at an academic event, I hope you find the same sense of community and collaboration that I did.</p><p>Read the paper here -&gt; <a href="https://arxiv.org/abs/2411.18516">https://arxiv.org/abs/2411.18516</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0b62ea785fe6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>