<?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 Sivesh Pb on Medium]]></title>
        <description><![CDATA[Stories by Sivesh Pb on Medium]]></description>
        <link>https://medium.com/@sivesh.pb?source=rss-024642ec80d4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*1wQMZveUlItif7mRFNAhVA.jpeg</url>
            <title>Stories by Sivesh Pb on Medium</title>
            <link>https://medium.com/@sivesh.pb?source=rss-024642ec80d4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 15:03:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sivesh.pb/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[Your AI Answer Was a Guess. Here’s Why.]]></title>
            <link>https://medium.com/@sivesh.pb/your-ai-answer-was-a-guess-heres-why-8e4e117796cf?source=rss-024642ec80d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e4e117796cf</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[writing]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Sivesh Pb]]></dc:creator>
            <pubDate>Wed, 28 Oct 2026 06:01:01 GMT</pubDate>
            <atom:updated>2026-10-28T06:01:01.673Z</atom:updated>
            <content:encoded><![CDATA[<h4>Three simple questions that expose hallucinations before they cost you.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZJyaKLHWsWl176XmaPsdEQ.png" /></figure><p>I asked my AI assistant for the name of a book I half remembered. It gave me a title, an author, a year. All of it sounded right. All of it was made up.</p><p>That’s the quiet horror most people haven’t hit yet. The answer didn’t look like a guess. It looked like a librarian had pulled a card from a drawer and handed it over with a polite smile. And that politeness is exactly why you believed it.</p><p>The problem isn’t that AI gets things wrong. It will. The problem is <em>how</em> it gets them wrong: smoothly, in confident prose, with no asterisk, no shrug, no “hmm, maybe.” You get the same calm voice whether it just quoted a fact from training data or just invented one. And until you know which one you’re looking at, you’re flying blind in your own inbox.</p><p><strong>In this post:</strong></p><ul><li>Why the calm tone makes wrong answers look like facts.</li><li>The one detail that turns a guess into proof.</li><li>How to check an answer in under two minutes.</li></ul><h3>The Robot Doesn’t Know It’s Guessing</h3><p>A large language model is, underneath all that friendly text, a prediction engine. You type words in, and it predicts the most likely next word, then the next, then the next. Most of the time “most likely” lands on a real fact it saw during training. But sometimes the next word it picks doesn’t come from any real memory. It comes from a pattern the model noticed: <em>books with titles like this often have authors named…</em> and it fills in the blank.</p><p>Chip Huyen describes this well in her book <em>Designing Machine Learning Systems</em>: models are optimized for likelihood, not truth. Likelihood means “sounds right given what came before.” Truth means “matches reality.” Those are two very different jobs, and the model is only doing the first one.</p><blockquote><em>A machine that predicts well is not a machine that remembers.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*li_gtLpH0lSJVG6RstzFug.png" /></figure><p>And here’s the kicker: the model doesn’t know the difference either. When it invented my book title, its internal math said “I’m about as confident as when I quote something real.” There’s no little light bulb that goes on. No sweat bead on the forehead.</p><p>In my current role, I build the kind of AI that answers support tickets for a team. One day the system confidently told a customer their refund window was fourteen days. The real answer was twenty-eight. Nobody had changed the rules. The model just filled in “fourteen” because it’s a rounder number, a more common phrase, a smoother sentence. We added a rule: every date must come from the ticket metadata, not from the model’s own mouth. Sound like a small thing? It saved us from a very expensive apology email.</p><h3>Three Questions That Save You Ten Minutes</h3><p>You don’t need a PhD to start stress-testing an answer. I keep a mental checklist in my head, and it has saved me from pasting a hallucinated citation into a work document more than once. The questions are simple enough that you can do them while half listening to a podcast.</p><p>Before you trust any AI answer, ask yourself:</p><ul><li><strong>Could I find this myself?</strong> If the answer is something a quick search would confirm (a phone number, a legal deadline, a recipe step), go look. Don’t assume the model beat you to it.</li><li><strong>Does it have specifics?</strong> Real facts come with dates, names, page numbers, URLs. Vague answers (“recent studies suggest,” “in the literature”) are often the model smoothing over gaps. Specifics are harder to invent convincingly.</li><li><strong>What’s the cost if I’m wrong?</strong> A wrong fact in a personal diary? Low stakes. A wrong fact in an email to your boss, a legal draft, a medication schedule? High stakes. Scale your checking effort to the stakes.</li></ul><p>The third question matters most because people treat every AI answer with the same trust, whether it’s captioning a photo or deciding which vitamin to take. It isn’t one machine making one kind of mistake. It’s the same calm voice saying different things at very different reliability levels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sNE5OG7zpIFMCyt9AkP8hw.png" /></figure><p>I used the second question for my career placement assistant during an internship, where I was building AI over thousands of placement records. When the system answered a counsellor’s question about a candidate’s GPA, it gave me the number <em>and</em> the document ID where that number lived. That one extra detail turned “trust me” into “go look.” And honestly, counsellors stopped double-checking every single time after about a week, which I was pretty happy with.</p><h3>The Calm Voice Is the Trap</h3><p>There’s a phrase in Google’s internal engineering culture: <em>the model doesn’t know what it doesn’t know.</em> The same calm tone comes out whether the answer is a solid fact or an elegant fabrication. That tone isn’t a bug. It’s the design. Models are trained to sound fluent, and fluency looks like certainty.</p><p>But certainty is a presentation choice, not a truth signal. When you read “Studies show…” with no citation, or when a model hands you a phone number for a small-town clinic without a source, that calm voice is doing the heavy lifting that should belong to footnotes.</p><blockquote><em>You’re reading a stranger’s handwriting and assuming it came from the official ledger.</em></blockquote><p>A friend of mine, a high school history teacher, started asking her students to treat AI answers like a first draft from a very well-spoken student who might have misremembered. The homework rule: “If you can’t point to where it came from, mark it with a question mark.” Their essays got better because the guessing stopped sneaking in as fact.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*atNMe800IHtbSxjxnQNGeQ.png" /></figure><h3>What I Actually Do Before Hitting Send</h3><p>Here’s my personal routine, unglamorous and short. It takes about ninety seconds and I’ve done it enough times to do it without thinking.</p><ol><li><strong>Read the answer out loud.</strong> Weird as it sounds, saying it aloud makes you notice when something is too smooth. A real fact has bumps in it. Numbers with odd digits, names that aren’t round, dates that aren’t clean. If everything sounds like a headline, slow down.</li><li><strong>Pull one detail and check it.</strong> Not the whole claim. One detail. The year, the author’s first name, the clinic’s street number. Search that. If it checks out, the rest is more likely to be real.</li><li><strong>Ask the model for its source.</strong> “Where did you get that?” Some models will point at training patterns honestly. Others will invent a citation. A made-up citation is still useful: it tells you which part of the answer is shaky, because the shaky part is usually where the fabrication started.</li></ol><p>I built a reply-suggestion tool for a support team in my current role. The biggest lesson from watching real users struggle with it wasn’t about the AI getting things wrong. It was about the support agents not realizing they’d stopped checking. After two weeks of “the AI says this,” nobody was verifying anything. We added a small “source” tag on every suggested reply, and the checking came back. Not because people are lazy. Because calm is more persuasive than a fact sheet.</p><h3>A Small Habit That Changes Everything</h3><p>The single most useful shift I’ve made: I now treat AI answers as <em>drafts</em>, not <em>answers</em>. A draft gets checked, edited, and verified before it goes anywhere real. An answer, by contrast, is something you trust once and move on from.</p><p>It’s a small change. You don’t need to memorize any model architecture. You don’t need to know what an LLM is, or what vector search means, or why the answer came back in the tone it did. You just have to stop letting the calm voice do its job for you, which is to make you skip the check.</p><p>The robot doesn’t know it’s guessing. That’s the whole problem. So you have to be the one who asks.</p><blockquote><em>Calm is not proof. The check is the proof.</em></blockquote><p>What’s the one AI answer you’ve trusted that turned out to be wrong? Drop it in the comments. I’ll bet there’s more than one.</p><h3>Sources</h3><ul><li>Chip Huyen, <em>Designing Machine Learning Systems</em> (2024)</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e4e117796cf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your RAG Isn’t Broken. Your Chunks Are.]]></title>
            <link>https://medium.com/@sivesh.pb/your-rag-isnt-broken-your-chunks-are-b9328f56c7e5?source=rss-024642ec80d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9328f56c7e5</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[langchain]]></category>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[embedding-model]]></category>
            <category><![CDATA[vector-database]]></category>
            <dc:creator><![CDATA[Sivesh Pb]]></dc:creator>
            <pubDate>Sun, 25 Oct 2026 06:01:01 GMT</pubDate>
            <atom:updated>2026-10-25T06:01:01.937Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xcZHqxd_QxqOMl5OUmk7TA.png" /></figure><p>Most teams debug the wrong layer first and burn a week on prompts before realizing the retrieval layer is quietly deleting their facts. I am going to walk you through how to find out if that is happening in your pipeline, using a checklist you can run today against a production stack. The payoff is simple: if retrieval accuracy is bad, stop fine-tuning and start fixing what comes before the LLM sees your text.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R9P01a_TLJl0V98cnvee7w.png" /></figure><p>A few months back, I was building a career placement assistant that had to answer multi-part questions from placement counsellors over 3,000 placement records. The model sounded confident, but it kept missing the actual dates and numbers people asked for. We tweaked the temperature. We swapped the system prompt three times. Nothing changed. The real issue was upstream, in how we were chunking and embedding the data before it ever reached the vector search step. When you build agentic pipelines with LangChain and RAG on ChromaDB, like I do now in my current role, you will run into this exact trap unless you treat retrieval accuracy as a separate, testable layer.</p><p><strong>In this post:</strong></p><ul><li>See exactly where your chunks are losing facts before the LLM sees them.</li><li>The 20-query test that separates retrieval bugs from generation bugs.</li><li>Why swapping your embedding model beats another round of prompt tweaks.</li></ul><h3>The prompt is not where your facts are dying</h3><p>When a RAG answer feels off, the instinct is to blame the model. But the model only sees what you handed it. If the chunking strategy split a key fact across two chunks, or if your embedding model simply cannot tell the difference between two similar technical terms in your domain, the LLM never gets a chance to recover.</p><p>In my work building an in-house project and ticket management platform extended with agentic AI automation, I saw this play out constantly. Support engineers would ask about a specific deployment error, and the agent would pull back generic troubleshooting steps instead of the actual incident log entry. The vector similarity search was working exactly as designed. It just found the wrong thing because “deployment error” and “deployment timeout” were embedding to nearly identical vectors in our space.</p><p>Here is the core tension I keep running into: your retrieval layer has its own failure modes, and they look exactly like generation failures. You cannot tell them apart from the output alone. That is why you need a separate diagnostic pass before you touch the prompt or the fine-tuning weights.</p><h3>A five-step checklist to find where retrieval fails</h3><p>I run this every time I inherit a RAG pipeline or build a new one from scratch. It is not fancy, but it has saved me from a lot of wasted cycles.</p><ol><li>Pull 20 real queries from your logs or users. Do not make them up; use the ones that actually failed or got complaints attached to them.</li><li>Run those queries through your current embedding and vector search stack, and log exactly which chunks come back at rank one and two.</li><li>Manually grade those retrieved chunks: does the correct answer appear in the top five results? If not, you have a retrieval problem, not a generation problem.</li><li>Test your chunking strategy against the failing queries. Does a key fact get cut across two chunks? Are you splitting on paragraphs when you should be splitting on semantic boundaries or fixed token sizes that respect your domain’s structure?</li><li>Try swapping your embedding model on just those 20 queries and see if retrieval accuracy improves. If it does, your current embeddings are too weak for your specific vocabulary.</li></ol><p>I did this in a GenAI internship I completed earlier this year, where I was building RAG pipelines with vector databases that improved knowledge retrieval accuracy by about 35% once we fixed the chunking layer first. That percentage came not from a better LLM but from better retrieval. The generation step just got cleaner because it stopped receiving noise.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bFhloZJspZQIdCFkbLqmUw.png" /></figure><h3>Chunking is where most pipelines quietly lose their facts</h3><p>Chunking is the step everyone treats as a default setting in LangChain or whatever framework they use. But it is usually the first place retrieval accuracy drops off. If you split on fixed token counts, you can chop a sentence in half and leave the answer orphaned from its context. If you split on paragraphs, you may pull back huge chunks that dilute the signal in your similarity search.</p><p>In my current role, where I own end-to-end system architecture on Azure Cosmos DB including API design, I have seen teams set chunk sizes to whatever default their vector database ships with. They never ask whether their domain’s content has natural boundaries that should drive the split. For ticket management, a single ticket body is the right unit. For legal documents, it is a clause or subsection. For codebases, it might be a function or a class.</p><p>The fix is usually not to change your embedding model at all. It is to change how you slice the document before embedding happens. And honestly, that is cheap to test. You do not need to re-index a million documents to see if your new chunking strategy recovers the answer on those 20 failing queries.</p><blockquote><em>Retrieval accuracy is a property of your chunks, not your model.</em></blockquote><h3>Embedding models are tools, not magic</h3><p>Your embedding model has strengths and weaknesses you will only discover inside your domain. General-purpose embeddings trained on web text will struggle with technical vocabulary, internal codenames, or domain-specific distinctions that do not appear in public corpora. If two terms are semantically close but functionally different in your context, the model will treat them as near-duplicates.</p><p>I tested this exact problem while working on an agent that handled multi-part questions from placement counsellors. The system had to distinguish between “placement records” and “career counselling sessions,” which in our data were stored separately but described with overlapping language. Our default embeddings could not separate them well enough for retrieval to work reliably. We swapped in a model fine-tuned on domain-specific text, and our retrieval accuracy jumped to 92% once the embeddings stopped conflating the two document types.</p><p>Do not assume your current embeddings handle your vocabulary. Test them against your failing queries. If they cannot separate what needs separating, no amount of prompt engineering downstream will fix the confusion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xigr9gmEADgfaASPQcMwDA.png" /></figure><h3>The agent layer makes this harder to debug</h3><p>When you wrap RAG inside an agentic pipeline, the failure looks even more like the model got confused. Your agent picks a tool, retrieves, calls the LLM, formats a response. At any step, the output can look like a hallucination. But in my multi-agent attrition analysis system where separate agents handled data processing, statistical analysis and attrition prediction, 65% of our debugging time went to retrieval before it ever reached generation. That ratio will not surprise you if you have ever watched an agent confidently cite a chunk that never contained the fact it was asked about.</p><p>Agentic pipelines add indirection. You have to log every retrieval step separately, with enough context to reconstruct what the agent actually saw at each decision point. Otherwise you are just guessing which layer failed. I learned this while building Flask-based LLM microservices with LangChain agentic pipelines and RAG retrieval on ChromaDB for production support workflows. Without per-step logging, debugging meant re-running the pipeline and hoping it failed the same way twice.</p><blockquote><em>If your agent retrieves the wrong chunk, no prompt will save you.</em></blockquote><h3>Fix retrieval before you touch fine-tuning</h3><p>Fine-tuning is expensive and slow. Retrieval fixes are cheap and fast. The order matters because fine-tuning can mask a broken retrieval layer for a while, until your data changes enough to expose it again. And by then, you have spent weeks training a model that was never the bottleneck.</p><p>Start with the chunking. Then test your embeddings against real failing queries. Only when both layers are solid do you move to prompt engineering and fine-tuning. That sequence has saved me from a lot of wasted effort, and it should save you from the same trap if your pipeline is producing answers that feel 90 percent right and 10 percent wrong in ways you cannot quite fix.</p><p>What is the most surprising layer where your RAG pipeline failed before you found the real cause?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9328f56c7e5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Pasting Your Work Into a Chatbot]]></title>
            <link>https://medium.com/@sivesh.pb/stop-pasting-your-work-into-a-chatbot-1c2516e87892?source=rss-024642ec80d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c2516e87892</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[future-of-work]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[careers]]></category>
            <category><![CDATA[privacy]]></category>
            <dc:creator><![CDATA[Sivesh Pb]]></dc:creator>
            <pubDate>Sat, 24 Oct 2026 06:01:01 GMT</pubDate>
            <atom:updated>2026-10-24T06:01:01.865Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to use AI for your job without leaking your secrets or losing your brain.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tUvlBh8x2aOnv2Rye_cNyA.png" /></figure><p>I was reviewing a support ticket last week. It was a standard complaint about a slow loading page. I pasted the entire user conversation into my chatbot to get a summary and some suggested responses. The bot gave me a perfect summary in three seconds. It even suggested a polite, professional reply.</p><p>But when I clicked “send,” I realized I had just handed a detailed account of our customer’s browser version, their specific account ID, and their previous support history to a public cloud server. That server might be owned by a company I don’t recognize, run on a GPU farm in another country, and shared with thousands of other developers.</p><p>It wasn’t a hack. No one stole my data. The data just went where it was supposed to go, according to the rules I accepted when I clicked “Enter.”</p><p>This is the daily reality of using AI at work. We are told to “prompt engineer” and “iterate,” but we rarely stop to ask where the conversation is actually happening. Most of us treat AI like a smart intern that lives in our kitchen. We talk about our problems, share our drafts, and ask for advice. But an intern is different from a cloud API.</p><p><strong>Confident Is Not the Same as Correct.</strong></p><p>Your AI tool might give you an answer that sounds authoritative, uses the right jargon, and follows the structure of a perfect email. But if it has accessed your private files, your customer lists, or your internal code, it has effectively become an external memory bank for your most sensitive information.</p><p>Here is the practical truth: You do not need to become a data scientist to protect your work. You just need to change how you ask questions.</p><h3>The Invisible Room Where Your Work Happens</h3><p>When you type a message into a tool like ChatGPT, Claude, or even a smaller open-source model running on your laptop, you are entering a specific “room.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZBG8RvG2AJFXQdTuT6xrJg.png" /></figure><p>For most cloud-based tools, this room is a massive, shared server farm. Think of it like a post office. When you mail a letter, you put it in a box, drop it in a bin, and the post office sorts it with millions of other letters. Sometimes, in rare cases, a letter from your house might end up in a box that gets mixed with a letter from your neighbor. The post office doesn’t always delete the old letters before the new ones arrive.</p><p>Cloud AI services work similarly. When you paste a text, it goes to a server. That server processes the text. Then, the server might save that text to a database for “training” future models, or it might keep it in a “context window” for a few hours.</p><p>Some companies call this “anonymous.” They say, “We remove your name.” But they often keep your specific words, your code snippets, and your project structure.</p><p>In my current role, building a ticket management platform, I saw this happen in a small way. A developer pasted a stack trace, an error log that revealed internal server paths and database schema details, into a chatbot to debug an issue. The chatbot immediately suggested a fix that was technically correct but exposed the internal path to anyone who later queried the model with a similar prompt.</p><blockquote><strong><em>Your private data becomes public data the moment you paste it into a cloud chatbot.</em></strong></blockquote><p>For a student or a small business owner, this might mean you paste a draft of a business proposal or a research paper into an AI to get feedback. The AI suggests improvements. But if that provider scans millions of documents, your proposal could be compared against thousands of others, potentially revealing your unique ideas or even your client’s name.</p><h3>How to Ask Without Leaving a Trace</h3><p>You don’t need to switch to a slower, private tool for every task. You just need a simple framework for your prompts.</p><p><strong>The “Clean Slate” Rule:</strong> Before you ask a complex question, imagine the AI has no memory of your previous conversation. Restate the context in your prompt.</p><p>For example, instead of saying:</p><blockquote><em>“Here is my project plan. Look at what we discussed about the budget, and suggest a new timeline.”</em></blockquote><p>Say:</p><blockquote><em>“You are reviewing a project for a client called ‘GreenTech’. The project involves a mobile app for tracking water usage. The current budget is $50,000. The deadline is three months from now. Based on this, suggest a new timeline.”</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U6XhPLDsqSt81Y5Oi7Q5OQ.png" /></figure><p>By restating the context, you reduce the chance the AI relies on hidden memory. You force it to work with the data you gave it, not the data it might have stolen or saved.</p><p><strong>The “Test File” Check:</strong> If you are using a new tool, try a “test file” first.</p><p>Paste a paragraph of text that includes your name, your company, and a unique project detail. Ask the AI to summarize it. Then, ask it to “show me the conversation history” or “export the log.” If the tool shows you a timestamp, a server ID, or a long string of text that looks like a log, it means the data is being stored.</p><p>If you see a log, treat the next conversation as “recorded.”</p><p><strong>The “One-Off” Mindset:</strong> For sensitive tasks, use tools that don’t save history.</p><p>Some tools offer a “chat mode” that runs in memory and deletes the text after the session ends. Others run locally on your own machine. A local model runs on your computer, meaning the data never leaves your hard drive.</p><p>In my GenAI internship, we built a system where a developer could type a document into a browser, and the AI would summarize it. To keep it private, we added a “self-destruct” button. When the user clicked it, the text was wiped from the server. This small change made the tool feel safer. You can do this too. Look for tools that say “ephemeral” or “session-based” in their settings.</p><h3>The Cost of “Free” AI</h3><p>Many free AI tools are “free” because they use your data to train their models. This is often written in the fine print.</p><p>If you use a free tool to write code, the company might use your code to teach the next version of the AI. If you write code for a client, and that client is a competitor, your competitor might end up learning from your work without paying you.</p><p>This isn’t always malicious. The developers are trying to make the tool smarter. But it changes the value of your work.</p><p><strong>Consider the “Data Dividend”:</strong> If you want your work to remain yours, ask: “Who owns this conversation?”</p><p>When you use a paid subscription, you often get a clause that says the provider can use your data to improve the model. When you use a free tier, the data is almost always shared.</p><p>For a student working on a thesis, this means your unique dataset could be analyzed by a research lab you never knew about. For a small business, it means your customer support logs could be used to train a generic support bot for the next company.</p><blockquote><strong><em>If your work is your asset, don’t let a free tool monetize it without asking.</em></strong></blockquote><h3>A Practical Framework for Safe AI Use</h3><p>Here is a simple checklist I use when I pick a tool for a task. You can use it too.</p><ol><li><strong>Is the data sensitive?</strong></li></ol><ul><li>If yes (client names, code, financials, personal health info), use a tool with “data retention off” or a local model.</li><li>If no (general ideas, public news, rough drafts), a free cloud tool is fine.</li></ul><p><strong>2. What is the task?</strong></p><ul><li><strong>Brainstorming:</strong> Cloud tools are great. You don’t need to worry about the output being used, as long as you don’t paste secrets.</li><li><strong>Refining:</strong> Cloud tools are okay, but read the terms.</li><li><strong>Production:</strong> If the AI will generate something that goes live (code, articles, code reviews), use a tool with a “private mode” or a local instance.</li></ul><p><strong>3. How do I verify?</strong></p><ul><li>Always ask the AI: “What data did you use to generate this?” or “Did you pull from my previous files?”</li><li>Some tools show a “knowledge source” bar. If it says “From your uploaded files,” you know it has your data.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CYyO80VuVEQBIKIeT9B-5A.png" /></figure><p>In my project building an in-house ticket management platform, we extended the system with an AI agent. Instead of using a public cloud API, we hosted the model on our own Azure server. We used a vector database to find related tickets. When a support agent typed a query, the AI only looked at the tickets they had uploaded or the ones in the current session.</p><p>We called this “scoped context.” The AI knew less, but it was more secure. The agents felt safer sharing details because they knew the “room” was smaller.</p><h3>The Future of Your Brain</h3><p>As AI gets better, the temptation to “offload” thinking increases. You might start pasting your entire day’s notes into an AI to organize them. You might ask it to remember your goals.</p><p>This is called “external memory.” It is useful. But if the memory is stored in a cloud that might be hacked, or used to train a model that competes with you, you are trading security for convenience.</p><p><strong>Keep a “Local” Brain:</strong> Use AI for speed, but keep your core assets safe.</p><p>Think of AI as a powerful calculator. A calculator can add numbers in a second. But if you feed it your bank account password, it might share that with the manufacturer. You wouldn’t say, “My calculator knows my bank password.” You would say, “My calculator knows my bank password, which is risky.”</p><blockquote><strong><em>Treat your AI tools like a very smart, very fast intern who lives in a shared house. Don’t leave your keys on the kitchen counter.</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sz_KAgEO2pU7PCd8aJt1ig.png" /></figure><p>Start small. Next time you open a chatbot, paste a tiny piece of text. Ask it where the text went. Ask if it saved it. Then, ask it to delete the text.</p><p>This simple habit builds a mental model of where your data is. It turns the “black box” of AI into a transparent tool you control.</p><p>In a few years, the people who win with AI won’t be the ones who know the most prompts. They will be the ones who know how to keep their data safe while using the power of the machine.</p><p><strong>What is one piece of data you worry about most right now?</strong></p><p><strong>In this post:</strong></p><ul><li>Your AI tool might sound authoritative, but is it actually correct with your private data?</li><li>Learn the ‘Clean Slate’ rule to force your AI to work only with the data you give it.</li><li>Discover how to verify if a free tool is secretly monetizing your work before you paste anything.</li></ul><h3>Sources</h3><ul><li>Chip Huyen, <em>Designing Machine Learning Systems</em> (2021)</li><li>Google, <em>Rules of Machine Learning</em> (2023)</li><li>Azure Cosmos DB Documentation, <em>Scalability and Security</em> (2024)</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c2516e87892" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your RAG Isn’t Hallucinating. It’s Living in Last Tuesday.]]></title>
            <link>https://medium.com/@sivesh.pb/your-rag-isnt-hallucinating-it-s-living-in-last-tuesday-47ed285d3b72?source=rss-024642ec80d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/47ed285d3b72</guid>
            <category><![CDATA[ai-engineering]]></category>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Sivesh Pb]]></dc:creator>
            <pubDate>Fri, 16 Oct 2026 06:01:01 GMT</pubDate>
            <atom:updated>2026-10-16T06:01:01.748Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zl8kOqw6Kwl01n6BH0A5dg.png" /></figure><p>The model didn’t hallucinate. It just answered from last Tuesday’s data. You keep blaming the weights when the real problem is the index.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dIbi7t1JIjq_HvVJtsXbNQ.png" /></figure><p>I spent three hours debugging what I thought was a hallucination issue in my support ticket system. The agent kept answering with the old refund policy. We’d updated the policy two days prior. I checked the model temperature. I checked the prompt template. I even swapped out the embedding model, convinced the vectors were the problem. Then I looked at our ingestion pipeline log. We hadn’t run it since Monday.</p><p>The answer wasn’t wrong logic. It was the right answer to a question that no longer existed.</p><p>In my current role, I build an in-house ticket management platform extended with agentic AI automation. We use Flask-based LLM microservices with LangChain agentic pipelines and RAG retrieval on ChromaDB for production support workflows. That setup works beautifully until the underlying data changes and nobody tells the vector store.</p><p>That’s when things get weird. The system feels confident. The citations look real. The tone is perfect. But it’s describing a world you left behind last week.</p><p><strong>In this post:</strong></p><ul><li>Why your ingestion pipeline is silently failing while your agents sound confident.</li><li>The one boolean check that saves you from answering with retired information.</li><li>How to make your LLM admit uncertainty instead of serving outdated facts as truth.</li></ul><h3>The Silent Killer Between Your Data Store and Your Vectors</h3><p>Most engineers assume RAG staleness comes from bad chunks or weak embeddings. It usually doesn’t. It comes from a missing link between your source of truth and your index.</p><p>When we built our related-ticket detection using embedding-based vector similarity search, we assumed updating the ticket records in our main database would automatically refresh their representation in ChromaDB. It didn’t. The old vectors sat there, happily matching queries against stale content.</p><p>Here’s what actually breaks RAG freshness:</p><ul><li><strong>New data never makes it to the index.</strong> Your ingestion job is manual, or it silently failed last Tuesday. You’re answering with knowledge from three days ago.</li><li><strong>Edited data leaves ghosts behind.</strong> Someone updates a policy doc in Confluence, but your chunking pipeline only runs on new documents, not edits. Now you have two versions of the same fact competing for retrieval.</li><li><strong>Deleted data lingers.</strong> An expired offer or a retired product page still lives in your vector DB because you never wrote a deletion logic.</li></ul><p>The last one is the sneakiest. Nobody thinks to delete vectors. You create them, you query them, and you forget they exist until a user asks about a feature that shipped in 2024 and got sunset last month.</p><blockquote>A stale vector store is worse than no vector store at all.</blockquote><p>That’s because absence fails loudly. Bad data fails softly. The agent sounds confident while serving you outdated facts.</p><h3>Why Your Chunking Strategy Is Probably Lying to You</h3><p>We assumed smaller chunks meant fresher retrieval. Wrong. Smaller chunks mean more chances for a single edit to fragment your meaning into pieces that no longer fit together.</p><p>During my GenAI internship, I worked on RAG pipelines with vector databases that improved knowledge retrieval accuracy by about 35%. That improvement came not from changing our embedding model, but from fixing how we handled document updates. We moved from “ingest once” to “version everything.”</p><p>Here’s the pattern that actually holds up:</p><ol><li>Give every chunk a unique ID tied to its source document and a timestamp.</li><li>When you detect an update (via webhook, polling, or change data capture), don’t just insert new chunks. Mark old versions as superseded.</li><li>Filter at query time. Only retrieve chunks where is_superseded == false.</li></ol><p>This last step matters more than people think. Filtering out stale chunks costs you almost nothing in latency but saves you from answering with retired information. I’ve seen teams spend weeks tuning their embeddings while the real fix was a single boolean check in their query filter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ByA8f_jctmME8_MnJeTTQA.png" /></figure><p>The trade-off is storage. You’re keeping dead vectors around until you explicitly clean them up. But dead vectors are cheap. Wrong answers are expensive.</p><h3>The Ingestion Pipeline Nobody Monitors</h3><p>We treat our RAG pipeline like a firehose: point it at documents, turn it on, walk away. Then we wonder why the water is muddy three months in.</p><p>In my mental health risk detection project, I fine-tuned RoBERTa on Reddit mental health data and got 88% accuracy on risk-level classification. That accuracy only meant anything because the training data was a snapshot. If we’d fed live Reddit posts into the same model without reprocessing, our “risk levels” would have drifted as slang and context evolved.</p><p>The lesson applies equally to your production RAG stack. Your ingestion pipeline is not a one-time setup. It’s a living dependency with its own failure modes:</p><ul><li><strong>Silent failures.</strong> The job runs, hits an API rate limit, and logs a warning nobody reads.</li><li><strong>Format drift.</strong> Your source documents change structure (a new field in JSON, a different PDF layout), and your chunker mangles them without crashing.</li><li><strong>No freshness SLA.</strong> Nobody knows whether the index is 5 minutes old or 5 weeks old until someone files a bug about an outdated answer.</li></ul><p>I now set a hard rule: every vector store has a last_ingested_at timestamp visible in our dashboard. If that timestamp is older than our data&#39;s expected update cadence, we get an alert before users do.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jaRVfcSwAisJIAUzjGrk0Q.png" /></figure><p>That timestamp is your canary. If it’s quiet for too long, something broke.</p><h3>The Query-Side Fix You’re Probably Skipping</h3><p>You can’t always fix the index before the user asks their question. Sometimes the data changed, but your pipeline hasn’t caught up yet. That gap is where query-time intelligence earns its keep.</p><p>I started adding two lightweight checks to our retrieval layer:</p><ul><li><strong>Recency bias.</strong> When scoring candidate chunks, add a small bonus for recent timestamps. It’s not a replacement for proper versioning, but it nudges the agent toward fresher information when it exists.</li><li><strong>Source confidence disclosure.</strong> If the chunk is older than our freshness SLA, we tag it in the context we send to the LLM. The model can then say “based on our last update, …” instead of speaking with false certainty.</li></ul><p>The second one is the one that matters most for user trust. Users don’t care that your vector store is old if you tell them the information has an expiration date attached. They care when you serve a stale fact as if it’s current truth.</p><blockquote>An honest “last updated” beats a confident wrong answer every time.</blockquote><p>That honesty also helps your support team. In our system, we draft LLM replies that are context-aware and sent to the support agent for review. When the underlying ticket data is old, we flag it in the UI so the human knows to double-check before hitting send. The AI isn’t hiding its uncertainty anymore. It’s wearing it openly.</p><h3>What Actually Keeps Your Answers Alive</h3><p>After six months of living with this problem, here’s what I do differently:</p><ul><li>I version every chunk by source doc ID plus timestamp, not just content hash.</li><li>I monitor my last_ingested_at timestamp like a production metric, not an afterthought.</li><li>I filter out superseded chunks at query time, even if storage cost goes up.</li><li>I tag stale context in the prompt so the LLM can hedge its language.</li></ul><p>None of this is sexy. None of it requires fine-tuning or new architectures. It’s plumbing work, the kind that keeps you honest when the data changes (and it always changes).</p><p>The hardest part isn’t technical. It’s admitting that your RAG system is a snapshot, not a mirror. And snapshots go stale unless someone keeps re-taking them.</p><p>So here’s my question for you: what’s the longest your RAG index has gone without a refresh in your production environment, and did anyone notice before the users did?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=47ed285d3b72" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your LLM Passed Every Eval. Then Production Broke It.]]></title>
            <link>https://medium.com/@sivesh.pb/your-llm-passed-every-eval-then-production-broke-it-707da45715fc?source=rss-024642ec80d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/707da45715fc</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai-engineering]]></category>
            <dc:creator><![CDATA[Sivesh Pb]]></dc:creator>
            <pubDate>Mon, 12 Oct 2026 08:20:05 GMT</pubDate>
            <atom:updated>2026-10-12T08:20:05.286Z</atom:updated>
            <content:encoded><![CDATA[<h4>Offline scores are a hypothesis. Production logs are the experiment. Here’s the three-layer eval setup that catches what benchmarks miss.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8UVqQjdvvB3eihtZpNflkg.jpeg" /></figure><p>The score is up three points. The regression suite is green. You push the new fine-tune to production and go to lunch feeling good.</p><p>Three days later, the support queue is on fire. Confident, made-up answers. Broken JSON. Replies that skip half the question. You re-run the evals, and they still say the new model is better.</p><p><strong>Both are telling the truth. They are just measuring different worlds.</strong></p><p>That gap, between <em>measuring</em> a model and <em>trusting</em> it, is one of the most expensive blind spots in LLM engineering. When my offline scores and my production logs disagree, I’ve learned to trust the logs. By the end of this post you’ll know exactly why, and you’ll have the setup I now use so the next “better” model doesn’t blindside you.</p><p><strong>In this post:</strong></p><ul><li>Why a passing eval suite can hide a model that is getting worse for real users</li><li>The warning sign that a high score should make you nervous, not relieved</li><li>A three-layer eval set and a four-step playbook for when evals and logs disagree</li></ul><h3>Your Eval Set Is a Photo of Last Month</h3><p>The biggest myth in LLM engineering is that output quality is a fixed property of the model. It isn’t. <strong>Quality is a property of the whole system, and the system keeps moving.</strong></p><p>What your users experience depends on the model interacting with things your test set froze in time:</p><ul><li><strong>Drifting prompts.</strong> Users change how they ask. New features bring new kinds of questions your test set has never seen.</li><li><strong>Changing context.</strong> Retrieval returns different documents as your knowledge base grows, and long conversations get truncated or summarized.</li><li><strong>Sampling.</strong> With temperature above zero, the same prompt gives different answers. Even at temperature zero, many serving stacks are not perfectly deterministic.</li></ul><p>None of this is new. Chip Huyen’s <em>Designing Machine Learning Systems</em> devotes a full chapter to data distribution shifts, and Google’s <em>Rules of Machine Learning</em> has a rule just for it: measure training/serving skew (Rule #37). LLMs just make the gap wider, because the input space is all of human language.</p><blockquote>If your eval set is a snapshot of last month’s users, you’re not evaluating your model. You’re evaluating its memory.</blockquote><p>This is the day-to-day reality of my work as an AI engineer, where I build LLM features for a support-ticket platform: AI-drafted reply suggestions, RAG retrieval over ChromaDB, and embedding-based detection of duplicate and related tickets. Tickets change every time the product changes. A test set collected a few months ago slowly stops looking like what support agents handle today, so fresh production tickets are the first thing I add to an eval set, not the last.</p><h3>A Perfect Score Should Make You Nervous</h3><p>Here’s the uncomfortable part. Every time you tweak a prompt, change a fine-tuning mix or pick a checkpoint because it scored best on the same small test set, you leak a little of that test set into your decisions. Do it enough times and you are tuning <em>to</em> the eval, not <em>for</em> your users.</p><p>Economists call this Goodhart’s law: <strong>when a measure becomes a target, it ceases to be a good measure.</strong></p><p>The fix isn’t a noisier metric. It’s <em>coverage</em>: an eval set varied and fresh enough that gaming it would mean actually getting better. Watch for these signs that yours has stopped telling the truth:</p><ul><li><strong>A big jump from a small change.</strong> A one-line prompt edit that adds five points has usually found a quirk of the test set, not a better model.</li><li><strong>Flat scores while complaints rise.</strong> Your set no longer covers what users actually send.</li><li><strong>Everything passes.</strong> A suite with no hard cases left can’t tell good from great, or great from broken.</li></ul><h3>The Three-Layer Eval Set That Predicts Production</h3><p>So how do you build an eval set that reflects production? You don’t build it once. You keep building it. Here is the structure I use:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5XdYiWy16V-cPiTWXJ5m2Q.jpeg" /></figure><ol><li><strong>The Frozen Core.</strong> 100 to 200 canonical examples of what your product must always get right. Run it on every change and edit it rarely, so scores stay comparable over time.</li><li><strong>The Drifting Edge.</strong> A growing set sampled from production logs every week and labeled. This is your early-warning system for new user behavior.</li><li><strong>The Adversarial Set.</strong> Cases built to break you: prompt injection, empty or huge inputs, ambiguous questions, strict formatting demands.</li></ol><p><strong>Never average the three into one number.</strong> Each answers a different question: <em>did we break anything</em>, <em>what are users doing now</em> and <em>how do we fail</em>. A blended score hides exactly the regressions you built the layers to catch.</p><p>There’s research behind keeping the edge alive, too. In <em>Who Validates the Validators?</em> (UIST 2024), Shreya Shankar and colleagues found that people refine their grading criteria <em>while</em> reviewing model outputs. They call it criteria drift: you can’t fully define “good” until you’ve looked at real outputs. Hamel Husain makes the same case in <em>Your AI Product Needs Evals</em>: the teams that improve fastest are the ones that look at their data constantly.</p><h3>Optimize the Metric Your Users Feel</h3><p>Even a perfect eval set can measure the wrong thing. Accuracy, BLEU and LLM-judge scores are proxies. Your users feel something else entirely.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rgyAxSBEU-Tnh7aN3kHisQ.jpeg" /></figure><ul><li>A support bot lives or dies on <strong>tickets resolved without a human</strong>.</li><li>A code assistant on <strong>suggestions developers keep</strong>.</li><li>A summarizer on <strong>time saved</strong> for the reader.</li></ul><p>And three things no benchmark scores for you: <strong>latency, cost and consistency</strong>. A model that is two points more accurate but takes twice as long can still lose you users.</p><p><strong>Pick one product metric per use case, then check that your offline metric actually moves with it.</strong> If it doesn’t, it is decoration.</p><p>I saw this clearly during a GenAI internship, where I fine-tuned LLMs for hiring automation. The model metric improved: candidate screening precision went up by 25%. But the number the recruiters actually felt was different. Manual review time dropped by 40%. That second number is the one that made the project matter, because it measured hours given back to people rather than points on a test set.</p><h3>When Evals Say Ship and Logs Say Stop</h3><p>So what do you actually <em>do</em> when the dashboard is green and the support queue is red? Don’t argue with the logs, and don’t roll back blindly. Run this playbook:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fnCLI88KdRi_7U7kjnSjXA.jpeg" /></figure><ol><li><strong>Sample the failures.</strong> Pull about 50 real conversations users complained about, and read every one.</li><li><strong>Name the patterns.</strong> Label each one: hallucination, broken format, wrong refusal, missed intent.</li><li><strong>Find the blind spot.</strong> Check which of those patterns your eval set never tests. That gap is the real bug.</li><li><strong>Close the loop.</strong> Add those cases to the Drifting Edge, write a check that catches them, then re-run before you ship again.</li></ol><blockquote>The offline metric is a hypothesis. The production logs are the experiment.</blockquote><p>When the two disagree, the hypothesis is what’s wrong. Your model isn’t what your eval set says it is. It’s what your users experience.</p><h3>The Bottom Line</h3><p><strong>Evals tell you whether you broke what you already knew about. Logs tell you what you didn’t know yet.</strong> Build for both, and the next “better” model won’t blindside you.</p><p>What’s the biggest gap you’ve found between your eval scores and what users actually saw? Tell me in the comments.</p><h3>Sources</h3><ul><li>Chip Huyen, <em>Designing Machine Learning Systems</em> (O’Reilly, 2022), chapter on data distribution shifts and monitoring</li><li>Martin Zinkevich, <em>Rules of Machine Learning: Best Practices for ML Engineering</em> (Google), Rule #37: Measure Training/Serving Skew</li><li>Shreya Shankar et al., <em>Who Validates the Validators? Aligning LLM-Assisted Evaluation of LLM Outputs with Human Preferences</em> (UIST 2024)</li><li>Hamel Husain, <em>Your AI Product Needs Evals</em> (2024)</li><li>Marilyn Strathern’s widely quoted formulation of Goodhart’s law (1997)</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=707da45715fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Memory Tax: Why Your LLM Agent Gets Dumber When It Remembers More]]></title>
            <link>https://medium.com/@sivesh.pb/the-memory-tax-why-your-llm-agent-gets-dumber-when-it-remembers-more-57816dd71b7a?source=rss-024642ec80d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/57816dd71b7a</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Sivesh Pb]]></dc:creator>
            <pubDate>Fri, 09 Oct 2026 13:44:23 GMT</pubDate>
            <atom:updated>2026-10-09T17:53:18.294Z</atom:updated>
            <content:encoded><![CDATA[<h4>A practical guide to managing context windows without losing the agent’s focus</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ENfrXqEdcb4eu07DIivogQ.png" /></figure><p>In the rush to build autonomous agents, we often treat context windows like a free resource. We dump every log, every user message, and every piece of retrieved data into the prompt. The assumption is that more information equals better performance. But in production, this leads to a phenomenon I call the “Memory Tax.”</p><p>I’ve seen agents that were once sharp and responsive become sluggish and unreliable simply because their context window filled up with low-value noise. The model doesn’t just “read” the extra text for free; it pays a tax in attention, latency, cost and, ultimately, reasoning quality.</p><p>This article explores how to manage your agent’s memory effectively. We will look at why long contexts hurt, practical strategies for context management, and how to architect an agent that remembers what matters without drowning in what doesn’t.</p><h3>Why More Context Hurts</h3><p>To understand why too much context hurts, it helps to look at how transformer models process information. In a decoder-only transformer, every new token attends to all the tokens before it. Attention weights pass through a softmax, so they always sum to one: the more tokens there are, the more candidates compete for the same attention budget. Compute and memory costs also grow with context length, which is why long prompts are slower and more expensive.</p><p>When the context grows far beyond what the task needs, the signal-to-noise ratio drops. The user’s current request, or the one tool result that actually matters, becomes a small island in a sea of text, and it gets harder for the model to separate relevant information from irrelevant chatter.</p><p>This isn’t just theory. In <a href="https://arxiv.org/abs/2307.03172"><em>Lost in the Middle: How Language Models Use Long Contexts</em></a>, Liu et al. (TACL, 2024) showed that models perform best when the relevant information sits at the beginning or end of the input, and significantly worse when it is buried in the middle, even for models built for long contexts. More recently, Chroma’s <a href="https://research.trychroma.com/context-rot"><em>Context Rot</em></a> report (2025) evaluated 18 models, including GPT-4.1, Claude 4, Gemini 2.5 and Qwen3, and found that performance becomes increasingly unreliable as input length grows, even on simple tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k6eBbqnO6iQdgy7hQZccLg.png" /></figure><p>Consider a simple retrieval-augmented generation (RAG) scenario. You want an agent to answer questions about a specific document. If you feed the entire 100-page document into the context window, the one sentence that answers the user’s question may end up buried in the middle, exactly where models are weakest. It’s a needle-in-a-haystack problem that you created yourself.</p><p>The result is an agent that seems “dumber” or less confident. It gives generic answers, hallucinates details, or fails to follow complex instructions because its attention is spread across too much information. That is the Memory Tax: the cost you pay in quality, latency and money for carrying memory the task doesn’t need.</p><h3>Strategies for Context Management</h3><p>So how do we build agents that are both smart and efficient? The key is to be intentional about what goes into the context window. Here are the strategies I’ve found most effective in production:</p><ul><li><strong>Summarize long histories</strong>: Instead of feeding raw logs or entire conversations, keep a rolling summary. If an agent needs to track a user’s session, maintain a summary of older turns plus the last few messages verbatim, rather than the whole 500-message history.</li><li><strong>Put critical information where models use it best</strong>: Keep instructions at the top and the current request at the end. Given the lost-in-the-middle effect, don’t bury the most important facts in the middle of a long prompt.</li><li><strong>Split work into focused calls</strong>: Instead of one giant prompt that classifies, retrieves, reasons and formats, break the task into separate LLM calls, each with only the context it needs for that step.</li><li><strong>Retrieve, don’t paste</strong>: Use a vector database or search index to retrieve only the most relevant chunks for a given query, so the context contains high-quality, relevant information rather than raw, unfiltered data.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FY_6u9DEKT6lH4XA3DO8_Q.png" /></figure><p>One effective pattern is “Summary + Retrieval.” You maintain a high-level summary of the conversation or task state, and use retrieval to pull specific details only when they are needed. This keeps the context window small but highly informative.</p><p>For example, consider an agent that helps customer service representatives handle tickets. Instead of feeding the entire ticket history, you maintain a summary of the ticket’s current status and the key issues raised. When the agent needs a specific earlier message, it retrieves just that part. The prompt stays small and focused, and the agent’s answers improve.</p><p>Another pattern is explicit task state. Instead of making the model infer progress from a long transcript, keep a small structured state object (for example, “goal: migrate the billing table; step 3 of 5; blocked on schema review”) and pass that to the agent on every step. It’s cheaper than replaying history and far less ambiguous.</p><h3>Multi-Agent Systems: Give Each Agent Its Own Context</h3><p>As agents become more complex, context management becomes even more critical. In a multi-agent system, it’s tempting to share one giant transcript between all the agents. That recreates the same attention dilution problem, only at a larger scale.</p><p>A better approach is the orchestrator-worker pattern: a lead agent plans and delegates, and each subagent works in its own context window, then returns only a condensed result. Anthropic describes this design in its write-up of <a href="https://www.anthropic.com/engineering/multi-agent-research-system">how it built its multi-agent research system</a>: subagents explore different parts of a question in parallel, each with a clean context, and hand compressed findings back to the lead agent.</p><p>For example, in a data-analysis system you might have one agent focused on data cleaning, another on exploration, and another on visualization. Each keeps the context relevant to its own job. The lead agent never sees the raw rows or the intermediate queries, only the conclusions it needs to combine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ceBHLSd1KCCrzDy2aA99iQ.png" /></figure><p>This approach not only keeps each agent focused but also makes the system easier to scale. You can add another specialist without inflating every other agent’s prompt.</p><p>Another consideration is external memory. Instead of storing everything in the context window, keep it in vector databases, key-value stores or knowledge graphs, and let the agent query them when needed. An agent answering questions about a large knowledge base should search for the few relevant passages per question, not carry the whole knowledge base in its prompt.</p><h3>Practical Tips for Implementation</h3><p>If you’re building an agent today, here are some practical tips to help you manage context effectively:</p><ul><li><strong>Start small</strong>: Begin with the smallest context that works and add information only when evaluations show it helps. Bigger context windows are a capability, not a target.</li><li><strong>Measure accuracy against context length</strong>: Build a small evaluation set and run it at different context sizes, for example 2k, 8k and 32k tokens. Log token counts for every agent step. If accuracy falls as context grows, you’re paying the Memory Tax.</li><li><strong>Use structured data</strong>: Where you can, pass compact structured data (JSON, tables, short key-value lists) instead of verbose prose or raw dumps. It’s shorter and easier for the model to scan.</li><li><strong>Cache tool results outside the prompt</strong>: Store the results of expensive lookups in a cache or state store and inject only the piece the current step needs. Provider-side prompt caching is also worth using, but note that it reduces the cost and latency of a long, stable prefix; it doesn’t shrink the context the model has to reason over.</li></ul><p>Two more advanced techniques are worth adopting as your agent grows.</p><p><strong>Pass references, not payloads.</strong> Instead of pasting a 5,000-line log or a whole source file into the prompt, store it and give the agent a short handle, such as a file path, document ID or URL, along with tools to fetch exactly what it needs, like search_log(query) or read_lines(path, start, end). The agent pulls in a few relevant lines when it needs them instead of carrying everything all the time.</p><p><strong>Tier your memory.</strong> Keep a small working memory in the prompt (the current goal, the current step and the last few turns), a rolling summary of older history, and long-term memory in an external store that’s searched on demand. <a href="https://arxiv.org/abs/2310.08560">MemGPT</a> (Packer et al., 2023) is a good blueprint: it treats the context window like RAM and external storage like disk, and lets the model move information between them.</p><h3>Closing</h3><p>The Memory Tax is a real and often overlooked challenge in building effective AI agents. By understanding why long contexts degrade performance and applying deliberate context management, you can build agents that are both smarter and cheaper to run.</p><p>As context windows keep growing, the temptation to stuff them will only get stronger. The agents that win won’t be the ones that remember the most. They’ll be the ones that remember the right things at the right time.</p><p>What challenges have you faced with context management in your own projects? How do you keep your agents focused without overwhelming their context windows? Share your experiences in the comments below.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57816dd71b7a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cheat Codes for AI: Mastering Advanced RAG Architectures]]></title>
            <link>https://medium.com/@sivesh.pb/cheat-codes-for-ai-mastering-advanced-rag-architectures-b14ffa1460ad?source=rss-024642ec80d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/b14ffa1460ad</guid>
            <dc:creator><![CDATA[Sivesh Pb]]></dc:creator>
            <pubDate>Wed, 28 Jan 2026 07:49:03 GMT</pubDate>
            <atom:updated>2026-01-28T07:49:03.635Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Why stuffing everything into a context window isn’t enough, and how to build AI that actually thinks before it answers.</em></p><p><strong>Introduction: The “Open Book Exam” Problem</strong></p><p><strong>The Hook:</strong> Start by asking the reader to imagine an open-book exam. If you memorize the textbook (Pre-training), you know a lot of general facts. But what if the exam asks about your professor’s specific lecture notes from yesterday (Private Data)? You need to go find those notes.</p><p>That is <strong>RAG (Retrieval Augmented Generation)</strong>. It bridges the gap between the LLM’s public training data and the “huge mass of private data” (like corporate or personal files) that it has never seen before.</p><p><strong>The Twist:</strong> For a long time, we just retrieved a few documents and fed them to the AI. But basic RAG is brittle. It’s like grabbing the first three pages of your notes and hoping the answer is there. Today, we are going to learn <strong>Advanced RAG</strong> — how to turn that basic look-up process into a sophisticated “operating system” for reasoning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4unxwR1TYSoYNZyVJ2pZ0w.png" /></figure><p><strong>Part 1: Fix the Question (Query Translation)</strong></p><p><strong>The Concept:</strong> Sometimes, users ask bad questions. If you ask a bad question, you get a bad answer. The first step in Advanced RAG is <strong>Query Translation</strong>. This is like having a smart study buddy rewrite your question before you check the textbook.</p><p><strong>Technique A: Multi-Query &amp; RAG Fusion</strong> Instead of asking once, the AI rewrites your question from different perspectives. It fans them out, retrieves documents for <em>all</em> of them, and then uses <strong>Reciprocal Rank Fusion</strong> to rank the best results. It’s a “shotgun approach” to make sure we don’t miss anything.</p><p><strong>Technique B: Decomposition</strong> If you ask a massive physics question, a smart student breaks it down. <strong>Decomposition</strong>splits one big question into sub-questions (e.g., “What is X?” then “How does X work?”), solves them one by one, and builds the final answer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4C-P0vK-6FfQo-rkT3mFyg.png" /></figure><p><strong>Technique C: HyDE (Hypothetical Document Embeddings)</strong> This is a trippy one! The AI hallucinates a fake answer to your question first. Why? Because a fake answer looks more like the <em>real</em> answer (in terms of vectors) than your short question does. It uses the fake answer to find the real document. It’s “fake it ’til you make it” for search.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C88Stkuva1CY_qzQwwf2Kw.png" /></figure><p><strong>Part 2: The Traffic Cop (Routing &amp; Construction)</strong></p><p><strong>The Concept:</strong> Not all questions should go to the same place. You wouldn’t look for a math solution in a history book.</p><p><strong>Routing:</strong> We can set up a “Router” that decides where a question goes.</p><p>• <strong>Logical Routing:</strong> The LLM chooses a data source (e.g., “This is a code question, go to the Python docs”).</p><p>• <strong>Semantic Routing:</strong> We embed the question and see which prompt it is most similar to (Math prompt vs. Physics prompt).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u-Nrhg7L_TLzrx6n1DPfkQ.png" /></figure><p><strong>Query Construction:</strong> Sometimes we need to speak the database’s language. If a user asks “Videos from 2024,” we can’t just search for the text “2024.” We use <strong>Query Construction</strong> to convert natural language into metadata filters (like date &gt; 2024) or SQL queries. It converts &quot;human speak&quot; into &quot;database speak&quot;.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RV6wA_SYo7VKlnTvUOl8hw.png" /></figure><p><strong>Part 3: Organize Your Notes (Advanced Indexing)</strong></p><p><strong>The Concept:</strong> Standard RAG chops documents into random chunks. But that breaks the flow of information. Advanced indexing is about organizing data so it’s easier to find.</p><p><strong>Technique A: Multi-Representation Indexing</strong> Imagine searching for a summary of a book chapter, but when you click it, you get the <em>whole</em> chapter. This technique embeds a <strong>summary</strong> (for efficient searching) but retrieves the <strong>full raw document</strong> (for the LLM to read). It keeps the context intact.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O5wpTDoNG2HFfM4d4UCwzg.png" /></figure><p><strong>Technique B: RAPTOR (Recursive Summarization)</strong> What if your question requires reading the whole textbook? <strong>RAPTOR</strong> clusters your documents, summarizes the clusters, and then summarizes the summaries! It creates a “tree” of information. High-level questions hit the top of the tree; specific questions hit the bottom leaves.</p><p><strong>Technique C: ColBERT</strong> Instead of squashing a whole document into one vector, <strong>ColBERT</strong> keeps vectors for every single token (word). It compares every word in your question to every word in the document. It’s computationally heavier but extremely precise.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KrG7QbMtWKoNdISJ3uEwaw.png" /></figure><p><strong>Part 4: The Self-Correcting Student (Active RAG &amp; Flow Engineering)</strong></p><p><strong>The Concept:</strong> This is the future. Basic RAG is linear: Retrieve -&gt; Generate. <strong>Active RAG</strong> is circular. It uses “Flow Engineering” (loops and tests) to check its own work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u35T0a5MPP1z2OFLekpxPQ.png" /></figure><p><strong>Technique A: CRAG (Corrective RAG)</strong> The AI retrieves documents and then <strong>grades</strong> them.</p><p>• Are they relevant? Yes -&gt; Generate answer.</p><p>• Are they irrelevant? No -&gt; <strong>Kick to Web Search</strong>. It adds a safety net so you don’t answer with bad data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t-GtC25xMbC3tEhX1l4hmA.png" /></figure><p><strong>Technique B: Self-RAG</strong> This adds even more checks.</p><p>1. Is the retrieval useful?</p><p>2. Is the generated answer a hallucination?</p><p>3. Does the answer actually address the question? If any of these fail, the AI loops back and tries again. It’s like a student checking their answers before handing in the test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c8sYmqo1eUuUMesEJwsDhQ.png" /></figure><p><strong>Conclusion: From Chains to Brains</strong></p><p>Early RAG systems were built like <strong>chains</strong>:<br>retrieve → generate → done.</p><p>They worked — until the question got harder, the data got messier, or the answer <em>actually mattered</em>.</p><p>Advanced RAG replaces chains with <strong>graphs</strong>.<br>Instead of blindly moving forward, the system can:</p><ul><li>rethink the question</li><li>choose the right knowledge source</li><li>preserve structure instead of shredding context</li><li>check its own answers and try again</li></ul><p>By combining <strong>Query Translation</strong>, <strong>Routing</strong>, <strong>Advanced Indexing</strong>, and <strong>Active RAG</strong>, we stop building systems that merely <em>repeat</em> information — and start building systems that <strong>reason with it</strong>.</p><p>This is the shift from AI as a lookup tool<br>to AI as a thinking partner.</p><h3>🚀 Final Thought</h3><p>Don’t just build a RAG bot.<br><strong>Build a RAG flow.</strong></p><p>Your users — and your grades — will thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b14ffa1460ad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[#NLP Diaries 3: Understanding Bias in Logistic Regression (Without the Jargon!)]]></title>
            <link>https://medium.com/@sivesh.pb/nlp-diaries-3-understanding-bias-in-logistic-regression-without-the-jargon-8f8f6051b8e5?source=rss-024642ec80d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f8f6051b8e5</guid>
            <dc:creator><![CDATA[Sivesh Pb]]></dc:creator>
            <pubDate>Sun, 02 Mar 2025 08:47:34 GMT</pubDate>
            <atom:updated>2025-03-02T08:47:34.778Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey there! 👋 If you’ve ever dived into machine learning, you’ve probably come across <strong>logistic regression</strong> — a fancy term for a simple classification model. But one concept that often confuses people is the <strong>bias term</strong> in the feature vector.</p><p>Don’t worry! I’m going to break it down in a super-friendly way so that even if you have zero technical background, you’ll get it by the end of this post. Let’s go! 🚀</p><h3>What’s Logistic Regression?</h3><p>Think of logistic regression as a decision-maker. Imagine you have a friend who decides whether to <strong>like or dislike</strong> a tweet based on the words in it. The model does the same — it looks at a tweet and predicts whether it’s <strong>positive</strong> or <strong>negative.</strong></p><blockquote>If you want to dive deeper into logistic regression, check out my <strong>NLP Diaries 2</strong>, where I break it down in a simple and practical way: <a href="https://medium.com/@sivesh.pb/nlp-diaries-2-breaking-down-logistic-regression-for-text-analysis-2d447a4a267b">NLP Diaries 2 — Breaking Down Logistic Regression for Text Analysis</a>.</blockquote><p>But how does it do this? It uses a special formula called the <strong>sigmoid function</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*GoxNQC9M68nfX0H4QisjvA.png" /></figure><p>(Okay, I know this looks scary, but stay with me! 😆)</p><p>Here’s what’s happening:</p><ul><li>The model calculates a score (let’s call it <strong>z</strong>) based on the words in the tweet.</li><li>It then converts that score into a probability between 0 and 1.</li><li>If the probability is <strong>above 0.5</strong>, it predicts <strong>positive</strong>; otherwise, it predicts <strong>negative.</strong></li></ul><p>Easy, right? Now, let’s talk about how we get that score <strong>z.</strong></p><h3>What’s a Feature Vector?</h3><p>When we analyze text, we turn words into numbers. The most basic way to do this is to count how many <strong>positive</strong> and <strong>negative</strong> words are in a tweet.</p><p>For example, let’s take the tweet:</p><p>👉 <em>“The food was amazing but the service was bad.”</em></p><p>We count:</p><ul><li><strong>Positive words</strong> = 1 (<em>amazing</em>)</li><li><strong>Negative words</strong> = 1 (<em>bad</em>)</li></ul><p>We represent this as a <strong>feature vector</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*fRUupi60h-ITlh1lw1dRjw.png" /></figure><p>So, for our tweet, we get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/242/1*uWof7xkrtuVWNhjBls2r_Q.png" /></figure><p>Wait… <strong>what’s that first ‘1’?</strong></p><h3>What’s the Bias Term?</h3><p>That first <strong>1</strong> is called the <strong>bias term</strong>, and it’s always there. It helps adjust our predictions so that the model isn’t forced to always go through zero.</p><p>Let’s see this in action.</p><p>Imagine our model has learned these weights:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/242/1*e2HtvLj27qwr_T3XshJQ_g.png" /></figure><p>This means:</p><ul><li>Each <strong>positive word</strong> adds <strong>+2</strong> to the score.</li><li>Each <strong>negative word</strong> subtracts <strong>3</strong> from the score.</li></ul><p>Now, let’s calculate the score for our tweet:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*_mdm44zIjToX4Q6rZg2Ajg.png" /></figure><p>Since <strong>-1</strong> is less than 0, the model predicts <strong>negative sentiment</strong>. But what if we want to shift this decision boundary?</p><h3>How Bias Helps</h3><p>Let’s say we add a bias value of <strong>4</strong>:</p><p>Now, our score becomes:</p><p>A positive score means the model predicts <strong>positive sentiment</strong>! 🎉</p><p>So, the <strong>bias term helps adjust predictions, making them more accurate.</strong> Without it, the model might struggle with certain inputs.</p><h3>🚀 <strong>Math Magic: np.dot and the Power of NumPy</strong></h3><p>Okay, let’s take a quick break from logistic regression and talk about something <strong>super cool</strong> — NumPy’s np.dot function! 🧠✨</p><p>Imagine you’re calculating values manually, multiplying numbers, and summing them up every single time. <strong>Sounds exhausting, right?</strong> Well, np.dot is here to do the heavy lifting for you!</p><h4><strong>What Does np.dot Do?</strong></h4><p>Simply put, np.dot performs <strong>dot product multiplication</strong>—a fancy way of saying it quickly multiplies and sums up corresponding values from two lists.</p><pre>import numpy as np<br><br>x = np.array([1, 1, 1])  # Feature vector<br>theta = np.array([4, 2, -3])  # Weights<br><br>z = np.dot(x, theta)  # Dot product<br>print(z)  # Output: 3</pre><p>Instead of manually calculating:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*r3Mw3iNWm0fHiftX1MPCjA.png" /></figure><p>We just call np.dot(x, theta), and <strong>boom—NumPy does it instantly!</strong></p><h3>Why Is This Useful?</h3><p>1️⃣ It <strong>speeds up</strong> calculations (especially with large datasets).<br>2️⃣ It makes code <strong>cleaner</strong> and easier to read.<br>3️⃣ It’s essential for machine learning models to process input data efficiently.</p><p>But wait, there’s more!</p><h3>Meet np.exp — The Secret Sauce of Predictions</h3><p>Another lifesaver in ML is np.exp, which helps compute the <strong>sigmoid function</strong> (used in logistic regression for predictions).</p><pre>y_pred = 1 / (1 + np.exp(-z))</pre><p>This transforms z into a probability between <strong>0 and 1</strong>, helping the model decide if a tweet is positive or negative.</p><h3>Final Thoughts 🎯</h3><p>At first glance, the <strong>bias term</strong> might seem like just another random number in the equation. But now you know — it’s actually a <strong>game-changer!</strong> It helps our model make <strong>better predictions</strong> and ensures that it doesn’t rely on incorrect assumptions.</p><p>And let’s not forget the <strong>magic of NumPy!</strong> Functions like np.dot and np.exp make all these calculations <strong>fast and effortless</strong>, saving us from doing tedious math by hand. 🚀</p><p>The takeaway? <strong>Small details matter in machine learning.</strong> Understanding concepts like bias and efficient computations can take your models to the next level.</p><p>So next time you see that <strong>mysterious ‘1’</strong> in your feature vector, you won’t just accept it — you’ll <strong>know exactly why it’s there!</strong> 😉</p><p>Machine learning doesn’t have to be intimidating — <strong>keep exploring, keep experimenting, and most importantly, have fun!</strong> 🎉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f8f6051b8e5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NLP Diaries #2: Breaking Down Logistic Regression for Text Analysis]]></title>
            <link>https://medium.com/@sivesh.pb/nlp-diaries-2-breaking-down-logistic-regression-for-text-analysis-2d447a4a267b?source=rss-024642ec80d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d447a4a267b</guid>
            <dc:creator><![CDATA[Sivesh Pb]]></dc:creator>
            <pubDate>Tue, 18 Feb 2025 03:29:18 GMT</pubDate>
            <atom:updated>2025-02-18T03:29:18.228Z</atom:updated>
            <content:encoded><![CDATA[<p>Ever wondered how a computer can tell if a tweet is <strong>positive or negative</strong>? Or how your email knows which messages are <strong>spam</strong>?</p><p>Well, it’s not magic — it’s <strong>logistic regression</strong> at work! Let me break it down in a way that actually makes sense.</p><h3><strong>What’s Logistic Regression, Really?</strong></h3><p>Think of it as a <strong>decision-making tool for machines</strong>. It helps answer simple yes/no questions like:<br>✅ Is this tweet positive or negative?<br>✅ Is this email spam or not?<br>✅ Will this customer buy something or not?</p><p>It does this using a special formula called the <strong>sigmoid function</strong> (fancy name, simple idea). This function takes in some numbers and <strong>spits out a probability between 0 and 1</strong>.</p><ul><li><strong>Closer to 0?</strong> → More likely <strong>“No”</strong></li><li><strong>Closer to 1?</strong> → More likely <strong>“Yes”</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ncTNW-sqe-Ta6PkF9iE0Qw.png" /></figure><p>So, if you feed logistic regression a tweet, it can predict whether it’s positive or negative <strong>just by looking at the numbers behind it</strong>.</p><h3><strong>How Does It Work?</strong></h3><p>Let’s break it down step by step:</p><p>1️⃣ <strong>Turn a tweet into numbers</strong> → Computers don’t understand words, so we convert them into numbers.</p><p>2️⃣ <strong>Multiply those numbers by some weights</strong> (let’s call them <strong>θ</strong>, but don’t stress about the name).</p><p>3️⃣ <strong>Pass the result through the sigmoid function</strong> → This squishes the output between 0 and 1, so we get a probability.</p><p>4️⃣ <strong>Make a decision</strong> → If the probability is <strong>high</strong>, the tweet is <strong>positive</strong>; if it’s <strong>low</strong>, it’s <strong>negative</strong>.</p><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*17Bx_e1J7jI3PW2uZfOcWg.png" /></figure><h3>How Does the Machine Get Better?</h3><p>At first, the machine is just <strong>guessing</strong> — like trying to hit a target with a blindfold on. But with every mistake, it <strong>adjusts its aim</strong> using a process called <strong>gradient descent</strong> (basically, trial and error until it gets better).</p><ul><li><strong>At first?</strong> Lots of mistakes.</li><li><strong>Over time?</strong> Fewer mistakes.</li><li><strong>Eventually?</strong> The machine <strong>figures out the right pattern</strong> and stops improving.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*irBjHyVmPceaYFnZCvhy8g.png" /></figure><p>If you were to <strong>plot</strong> this learning process, you’d see the number of mistakes <strong>going down</strong> until it levels off — just like how we improve at anything with practice!</p><h3>Why Does This Matter?</h3><p>This simple idea powers a ton of things you use daily:<br>🚀 <strong>Spam filters</strong> that keep your inbox clean<br>🚀 <strong>Movie recommendations</strong> that actually make sense<br>🚀 <strong>AI-powered customer support</strong></p><p>So the next time an AI predicts something, just know — it’s using <strong>logistic regression (or something very similar) to make that call!</strong> 🤖✨</p><p>Inspired by insights from <strong>Ken Church</strong>, I wanted to break down logistic regression in the simplest way possible…</p><p>💡 <strong>Got questions?</strong> Drop them below! If you enjoyed this, stay tuned for more bite-sized AI insights. 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d447a4a267b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NLP Diaries: How Machines Learn and Understand Emotions in Text]]></title>
            <link>https://medium.com/@sivesh.pb/nlp-diaries-how-machines-learn-and-understand-emotions-in-text-63d4a1fb4f43?source=rss-024642ec80d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/63d4a1fb4f43</guid>
            <dc:creator><![CDATA[Sivesh Pb]]></dc:creator>
            <pubDate>Sat, 08 Feb 2025 21:11:18 GMT</pubDate>
            <atom:updated>2025-02-08T21:29:25.805Z</atom:updated>
            <content:encoded><![CDATA[<h3>🧠 How Machines Learn: Supervised ML Made Simple</h3><p>Imagine teaching a machine how to guess answers correctly — just like how a teacher helps students learn. In supervised machine learning (ML), you give the machine examples with correct answers, and it learns from them to make predictions. Here’s a simple way to break it down:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*o_t5k0qMxCBjLsej" /></figure><ul><li><strong>Input (X)</strong>: Think of this as the problem or question you give the machine.</li><li><strong>Prediction Function</strong>: This is the machine’s method for figuring out the answer.</li><li><strong>Predicted Output (ŷ)</strong>: The machine’s guess.</li><li><strong>True Output (Y)</strong>: The actual correct answer.</li><li><strong>Cost Function</strong>: How wrong the machine’s guess is.</li><li><strong>Parameter Updates (θ)</strong>: Ways to adjust the machine so it gets better at guessing.</li></ul><p>The machine keeps learning and improving until it’s accurate enough.</p><h3>😊 Teaching Computers to Spot Happy or Sad Messages</h3><p>Sentiment analysis is like asking the computer to figure out if a message is happy or sad. For example, if you see the tweet:</p><blockquote><em>“I am happy because I am learning NLP.”</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HUhlSpfT9d5GgIMv" /></figure><p>Here’s how the machine figures it out:</p><ol><li><strong>Feature Representation</strong>: Turn the words in the text into numbers.</li><li><strong>Model Training</strong>: Teach the computer by showing it many examples of happy and sad messages.</li><li><strong>Prediction</strong>: The computer checks the message and decides whether it’s positive (1) or negative (0).</li></ol><h3>🔤 How Machines Read Words: Vocabulary &amp; Features</h3><p>To make sense of text, the computer needs to convert it into numbers. This is called feature extraction. Imagine this sentence:</p><ul><li><strong>Text Example</strong>: “I am happy because I am learning NLP.”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gkxNVfXvSbliMUKp" /></figure><p>The computer creates a list where each word gets a number, like placing a 1 for every word that appears and 0 for those that don’t.</p><p>As more words are added, the list gets really long, making it harder for the machine to work efficiently.</p><h3>📊 Smarter Feature Extraction with Word Counts</h3><p>Instead of just marking whether a word appears, it’s smarter to count how often each word shows up in happy or sad messages. For example:</p><ul><li><strong>Positive Tweet</strong>: “I am happy.”</li><li><strong>Negative Tweet</strong>: “I am sad.”</li></ul><p>The machine builds a dictionary to keep track. For the tweet “I am sad, I am not learning NLP,” the feature list might be:</p><ul><li><strong>Feature Vector</strong>: [1, 8, 11]</li><li><strong>1</strong>: A starting number to help the math work out.</li><li><strong>8</strong>: How often positive words appear.</li><li><strong>11</strong>: How often negative words appear.</li></ul><p>Let’s break it down in a way that’s super easy to understand:</p><ul><li>Imagine your tweet is a mix of happy and sad words. If “happy” showed up 8 times in all positive tweets and “sad” appeared 11 times in negative tweets, that’s what gets counted.</li><li>The <strong>1</strong> is like a magic helper number (bias) that smooths out the math during predictions.</li></ul><h4>Example:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nOtVP-HQQ-tutWWG" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RBKLHAjuBFOvNDt1" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5mP2R-EMFAx2e4Ef" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6dPaw5pEs0a6Rjrw" /></figure><p>This way, the machine gets better without wasting time.</p><h3>🛠️ Cleaning Text Before Teaching Machines</h3><p>Before the machine can learn, the text needs cleaning up. Here’s what you do:</p><ol><li><strong>Eliminate Handles and URLs</strong>: Remove mentions like @someone and links.</li><li><strong>Tokenization</strong>: Break the sentence into individual words.</li><li><strong>Remove Stop Words</strong>: Get rid of words like “and,” “is,” “a,” etc.</li><li><strong>Stemming</strong>: Simplify words to their basic form (e.g., “dancer,” “dancing,” “danced” all become “danc”).</li><li><strong>Lowercase Conversion</strong>: Make everything lowercase.</li></ol><h4>Example</h4><p>Given the tweet:</p><blockquote><em>“@YMourri and @AndrewYNg are tuning a GREAT AI model at </em><a href="https://deeplearning.ai/"><em>https://deeplearning.ai</em></a><em>!!!&quot;</em></blockquote><p>After cleaning it up, it becomes:\</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MDHM5-1g6qp2HQRO" /></figure><blockquote><em>[“tun”, “great”, “ai”, “model”]</em></blockquote><p>Here’s what happened:</p><ul><li><strong>Handles Removed</strong>: Names like @YMourri were deleted.</li><li><strong>URLs Removed</strong>: The website link was removed.</li><li><strong>Tokenization</strong>: The sentence was split into words.</li><li><strong>Stop Words Removed</strong>: Common words like “and” were removed.</li><li><strong>Stemming Applied</strong>: Words were simplified (“tuning” became “tun”).</li><li><strong>Lowercase Conversion</strong>: Everything turned lowercase.</li></ul><p>By cleaning and simplifying text, machines can better understand and predict whether a message is happy or sad.</p><h3>🏅 Acknowledgment</h3><p>Special thanks to <strong>Ken Church</strong>,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/0*4UcCIHCWqNQaONSU" /><figcaption><strong>Ken Church</strong></figcaption></figure><p>Distinguished Scientist at Baidu and former leader of computational linguistics research at IBM, Microsoft, AT&amp;T, and Johns Hopkins University, for reviewing the outline and topics of the Coursera course <strong>Natural Language Processing with Classification and Vector Spaces</strong> and sharing valuable insights on NLP education.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63d4a1fb4f43" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>