<?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 Sarin Bhaskaran on Medium]]></title>
        <description><![CDATA[Stories by Sarin Bhaskaran on Medium]]></description>
        <link>https://medium.com/@sarinbhaskaran?source=rss-d69e530e03c3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Sarin Bhaskaran on Medium</title>
            <link>https://medium.com/@sarinbhaskaran?source=rss-d69e530e03c3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 05:16:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sarinbhaskaran/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[Jev : Meet the strong, silent type of AI]]></title>
            <link>https://sarinbhaskaran.medium.com/jev-everyones-new-favorite-ai-has-nothing-to-say-9b245e1e8c8f?source=rss-d69e530e03c3------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b245e1e8c8f</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[artificalintelligence]]></category>
            <category><![CDATA[jevs]]></category>
            <category><![CDATA[system-one-model]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Sarin Bhaskaran]]></dc:creator>
            <pubDate>Wed, 23 Sep 2026 14:05:17 GMT</pubDate>
            <atom:updated>2026-09-23T14:23:00.148Z</atom:updated>
            <content:encoded><![CDATA[<h4>Everyone’s calling it “193x faster than an LLM.” Here’s what Jev actually is, in plain English — and why an AI that refuses to write a single word is the interesting part.</h4><p>So there’s a new AI thing called Jev, and your timeline has decided it’s the second coming.</p><p>“193x faster than GPT!” “445x cheaper!” “LLMs are over!”</p><p>And then you click through to actually learn what it <em>is</em>, and every single article assumes you already know. They start talking about “typed primitives” and “calibrated decision models” and “non-autoregressive parallel sampling,” and you quietly close the tab and go back to pretending you understood.</p><p>I did that about six times. So I went and figured it out properly, and I’m going to explain it the way I wish someone had explained it to me — no jargon, no hype, and with an honest answer to the question you actually care about: <em>is this thing going to replace ChatGPT?</em></p><p>(Spoiler, because I respect your time: no. But not for the reason you think.)</p><h3>First, the one-sentence version</h3><p><strong>Jev is an AI that doesn’t write. It only picks.</strong></p><p>That’s it. That’s the whole idea. Everything else — the speed, the cost, the hype, the weird name — falls out of that one design decision.</p><p>An LLM like ChatGPT or Claude gives you <em>words</em>. Jev gives you <em>answers to multiple-choice questions</em>. You hand it a situation, you hand it a list of options, and it points at one of them and tells you how sure it is.</p><p>It cannot write you a poem. It cannot explain its reasoning. It cannot say “hello.” It genuinely, structurally cannot produce a sentence. And it turns out that giving all that up buys you something enormous.</p><h3>The analogy that made it click for me</h3><p>Picture two students taking the same exam.</p><p><strong>Student A (the LLM)</strong> has to answer everything in essay form. Even for “Is this email spam?”, they write: <em>“Great question! Looking at this email, there are several factors to consider. The sender domain appears…”</em> — four paragraphs later, they land on “yes.” And crucially, they write it <strong>one letter at a time</strong>, and each letter they write depends on the letters before it. They cannot skip ahead. They cannot write the conclusion first.</p><p><strong>Student B (Jev)</strong> got the bubble sheet. Question 1: A, B, C, or D. <em>Shhk.</em> Done. And because the bubbles don’t depend on each other, Student B can fill in <strong>all forty bubbles at the same time</strong>.</p><p>That’s the entire performance story. LLMs are sequential by nature — token by token, each one waiting on the last. Jev answers everything in one parallel pass.</p><blockquote><strong><em>An LLM writing “yes” costs you the same machinery as an LLM writing a novel. It just stops sooner.</em></strong></blockquote><p>This is why the speed gap isn’t a small optimization. It’s a different shape of work.</p><h3>What you actually send it</h3><p>Okay, slightly more concrete — but I promise this stays readable.</p><p>A request to Jev has exactly two parts:</p><p><strong>1. The state.</strong> This is just “here’s what’s going on.” A support ticket, a user’s shopping cart, a chunk of a document, a snapshot of a game. Text or JSON, whatever you’ve got.</p><p><strong>2. The questions.</strong> These are typed, meaning you define the possible answers in advance. There are only three kinds:</p><ul><li><strong>Choice</strong> — “Pick one of these options.” <em>(Which team should this ticket go to: Billing, Technical, or Refunds?)</em></li><li><strong>Score</strong> — “Rate this on a scale.” <em>(How urgent is this, 0 to 4?)</em></li><li><strong>Noul</strong> — “How likely is this statement to be true?” <em>(Is this customer about to churn?)</em> You get back a probability between 0 and 1.</li></ul><p>And then Jev answers all of them at once and hands back structured data — the answer, the probability for <em>every</em> option, and a confidence score.</p><p>Here’s the part that quietly matters a lot: <strong>because you defined the options up front, Jev physically cannot answer with something else.</strong> If the options are Billing, Technical, and Refunds, you will get one of those three. Not “Bilingual.” Not “I’m sorry, as an AI language model.” Not a JSON object with a missing bracket that crashes your code at 3am.</p><p>If you’ve ever begged an LLM to <em>please just return valid JSON this time</em> — this is the feature. This is the whole pitch.</p><h3>The name is a nerd joke, and I love it</h3><p>Two references packed into one product:</p><p><strong>“System One models”</strong> comes from Daniel Kahneman’s <em>Thinking, Fast and Slow</em>. System 1 is your fast, intuitive, gut-instinct brain — the one that recognizes a friend’s face or slams the brakes. System 2 is the slow, deliberate one that does long division. LLMs with reasoning modes have been chasing System 2. TypeSafe went the other way entirely.</p><p><strong>“Jev”</strong> is short for William Stanley Jevons, a Victorian economist famous for the Jevons paradox: when you make something dramatically cheaper to use, people don’t use less of it — they use <em>way</em> more. Steam engines got efficient, and coal consumption exploded.</p><p>The bet baked into the name is that cheap-enough machine decisions won’t just save money on existing AI features. They’ll unlock a pile of uses nobody bothered building because AI was too slow and too expensive to put there.</p><p>Naming your model after your own business thesis is a <em>choice</em>. Respect.</p><h3>Okay, but is it really 193x faster?</h3><p>Here’s where I have to be the annoying friend who reads the footnotes.</p><p><strong>Short answer: the number is real, and it’s also the best-case number, and independent testers got much smaller numbers doing simpler things.</strong></p><p>Both of those are true, and understanding why is genuinely the most useful thing in this article.</p><p>TypeSafe’s own headline claims: responses in 70–500 milliseconds, 40–200x faster than frontier LLMs, peaking at 193.6x faster and 444.6x cheaper. To their credit, their launch post openly says these are “on the higher end” of real-world gains — the receipts come with footnotes, which is more than most AI launches manage.</p><p>Then other people started measuring. Here’s what they found:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*GEcv-WL-1DZR2cYgndzyWw.png" /></figure><p>Look at that first row and that second row. <strong>Same model. Same testers. Same week.</strong> 1.7x and 100x.</p><p>Nobody’s lying. They’re measuring different things, and the difference is the whole point:</p><p><strong>If you swap one single LLM call for one Jev call, you get maybe 2–5x.</strong> Nice! Not life-changing.</p><p><strong>If you have a workflow that asks six questions about the same thing, one after another</strong> — is this urgent, is it a refund request, is the customer angry, should a human see it, what’s the priority, is it a duplicate — <strong>an LLM does six round trips and Jev does one.</strong> That’s where 100x lives. Six sequential calls at ~12 seconds each became one call at 0.74 seconds.</p><blockquote><strong><em>Jev isn’t fast because it’s a faster engine. It’s fast because it doesn’t have to make the trip six times.</em></strong></blockquote><p>So when someone quotes you a speed number for Jev, the only sensible response is: <em>okay, faster at what, exactly?</em></p><h3>The part that’s arguably cooler than the speed</h3><p>Speed gets the headlines. But talk to people actually building with it and they get more excited about something else: <strong>it tells you when it’s unsure, and it’s honest about it.</strong></p><p>You can ask an LLM “how confident are you?” and it’ll cheerfully say “95%!” That number is generated text. It’s the model producing a plausible-sounding confidence, which is not the same as <em>having</em> one. LLMs are famously, endearingly overconfident — like a golden retriever that’s certain it can catch the frisbee.</p><p>Jev was trained differently. TypeSafe calls the method <strong>RLCD — Reinforcement Learning for Calibrated Decisions</strong>. Instead of tuning the model to give answers humans <em>like</em>, they tuned the probabilities to <em>match reality</em>. When Jev says 82%, the goal is that across a big pile of similar calls, it’s right about 82% of the time.</p><p>That sounds academic. It is wildly practical. It means you can write code like:</p><p><em>“If Jev is more than 90% sure, just do it automatically. Otherwise, send it to a human.”</em></p><p>You cannot reliably do that with a vibes-based confidence score. This is the difference between “AI that’s impressive in a demo” and “AI you let touch production.”</p><p>There’s even a neat trick people are using: run Jev first, and only escalate the genuinely uncertain cases to an expensive frontier model. OpenRouter tested this and got within 0.4 percentage points of Claude Opus 5’s accuracy for under 30% of the cost.</p><p><strong>One important caveat</strong>, because I said I wouldn’t hype: calibration is a property of the <em>group</em>, not the individual answer. “82% confident” doesn’t mean this specific answer is 82% correct. It means the batch behaves that way on average. Any single answer can still be flat wrong.</p><p>And while Jev can’t hallucinate a value outside your options — that’s mathematically guaranteed — it can absolutely pick the <em>wrong</em> option from your list. “Can’t hallucinate” means “can’t make up nonsense,” not “can’t be mistaken.” Big difference, frequently blurred.</p><h3>Where Jev is completely useless</h3><p>This is my favorite section to write because the list is long and the honesty is refreshing.</p><p>Jev cannot:</p><ul><li><strong>Write anything.</strong> No text. At all. Not a summary, not an email, not a variable name.</li><li><strong>Explain itself.</strong> You get a decision and a probability. You do not get “because the customer mentioned a chargeback.” No reasoning, no receipts.</li><li><strong>Plan.</strong> It answers the question you asked about the state you sent. It has no idea what should happen next.</li><li><strong>Remember.</strong> Zero memory between calls. No conversation history, no stored context. Every request ships its own state, every time.</li><li><strong>Weigh many things against each other.</strong> “Rank these companies across quality, momentum, and management” needs synthesis. Jev does “does this violate rule four, yes or no.”</li><li><strong>Play the long game.</strong> Chess, strategy, anything needing look ahead. There’s no planner in there.</li></ul><p>It also tops out at 255 options per Choice question, and it’s still in limited early access — TypeSafe is pulling people off a waitlist. The architecture, the weights, and the parameter count are all unpublished; there’s no technical paper. Community projects (openjev, open-jev, jev-on-a-laptop, and an open reference model called Laya) have recreated the <em>interface</em> on open models, but nobody outside TypeSafe knows what&#39;s actually under the hood. Outside observers suspect an open-weight LLM underneath. Worth knowing before you build a company on it.</p><h3>So: Jev vs. LLM. Who wins?</h3><p>Wrong question, and I say that with love.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*IYj_wEz36FAZ00z5TwlxWA.png" /></figure><p>The cleanest way to think about it: there are now <strong>three tiers</strong> in the AI stack.</p><ol><li><strong>Embedding models</strong> — find and retrieve the relevant stuff</li><li><strong>Decision models (Jev)</strong> — route, classify, score, judge</li><li><strong>LLMs</strong> — reason, write, explain, create</li></ol><p>Jev didn’t take a slot away from LLMs. It filled a slot that was previously being covered by LLMs badly and expensively — because it was the only tool anyone had. Using GPT-5 to answer “is this spam, yes or no” was always a bit like hiring a novelist to fill out your tax forms. They’ll do it. It’ll be slow and you’ll pay a lot and occasionally they’ll get creative.</p><p><strong>Will it replace LLMs?</strong> No. It cannot do the thing LLMs do. It doesn’t produce language. Asking whether Jev replaces ChatGPT is like asking whether a calculator replaces a lawyer.</p><p><strong>Will it take work away from LLMs?</strong> Oh, absolutely. There is a <em>staggering</em> amount of AI spend right now going toward tiny yes/no decisions dressed up as chat completions, and a lot of that is going to migrate.</p><p><strong>Is “decision model” now a permanent category?</strong> That’s the actually interesting bet, and I think yes. Jev is the loud first one, not the last one. It has $40M from DCVC behind it, a $200M valuation, and a founder — Diogo Almeida — who spent four years at OpenAI working on the RLHF research that became ChatGPT. He built the thing. Then he went and built the opposite of the thing.</p><h3>What I’d actually do with this information</h3><p>If you’re just learning about AI: the takeaway isn’t “new model dropped.” It’s that <strong>the field is starting to specialize.</strong> For three years the answer to every problem was “throw an LLM at it.” That era is ending, and that’s a sign of maturity, not disruption.</p><p>If you build things: go find the dumbest AI call in your product. The one that asks a frontier model a yes/no question and waits two seconds for the privilege. That’s the one. Input runs $0.042 per million tokens and output is free, so the math gets silly fast.</p><p>If you’re just here to sound informed at dinner: <em>“It’s not a chatbot, it’s a decision model — it doesn’t write text, it just picks from options you define, which is why it’s fast. It’s not replacing LLMs, it’s taking the boring jobs off them.”</em></p><p>That’s genuinely the whole thing.</p><h3>In Short</h3><p>Your chatbot is safe. Your thousand-calls-a-minute spam classifier, though? That one should be updating its résumé.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b245e1e8c8f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The End of AI Amnesia: An Introduction to Graphiti]]></title>
            <link>https://sarinbhaskaran.medium.com/the-end-of-ai-amnesia-an-introduction-to-graphiti-99b64e53e175?source=rss-d69e530e03c3------2</link>
            <guid isPermaLink="false">https://medium.com/p/99b64e53e175</guid>
            <category><![CDATA[context-management]]></category>
            <category><![CDATA[graphiti]]></category>
            <category><![CDATA[memory-management]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Sarin Bhaskaran]]></dc:creator>
            <pubDate>Tue, 08 Sep 2026 20:01:37 GMT</pubDate>
            <atom:updated>2026-09-08T20:01:37.796Z</atom:updated>
            <content:encoded><![CDATA[<p><em>In my ongoing exploration of AI memory architectures (</em><a href="https://medium.com/@sarinbhaskaran/my-ai-forgot-me-over-the-weekend-so-i-gave-it-a-brain-a-gbrain-abd9f073f63d"><em>see my article on GBrain</em></a><em>), I stumbled upon Graphiti. Here is my understanding of how it fits into the landscape, shared in hopes of saving you some research time.</em></p><p>Starting with a conversation with AI in January:</p><blockquote><strong>You:</strong> trying to go vegetarian this year, wish me luck</blockquote><blockquote><strong>App:</strong> Nice! Want some veg recipes?</blockquote><p>Solid. Ten out of ten. Now September, same app:</p><blockquote><strong>You:</strong> what should I order tonight?</blockquote><blockquote><strong>App:</strong> How about the Paneer Butter Masala? Great vegetarian option!</blockquote><blockquote><strong>You:</strong> I stopped being vegetarian in March. I’ve told you this four times.</blockquote><blockquote><strong>App:</strong> How about the Paneer Butter Masala? Great vegetarian option!</blockquote><p>This is the single most common way AI features disappoint people, and it isn’t because the model is dumb. GPT-5 could pass your engineering interview. It just has no idea what you told it last Tuesday, and — this is the interesting part — even when you <em>do</em> hand it your history, it often can’t tell which parts of that history are still true.</p><p>That second problem is the one this article is really about, because it’s the one that surprises people.</p><h3>Skip to the ending</h3><p>Here’s the same September conversation after wiring in a Memory Layer:</p><blockquote><strong><em>You:</em></strong><em> what should I order tonight?</em></blockquote><blockquote><strong><em>App:</em></strong><em> Since you went back to eating meat in March, want me to pull up your favourite Non-Vegetrarian Restaurant?</em></blockquote><blockquote><em>Also — heads up, if Mia’s joining, they use peanut oil.</em></blockquote><p>Nothing about the model changed. What changed is that something was sitting between the app and the model, and when the app asked <em>“what do I know about this person that’s relevant to dinner?”</em>, that something replied with three specific facts:</p><pre>Sia ── follows diet ──▶  Omnivore<br>        true since: 2026-03-14        (still true)</pre><pre>Sia ── follows diet ──▶  Vegetarian<br>        true from:  2026-01-05<br>        true until: 2026-03-14        ← retired, not deleted</pre><pre>Sia ── sister of ──▶  Mia<br>Mia ── allergic to ──▶  Peanuts</pre><p>Look at what’s happening in that block. There are two contradictory diet facts stored at the same time, and the system is completely relaxed about it, because each one carries the dates it was true. The old one didn’t get overwritten. It got a closing date.</p><p>That’s Graphiti. Everything else in this article is me explaining how that block gets built and why the date stamps are the whole ballgame.</p><p>The rest of this is structured around the questions people actually ask me when I show them this, roughly in the order they ask them.</p><h3>“Wait — why can’t the AI just remember on its own?”</h3><p>Because language models are <strong>stateless</strong>. Every API call starts from zero. There is no session, no yesterday, no “as we discussed.” The illusion of a continuing conversation exists because your app re-sends the entire chat history on every single request.</p><p>That trick works great, right up until it doesn’t:</p><p><strong>The context window fills up.</strong> There’s a hard cap on how much text you can send in one request. Long conversations eventually hit it. Then what — drop the oldest messages? Sure, and now you’ve dropped the important part, because the important part is usually old.</p><p><strong>You pay for it repeatedly.</strong> You’re billed per token. Re-sending 500 messages on every turn means paying for those same 500 messages hundreds of times.</p><p><strong>Quality actually gets worse.</strong> This one’s counterintuitive and well-documented. Bury one crucial sentence in the middle of a huge wall of text and models get noticeably worse at finding it. The research nickname is “lost in the middle.” You’ll experience it as <em>“why is it ignoring what I literally just said.”</em></p><p>So you can’t send everything. You have to choose what to send. That choice — deciding what goes into a limited window on any given request — has a name now: <strong>context engineering</strong>. Long-term memory is just a good strategy for making that choice.</p><p>The obvious first strategy is to summarize the old stuff. Compress the last ten conversations into a paragraph, keep the paragraph. And that works, sort of, except compression is lossy and the summarizer has no idea which detail is going to matter in six months. Your summary comes out as <em>“user enjoys food and travel, prefers short answers,”</em> and the vegetarian thing has quietly evaporated. Do it again next month and you’re summarizing a summary. Photocopy of a photocopy.</p><h3>“Isn’t this what vector databases are for?”</h3><p>Yes! And this is genuinely the right next step, so let’s make sure the machinery is clear, because Graphiti sits on top of it rather than replacing it.</p><p>The approach is called <strong>RAG</strong> — Retrieval-Augmented Generation. Instead of sending everything, you store everything and fetch back only the relevant bits.</p><p>Here’s how RAG works in four steps:</p><ol><li><strong>Chunk</strong> — chop your text into small pieces.</li><li><strong>Embed</strong> — run each piece through an embedding model, which converts text into a list of numbers called a <strong>vector</strong>. The clever bit: the model places vectors so that things with similar <em>meaning</em> end up close together in space.</li><li><strong>Store</strong> — keep those vectors in a <strong>vector database</strong>.</li><li><strong>Retrieve</strong> — when a question comes in, embed the question too, and grab the chunks whose vectors sit nearest to it.</li></ol><p>The payoff is search by <em>meaning</em> rather than by <em>keyword</em>. “I don’t eat meat” and “I’m a vegetarian” share almost no words, but they land as neighbors. Your old LIKE &#39;%vegetarian%&#39; query could never.</p><p>Now the problem. Both of Sia’s messages are in there:</p><ul><li>January: <em>“trying to go vegetarian this year”</em></li><li>March: <em>“gave up on the vegetarian thing, had chicken last night”</em></li></ul><p>Ask “what does Sia eat?” and vector search does exactly its job: it returns <strong>both</strong>, because both are outstanding matches for the question. It has no opinion about which one still applies. Neither does the model receiving them. So the model picks one — coin flip — or does that thing where it splits the difference and tells you you’re <em>“a vegetarian who occasionally eats chicken,”</em> which is not a diet, that’s just being conflicted.</p><p>Here’s the sentence I’d like you to take away from this whole article:</p><p><strong>Vector search is very good at finding what’s relevant. It has no concept of what’s been replaced.</strong></p><p>And an enormous amount of what we know about people and businesses is exactly the stuff that gets replaced. Job titles. Cities. Prices. Subscription tiers. Who owns which service. Who’s on call. Who still works here.</p><p>A memory system doesn’t just need to recall things. It needs to be able to <strong>change its mind</strong>, and to know when it did.</p><h3>“Fine. So what does Graphiti store instead?”</h3><p>Three kinds of thing. Let’s take them one at a time, with the smallest useful examples I can manage.</p><h3>Episodes — the receipts</h3><p>An <strong>episode</strong> is one raw input, saved exactly as it arrived. A chat message. A support ticket. A meeting transcript. A JSON row from your CRM.</p><p>Episodes are the bottom layer of truth. Everything else Graphiti builds is <em>derived</em> from them, and every derived thing remembers which episode it came from. That’s called <strong>provenance</strong>, and it’s the difference between an AI you can debug and an AI you have to take on faith. When your assistant says something strange, you can ask “which input made you believe that?” and get an actual answer.</p><p>Graphiti accepts three flavors: text for prose, message for conversational turns like &quot;user: hello&quot;, and json for structured records.</p><p>Don’t skim that last one. It means your memory isn’t built only from chat. You can pour in your real business data — orders, tickets, subscriptions — and it lands in the same graph, attached to the same people. Your conversation history and your system of record stop being two separate worlds.</p><h3>Entities — the nouns</h3><p>An <strong>entity</strong> (also called a <strong>node</strong>) is a thing worth tracking. A person, a company, a product, a city, a concept.</p><p>Simplest way to think about it: entities are the nouns in your data. Sia. Mia. Peanuts. Chicago.</p><p>The part that’s harder than it looks is making sure “Sia,” “Sia S.,” “sia.superstar@…” and “she” all resolve to <strong>one</strong> entity instead of four. That’s <strong>entity resolution</strong>, and it’s where a lot of homegrown memory systems quietly rot — you end up with eleven slightly different versions of the same customer and no idea which one is real.</p><p>Each entity also keeps a running <strong>summary</strong> that grows as more episodes mention it. Sia’s node slowly accumulates a description of Sia.</p><h3>Facts — the sentences</h3><p>A <strong>fact</strong> (or <strong>edge</strong>) connects two entities with a labelled relationship. Formally it’s a <strong>triplet</strong>: subject → relationship → object.</p><ul><li>Sia → LIVES_IN → Chicago</li><li>Sia → SISTER_OF → Mia</li><li>Mia → ALLERGIC_TO → Peanuts</li></ul><p>If entities are nouns, facts are short sentences.</p><p>Why bother with this shape instead of just storing the text? Because it makes <em>connections</em> queryable. Consider the question <strong>“does anyone in Sia’s family have a food allergy?”</strong> With text chunks, that’s hopeless — no single chunk contains the answer. It’s spread across two different messages from two different months.</p><p>On a graph it’s a short walk: start at Sia, follow the family relationship, then follow the allergy relationship. Two hops, answer found. That’s <strong>graph traversal</strong>, and it’s how you answer questions whose answer doesn’t exist in any one place. Vector search fundamentally cannot do this. It can only find you things that <em>look like</em> your question.</p><h3>“How does it know a fact has expired?”</h3><p>This is the bit that makes Graphiti different from everything else in the space, so let’s go slow.</p><p>Every fact tracks <strong>two separate kinds of time</strong>. The word for this is <strong>bi-temporal</strong>, which sounds like a physics lecture and means something almost embarrassingly simple:</p><p><strong>When the thing was true in the real world.</strong> In the code: valid_at and invalid_at.</p><p><strong>When your system found out about it.</strong> In the code: created_at and expired_at.</p><p>Two clocks. <em>Event time</em> and <em>ingestion time</em>. Once you notice the difference you’ll see it everywhere.</p><p>Say Sia tells you today: <em>“oh by the way, I moved to Chicago last April.”</em></p><p>A one-clock system writes down “moved to Chicago: today.” Which is just false, and it’ll keep being false forever. Graphiti writes down that the move happened in April, and separately, that you learned about it today. Both are real facts. They answer different questions.</p><p>That second clock is what makes these answerable:</p><ul><li><em>“What did our system believe about this customer’s plan on the day we billed them?”</em></li><li><em>“When did we first learn about this risk?”</em></li><li><em>“Given what the agent knew at the time, was its recommendation reasonable?”</em></li></ul><p>If you’ve ever worked anywhere near finance, insurance, healthcare, or an auditor, you know that last question isn’t academic. “What did you know and when did you know it” is frequently the entire dispute. Most memory systems can’t answer it at all.</p><p>Now the other half. When a new episode contradicts an existing fact, Graphiti doesn’t delete the old one. It <strong>invalidates</strong> it — stamps a closing date on it and writes a new fact alongside. Nothing is destroyed. The graph keeps a complete record of its own changing mind.</p><p>Two comparisons to make that concrete, because you already know both of these systems:</p><p><strong>Compare it to a normal SQL update.</strong> UPDATE users SET diet = &#39;omnivore&#39; is an act of destruction. The previous value is gone, and worse, the database will now cheerfully insist it never thought otherwise. You cannot ask it what Sia ate in February. That information doesn&#39;t exist anymore.</p><p><strong>Compare it to git.</strong> Git doesn’t overwrite your file when you change a line. It records that the line changed, when, and by whom — and lets you check out any point in history. Graphiti is doing that for facts about the world instead of lines of code.</p><p>And if you want the version built by humans, for humans, long before any of this: <strong>a medical record.</strong> Nobody erases “patient was on 10mg” when the dose changes. You write the new dose with a date and the old one stays legible forever, because <em>when</em> something was true is clinically essential. Graphiti applies that same discipline to your app’s memory.</p><h3>“Who decides what counts as an entity?”</h3><p>An LLM does, during ingestion. And this is the single most important operational thing for a beginner to understand, so I’m going to be blunt about it:</p><p><strong>The LLM isn’t only working when you ask a question. It’s working hardest when you write.</strong></p><p>Every time you add an episode, Graphiti runs several model calls behind the scenes: pull out the entities, check whether each one already exists, extract the facts, decide whether any of them contradict what’s already stored, refresh the affected summaries.</p><p>That’s why writing to Graphiti costs real money and takes seconds rather than milliseconds. Compare it to a vector database, where a write is one cheap embedding call and you’re done. This one difference shapes almost every practical decision you’ll make, and it’s the main thing in the fine print later on.</p><p>By default Graphiti works out entity and relationship types from your data on its own — that’s called <strong>learned ontology</strong>, and it’s a fine way to start. Dump data in, see what shows up.</p><p>Once you know your domain, though, you can tell it exactly what to look for using <strong>Pydantic models</strong>, which are just Python classes describing a shape. Graphiti calls this <strong>prescribed ontology</strong>:</p><pre>from pydantic import BaseModel, Fieldclass Customer(BaseModel):<br>    &quot;&quot;&quot;A person who buys from us.&quot;&quot;&quot;<br>    industry: str | None = Field(None, description=&quot;Industry they work in&quot;)<br>    plan_tier: str | None = Field(None, description=&quot;free, pro, or enterprise&quot;)class Product(BaseModel):<br>    &quot;&quot;&quot;Something we sell.&quot;&quot;&quot;<br>    category: str | None = Field(None, description=&quot;Product category&quot;)</pre><p>Hand them over when you add an episode and the extraction suddenly has guardrails. Instead of the model inventing thirty vague, overlapping node types across your dataset, it’s filling in a form you designed. You can go further and restrict which relationships are even permitted between which types — a manager can MANAGES a person, but a person shouldn&#39;t be able to MANAGES a city.</p><p>If you’ve ever added a database constraint after being burned by dirty data, it’s the same instinct, applied to an LLM.</p><h3>“How do I get things back out?”</h3><p>Graphiti doesn’t pick one retrieval strategy. It runs three and combines them — hence <strong>hybrid search</strong>.</p><p><strong>Semantic search</strong> (those vector embeddings) catches meaning. “What does she eat?” finds “follows a vegetarian diet” with zero shared words.</p><p><strong>Keyword search</strong> catches exact strings, using <strong>BM25</strong> — the classic full-text ranking algorithm that powered search engines long before embeddings were fashionable. This exists because embeddings are genuinely bad at identifiers. ERR-4021 and ERR-4012 are practically identical in vector space and completely unrelated in real life. Same for order IDs, SKUs, and surnames.</p><p><strong>Graph traversal</strong> catches structure — start from a node you care about and walk outward.</p><p>Then a <strong>reranker</strong> merges those separate result lists into one sensible order. Graphiti ships a few, and you’ll see their names in the code:</p><ul><li><strong>RRF</strong> (Reciprocal Rank Fusion) — a cheap, fair way to blend multiple ranked lists. Your default.</li><li><strong>MMR</strong> (Maximal Marginal Relevance) — deliberately favours <em>variety</em>, so you don’t get five results that all say the same thing in different words.</li><li><strong>Cross-encoder</strong> — a slower, smarter model that reads the query and the result together and scores the pair properly.</li><li><strong>Node distance</strong> — boosts results sitting close to a node you nominate. If the conversation is about Sia, facts near Sia’s node should win. Small feature, surprisingly large effect on relevance.</li></ul><p>Two more retrieval-adjacent things worth knowing early:</p><p>group_id partitions the graph. One per user, one per tenant, one per project. This is your isolation story and you want to decide it on day one, because &quot;customer A&#39;s memory showed up in customer B&#39;s answers&quot; is a genuinely terrible Monday.</p><p><strong>Communities</strong> are what you get from build_communities(), which clusters tightly-connected entities and writes a summary per cluster. It gives you the zoomed-out view — not &quot;what did Sia say on Tuesday&quot; but &quot;what&#39;s the overall shape of this account.&quot; Nice to have. Not where you start.</p><h3>Mixing in your real data</h3><p>Same function, JSON payload:</p><pre>import json<br><br>await graphiti.add_episode(<br>    name=&quot;crm-snapshot&quot;,<br>    episode_body=json.dumps({<br>        &quot;customer&quot;: &quot;Sia S&quot;,<br>        &quot;city&quot;: &quot;Chicago&quot;,<br>        &quot;plan&quot;: &quot;enterprise&quot;,<br>        &quot;renewal_date&quot;: &quot;2027-03-01&quot;,<br>    }),<br>    source=EpisodeType.json,<br>    source_description=&quot;Salesforce export&quot;,<br>    reference_time=datetime.now(timezone.utc),<br>    group_id=&quot;sia&quot;,<br>)</pre><p>Sia-from-the-chat and Sia-from-Salesforce become the <strong>same node</strong>. For a lot of teams that single property is the reason to look at this at all.</p><h3>When you need more control</h3><p>graphiti.search() is the friendly front door and hands back facts. When you want nodes, filters, and control over reranking, there&#39;s search_() with prebuilt configs the codebase calls &quot;recipes&quot;:</p><pre>from graphiti_core.search.search_config_recipes import NODE_HYBRID_SEARCH_RRF</pre><pre>config = NODE_HYBRID_SEARCH_RRF.model_copy(deep=True)<br>config.limit = 5</pre><pre>results = await graphiti.search_(query=&quot;Chicago customers&quot;, config=config)</pre><pre>for node in results.nodes:<br>    print(node.name, &quot;|&quot;, node.summary)</pre><p>Start with search(). Graduate to search_() when relevance starts mattering more than convenience.</p><h3>The fine print</h3><p>I’d rather you trust me than be excited, so here’s the honest list. A few of these will decide whether this is right for you at all.</p><p><strong>Remembering costs money.</strong> Several LLM calls per episode, every episode. Ingesting a large backlog is a real project with a real invoice attached. Estimate it before you promise it.</p><p><strong>It’s not instant.</strong> Per-episode ingestion is seconds, not milliseconds. Don’t put it in a user-facing request path — write asynchronously, in a background job.</p><p><strong>You will meet HTTP 429.</strong> Because ingestion is model-heavy, rate limits arrive sooner than expected. Graphiti ships with concurrency deliberately throttled (SEMAPHORE_LIMIT, default 10) for exactly this reason. If it feels slow, that&#39;s the dial — but your provider&#39;s quota is on the other end of it.</p><p><strong>Your extractor can be wrong, and its mistakes become your data.</strong> The LLM can miss facts, invent relationships nobody stated, merge two different Johns into one node, or split one person into three. Graphiti works hard against this; hard is not the same as solved. Actually look at your graph early and often.</p><p><strong>It needs a genuinely capable model.</strong> Extraction depends on reliable structured JSON output. OpenAI, Anthropic, and Gemini handle it well. Small local models frequently emit JSON that doesn’t match the requested schema, which shows up as silent extraction failures. If the plan is “run this entirely on a 7B model on my laptop,” adjust expectations before you start, not after.</p><p><strong>You just adopted a database.</strong> Neo4j or FalkorDB is now yours to run, back up, index, and think about at 3am. Not exotic, but it’s operational surface you didn’t have yesterday.</p><p><strong>Reads aren’t free either.</strong> Hybrid search plus reranking has latency, and cross-encoder reranking has more of it. Typically sub-second, which is fine — but it’s not a key-value lookup, so measure it against your budget rather than assuming.</p><p><strong>Forgetting is harder than remembering.</strong> Think about GDPR for a moment. A user asks to be erased. You delete their episodes, but facts derived from those episodes may have merged into shared entities, altered summaries, and shaped community groupings. Graphiti does cascade-delete facts that came solely from a deleted episode, which is more than most systems offer — but “un-bake this cake” is a hard problem in <em>any</em> derived-data system. Handling regulated personal data? Design for this on day one, not after legal calls.</p><p><strong>It won’t quote your PDF.</strong> If the requirement is “answer questions about this 400-page contract and cite the exact clause,” you want chunks and vectors, not an entity graph. Graphiti extracts <em>facts about things</em>; it isn’t preserving prose for verbatim citation. Different tool, different job — plenty of real systems run both side by side.</p><p><strong>The learning curve is real.</strong> Bi-temporality, entity resolution, ontology design, reranker choice. And when output looks wrong, debugging means staring at a graph asking “why did it extract <em>that</em>?”, which is a genuinely new skill. Give yourself a couple of weeks.</p><p><strong>The project moves fast.</strong> Graphiti is young and actively developed. Mostly good news, but pin your versions and read the release notes, because APIs still shift.</p><p><strong>And the unglamorous one: you may not need this.</strong> If your app is three CRUD endpoints and a bot answering from a static FAQ, this is enormous overkill. Use a system prompt and a vector store and go home early.</p><h3>One clarification: Graphiti vs Zep</h3><p>You’ll run into both names, so, briefly.</p><p><strong>Graphiti</strong> is the open-source Python framework. Bring your own graph database, build your own user and conversation handling, operate it all yourself, get total control. Free and flexible.</p><p><strong>Zep</strong> is the commercial managed platform built on the same ideas, running on a purpose-built graph engine, with users and threads, a dashboard, SDKs in several languages, and support. Their published figures put retrieval under 200ms at scale.</p><p>Usual trade-off: Graphiti if you want the OSS core and are happy running the surrounding system, Zep if you’d rather pay to make the operational burden someone else’s problem. There’s also a paper — <em>Zep: A Temporal Knowledge Graph Architecture</em> (arXiv 2501.13956) — and it’s a readable one if you want the reasoning behind the design.</p><h3>The cheat sheet</h3><p>Every term in this article, one line each. Bookmark this bit; it’s the part I’d have wanted on day one.</p><p><strong>Stateless</strong> — the model remembers nothing between calls. Everything else here exists because of this.</p><p><strong>Context window</strong> — the hard cap on how much text you can send in one request.</p><p><strong>Context engineering</strong> — deciding what to put in that limited window. The actual job.</p><p><strong>Embedding / vector</strong> — text converted to numbers, positioned so similar meanings sit close together.</p><p><strong>Chunk</strong> — a small piece of text you embed and store.</p><p><strong>RAG</strong> — Retrieval-Augmented Generation. Fetch relevant text, add it to the prompt.</p><p><strong>Episode</strong> — one raw input as it arrived. Chat message, ticket, transcript, JSON row.</p><p><strong>Entity (node)</strong> — a thing being tracked. The nouns.</p><p><strong>Fact (edge)</strong> — a labelled relationship between two entities. The short sentences.</p><p><strong>Triplet</strong> — the shape of a fact: subject → relationship → object.</p><p><strong>Provenance</strong> — every derived fact remembers which episode produced it.</p><p><strong>Entity resolution</strong> — recognising that “Sia,” “Sia S.” and “she” are one entity, not three.</p><p><strong>Bi-temporal</strong> — tracking two clocks per fact: when it was true, and when you learned it.</p><p>valid_at<strong> / </strong>invalid_at — clock one. When the fact was true in the real world.</p><p>created_at<strong> / </strong>expired_at — clock two. When your system knew about it.</p><p><strong>Invalidation</strong> — closing out a superseded fact instead of deleting it.</p><p><strong>Ontology</strong> — the set of entity and relationship types. <em>Learned</em> if inferred from data, <em>prescribed</em> if you define it with Pydantic models.</p><p><strong>Graph traversal</strong> — walking from node to node to answer questions no single record contains.</p><p><strong>Hybrid search</strong> — combining semantic, keyword, and traversal search instead of picking one.</p><p><strong>BM25</strong> — the classic keyword ranking algorithm. Catches exact IDs that embeddings fumble.</p><p><strong>Reranker</strong> — merges multiple result lists into one order. RRF blends fairly, MMR pushes for variety, cross-encoder scores query-and-result together, node distance favours results near a node you nominate.</p><p>group_id — partitions the graph. Per user, per tenant, per project.</p><p><strong>Community</strong> — a cluster of tightly-connected entities with its own summary. The zoomed-out view.</p><p><strong>MCP server</strong> — lets AI tools like Cursor use Graphiti as persistent memory across sessions.</p><p>You’ll get two facts back. One with a closing date, one without, neither deleted. You didn’t write a single line of logic to make that happen. You told it two things at two different times and it figured out the world had moved on.</p><p>Then go find the last place your product confidently told a user something that stopped being true months ago — and imagine it having had a date to check.</p><p><em>If this was useful, I’d genuinely like to know which explanation landed best. I’m still hunting for the perfect way to describe bi-temporality to someone on day one. And if you’re building something interesting on Graphiti, tell me about it in the comments.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99b64e53e175" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My AI Forgot Me Over the Weekend, So I Gave It a Brain- A GBrain]]></title>
            <link>https://sarinbhaskaran.medium.com/my-ai-forgot-me-over-the-weekend-so-i-gave-it-a-brain-a-gbrain-abd9f073f63d?source=rss-d69e530e03c3------2</link>
            <guid isPermaLink="false">https://medium.com/p/abd9f073f63d</guid>
            <category><![CDATA[memory-management]]></category>
            <category><![CDATA[gbrain]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[ai-memory]]></category>
            <dc:creator><![CDATA[Sarin Bhaskaran]]></dc:creator>
            <pubDate>Wed, 26 Aug 2026 20:37:19 GMT</pubDate>
            <atom:updated>2026-08-26T20:37:19.190Z</atom:updated>
            <content:encoded><![CDATA[<p>I spent a Friday afternoon explaining my codebase to an AI.</p><p>The full tour. I told it that orders_v2 is the real orders table and orders is a haunted table nobody is brave enough to drop. I told it we retry payment webhooks three times, not five, and there&#39;s a good reason for that. I told it Justin owns webhooks now because Marcus moved teams.</p><p>By 5pm it was genuinely useful. It stopped inventing a TaxService we&#39;ve never had.</p><p>Monday morning, same tool:</p><p>“Hello! How can I help you today?”</p><p>Cool. Cool cool cool. Let me get my slides out again.</p><p>If you’re new to this, that feels like a bug you should report. It isn’t. And understanding why it happens explains a whole category of tools built to fix it. This is about one of them, <strong>gbrain</strong>, though the ideas matter more than the tool.</p><p>No prior knowledge needed. If you know what a text file is, you’re qualified.</p><h3>In fairness, the AI never promised to remember</h3><p>The model has two kinds of knowledge, and neither one is your job.</p><p>The first is everything it absorbed during training, baked into billions of numbers. It’s why it knows Python and HTTP. But training finished, the numbers froze, and it has learned nothing since. It’s the brilliant graduate who read the entire library then immediately stopped reading. Ask about <em>your</em> payment service and it’ll either say nothing useful or confidently invent something plausible.</p><p>The second is the <strong>context window</strong>: everything in the current conversation. This part is impressive. It’ll hold your file, your stack trace and your last twenty messages and reason across all of it.</p><p>But it’s a whiteboard. Great during the meeting, wiped after.</p><p>So Friday wasn’t teaching. It was writing on a whiteboard that a very thorough cleaner visits nightly. There’s no notebook, no filing cabinet. Adding that missing filing cabinet is what people mean by <strong>long-term memory</strong>.</p><h3>What everyone tries first</h3><p>You paste more stuff in. Works for a day, then you’re doing it every time, paying for those tokens on every message, and eventually it doesn’t fit. There’s a sneaky failure here too: stuff a huge amount of text into a context window and models attend closely to the start and end while going vague in the middle. Researchers call it “lost in the middle,” which is also how I’d describe my train of thought in every meeting.</p><p>Then you write a rules file — a CLAUDE.md or Cursor rules. Good idea, do it, but it&#39;s a sticky note on your monitor. Fine for &quot;always use our linter,&quot; useless for three years of architectural decisions. Mine hit 400 lines and became a document everyone added to and nobody read.</p><p>Then you point it at a wiki, which humans can search but an AI can’t meaningfully use, because handing a model 900 pages is the first problem again. Also, gently: your wiki is lying to you. Half of it was accurate in 2023.</p><p>Then you reach for a vector database and chunk everything up. Real progress — this is the core of what people call RAG — but it’s a very literal-minded librarian. It finds pages that <em>sound</em> like your question. It can’t tell you who believed what, what depends on what, or that the thing it just handed you was superseded in March.</p><p>gbrain is roughly stage five: keep the search, add everything that was missing.</p><h3>So what is gbrain?</h3><p><strong>A memory that lives outside the AI, made of markdown files, that any assistant can search and cite.</strong></p><p>You write pages. gbrain indexes them, links them, extracts claims, and exposes lookup tools. Your assistant stops guessing and starts checking.</p><p>The part I liked immediately: the source of truth is markdown on disk. Not a proprietary blob, not a cloud account you’re locked into. Files. You can read them, git diff them, review them in a PR, delete them when they&#39;re wrong.</p><pre>---<br>type: service<br>owner: justin<br>---</pre><pre># PaymentService</pre><pre>Handles card and wallet payments at checkout.<br>Retries failed webhooks 3 times with exponential backoff.<br>Depends on OrderService and the Stripe API.</pre><pre>## Timeline<br>- 2025-03-14: Retries cut from 5 to 3 after duplicate<br>  charges. [Source: postmortem INC-204]<br>- 2025-09-10: Marcus handed ownership to Justin.<br>  [Source: standup]</pre><h3>The trick is the line in the middle</h3><p>The top is what you believe <strong>right now</strong>. When reality changes, you rewrite it. gbrain calls it the <em>compiled truth</em>, which just means “the cleaned-up current answer.”</p><p>The bottom is the <strong>timeline</strong>. Dated entries, each citing a source. You never edit these, you only add.</p><p>Wikipedia does exactly this. The article says what’s true today; the revision history says how we got here and who to blame. Or a patient’s chart: summary clipped to the front, visit notes behind it.</p><p>Most documentation gives you only the top half. Which is fine until you actually need help, because then the question is never “what does this service do.” It’s “why does it do it <em>that</em> way.”</p><p>Three retries looks arbitrary. Three retries <em>because five caused duplicate charges in INC-204</em> is different information entirely. One is trivia. The other stops you “fixing” it next quarter.</p><h3>How it finds things without reading everything</h3><p><strong>It cuts pages into index cards.</strong> A 3,000-word page is useless as one lump, so gbrain slices pages into <strong>chunks</strong> of a few hundred words, slightly overlapping so a sentence on the boundary isn’t orphaned.</p><p><strong>It gives every card a location based on meaning.</strong> An <strong>embedding</strong> is a list of numbers representing what text <em>means</em>.</p><p><strong>It also does boring keyword search, on purpose.</strong> Meaning-based search has one annoying blind spot: precision. Ask for the function calculateTaxRate and it may hand you <em>tax calculation as a general concept</em> — adjacent, useless. Keyword search nails exact names and is hopeless at vague questions.</p><p>So gbrain runs both and merges them. Two librarians: one a stickler for exact titles, one who knows what the books are about. Anything they <em>both</em> rank highly is almost certainly what you wanted.</p><p><strong>And it knows how things connect.</strong> Search finds documents resembling your question. But the question engineers ask most is <em>“if I change this, what breaks?”</em> — and no single document answers that. It lives in the relationships, so gbrain stores typed links:</p><pre>OrderService     --depends_on--&gt;    PaymentService<br>PaymentService   --depends_on--&gt;    StripeAPI<br>PaymentService   --owned_by--&gt;      Justin<br>INC-204          --affected--&gt;      PaymentService</pre><p>LinkedIn connections, except each one is labelled. And you can walk it: start at StripeAPI, hop back twice, and learn that a Stripe outage reaches OrderService and Justin is the one to wake at 3am. Nobody wrote that sentence. The graph worked it out.</p><h3>The bit that actually matters: it knows who said it</h3><p>Memory has a temperature, and your own desk has both kinds.</p><p><strong>Sticky notes on the monitor.</strong> “Standup moved to 10.” “Justin’s out Thursday.” Urgent, disposable, correctly forgotten within a week. gbrain calls these <em>facts</em>.</p><p><strong>The binder on the shelf.</strong> Architecture decisions, postmortems, reasoning behind a choice made two years ago. Slow, durable, valuable <em>because</em> it’s old. gbrain calls these <em>takes</em> — and takes record who believes what:</p><pre>holder: justin   kind: take   &quot;the retry logic is flaky&quot;     0.60<br>holder: world    kind: fact   &quot;the build fails on Node 18&quot;   1.00<br>holder: marcus   kind: bet    &quot;we&#39;ll need sharding by Q3&quot;    0.45</pre><p>“The retry logic is flaky” is <em>not a fact about the universe</em>. It’s Justin’s opinion, held with moderate confidence. “The build fails on Node 18” is checkable regardless of who says it.</p><p>Mush those into one flat list and your new hire gets told “the retry logic is flaky,” full stop, as though it were physics. Keep the attribution and they get “Justin suspects the retry logic is flaky” — a far more useful sentence, because it hands over both the concern and the person to talk to.</p><p>Most tools throw this away. So does most documentation. We write “the service is slow” when we mean “Marcus said it felt slow, once, in April, before the caching change.”</p><h3>It sleeps. I’m not joking.</h3><p>There’s a command called gbrain dream and I refuse to pretend I didn&#39;t find that delightful.</p><p>While you sleep, your brain replays the day and files parts of it into long-term storage. It’s why cramming until 4am works worse than studying then sleeping. Same job here: a cycle runs overnight, promotes the sticky notes that turned out to matter into the binder with proper attribution, collapses duplicates, draws new links, and flags contradictions for a human to referee.</p><p>Skip this and you don’t have a memory. You have a junk drawer with really good search.</p><h3>How your editor talks to it</h3><p><strong>MCP</strong> (Model Context Protocol) is an open standard for plugging assistants into outside tools. Everyone compares it to USB-C and the comparison earns its keep: one port, everything fits.</p><p>gbrain runs as an MCP server offering a few tools — search, fetch a page, recall a fact, walk the graph. Your editor plugs in. Your memory isn’t trapped in one vendor’s chat app; switch assistants next year and the brain comes with you.</p><h3>Watching it work</h3><p>A new joiner, six days in, asks the question I opened with: <em>“Why do we retry payment webhooks three times?”</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1bw8gmrXvE2oeukQexX8KQ.png" /></figure><p>What comes back isn’t a vibe:</p><blockquote>Three retries, set on 2025–03–14. It used to be five, but incident INC-204 traced duplicate customer charges to the extra attempts. Justin owns this service and has an open concern that the retry logic is still flaky. Sources: PaymentService page, postmortem INC-204.</blockquote><p>Six days of tenure, and they have the reasoning, the incident, the owner, a concern to tread carefully around, and two links to check it themselves.</p><p>Before, that answer lived in exactly one place: Marcus’s head. And Marcus moved teams.</p><h3>Where this earns its keep</h3><p><strong>Onboarding.</strong> The first month anywhere is archaeology. A team brain turns a chunk of that into an evening of questions to something that never sighs.</p><p><strong>3am incidents.</strong> “Have we seen this before?” is the most valuable question in ops and the one humans answer worst under adrenaline.</p><p><strong>Legacy archaeology.</strong> 200,000 lines, original authors gone. The code says what it does; a brain built from commits and old arguments is your only shot at why.</p><p><strong>Anywhere audited.</strong> When someone asks why a system behaves a certain way, “I think Marcus decided that” isn’t an answer. Dated, cited reasoning is.</p><h3>Its not perfect — Somethings to remember before considering gbrain</h3><p><strong>It repeats your mistakes with total confidence.</strong> Store a wrong assumption and you’ve built a machine that recites it to every new hire forever, with citations. Citations make wrong things <em>more</em> convincing.</p><p><strong>Stale memory is worse than none.</strong> If nobody trusts it, they ask a human — annoying but safe. If they trust it and it’s six months old, they’ll ship the wrong thing cheerfully.</p><p><strong>Retrieval isn’t understanding.</strong> It returns the top few matches. If the crucial page ranked eleventh, it may as well not exist, and nothing tells you that happened. Treat answers as good leads and click the sources.</p><p><strong>Privacy gets a blast radius.</strong> One searchable index of everything your team knows, including the API key someone pasted into a channel in 2022 — now semantically searchable. Decide what’s allowed in before you index.</p><p><strong>It costs money and adds latency.</strong> Embedding is cheap per chunk and expensive in bulk. Every query does an embed, two searches and a merge before the model opens its mouth.</p><p><strong>You just adopted a production system.</strong> Database, indexes, background jobs, backups. If nobody owns it, it rots in a quarter.</p><p><strong>Automatic extraction mixes up who said what.</strong> The classic failure turns “Marcus thinks Justin’s caching approach is risky” into <em>Justin</em> believing something. Wrong attribution is worse than none.</p><p>And the boring, important one: this doesn’t replace tests, readable code, or talking to Justin. It’s an amplifier — it makes a team with decent habits sharper, and a team with bad habits faster at being wrong.</p><p>If your project is a README and three files, you don’t need this. A good rules file is plenty.</p><h3>Try it tonight</h3><p>Ten pages, not ten thousand.</p><ol><li>Pick one service you know well. Write ten small markdown pages: the service, a couple of dependencies, one decision, one incident. Current understanding on top, dated timeline underneath.</li><li>Install gbrain, point it at that folder, sync. <em>(TODO: verify link — drop the current install command in before publishing.)</em></li><li>Connect it to your editor over MCP and ask the questions a new joiner would ask.</li><li>Then change something — cut retries from 3 to 2 in the compiled truth, add a timeline entry, sync again, ask again. The answer should move.</li></ol><p>Judge it on one question: <strong>did it cite something real, and was the citation right?</strong></p><p>If yes, the rest is an engineering problem. If no, you’ve learned something more valuable than the tool: the hard part was never the vector database. It was the writing.</p><h3>One last thought</h3><p>Almost everyone right now is focused on making models smarter, and I’m glad they are.</p><p>But smart was never my bottleneck. I don’t need my assistant to be a genius. I need it to remember that we tried the five-retry thing already, it went badly, and Justin still isn’t happy about it.</p><p>A brilliant engineer who forgets everything each morning is less useful than an average one who remembers your system. True of people, turns out it’s true of tools.</p><p>Anyway — my AI knows who Justin is now. Small win. I’ll take it.</p><p><em>If you found this useful, I’d love to know which analogy landed best. And if you’re using something like this for something interesting, tell me in the comments.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abd9f073f63d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What If Your Code Could Sleep for 90 Days? A Beginner’s Guide to the Tool of the year : Temporal.io]]></title>
            <link>https://sarinbhaskaran.medium.com/what-if-your-code-could-sleep-for-90-days-a-beginners-guide-to-the-tool-of-the-year-temporal-io-d3ee618f74c9?source=rss-d69e530e03c3------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3ee618f74c9</guid>
            <category><![CDATA[temporal]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[stateful]]></category>
            <category><![CDATA[cronjob]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Sarin Bhaskaran]]></dc:creator>
            <pubDate>Mon, 24 Aug 2026 18:27:26 GMT</pubDate>
            <atom:updated>2026-08-24T18:27:26.909Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Everything I wish someone had told me before I wrote my first workflow.</em></p><p>Let me start with a small feature request. It sounds trivial. It is not.</p><blockquote>“If a user hasn’t logged in for 60 days, send them a warning email. At 83 days, send another one. At 90 days, deactivate their account. Oh, and if they log in at any point, reset the clock.”</blockquote><p>Read that again. It’s four lines of business logic. Any junior developer could write it as pseudocode in thirty seconds:</p><pre>wait 60 days<br>send warning<br>wait 23 more days<br>send warning<br>wait 7 more days<br>deactivate account</pre><p>Now try to actually build it.</p><h3>The way we’ve always done it (and why it hurts)</h3><p>You can’t literally write sleep(60 days) in your code. Your process will get redeployed on Tuesday. The pod will be rescheduled. Someone will restart the server. Your sleep dies and takes the user&#39;s state with it.</p><p>So instead, we do the dance we’ve all done. It goes something like this:</p><p>You add columns to the users table: last_login_at, warning_1_sent_at, warning_2_sent_at, deactivated_at. Then you write a cron job that runs every hour, scans the whole table, and asks &quot;who crossed 60 days since we last checked?&quot; Then you add a check so you don&#39;t email the same person twice.</p><p>Then someone points out the email service returns a 503 sometimes, so you add a retry. Then the retry runs twice and a user gets two emails, so you add an idempotency key. Then the cron job crashes halfway through a 2-million-row scan, and now you need to know where it stopped, so you add a last_processed_id. Then a user logs in and you have to remember to clear all the warning columns, and you forget in one code path, and a perfectly active customer gets deactivated on a Friday night.</p><p>Six months later, the “four lines of business logic” is 800 lines of code spread across a cron scheduler, four database columns, a retry helper, a dead letter queue, and a Slack alert that fires at 3 a.m.</p><p>And here’s the part that should bother you: <strong>ALMOST NONE OF THAT CODE IS ABOUT YOUR BUSINESS.</strong> It’s all plumbing. It’s state management, retry logic, and crash recovery. You wrote a lot of code to protect your application from the fact that computers restart.</p><p>Temporal deletes that plumbing.</p><h3>The one-sentence version</h3><p><strong>Temporal lets you write code that remembers where it was, even after the process running it dies.</strong></p><p>That’s it. That’s the whole pitch. It’s called <strong>durable execution</strong>, and the first time you see it work, it feels a bit like cheating.</p><p>With Temporal, the inactivity feature above genuinely looks like this:</p><pre>await Workflow.DelayAsync(TimeSpan.FromDays(60));<br>await SendWarningEmail(userId);<br><br>await Workflow.DelayAsync(TimeSpan.FromDays(23));<br>await SendWarningEmail(userId);<br><br>await Workflow.DelayAsync(TimeSpan.FromDays(7));<br>await DeactivateAccount(userId);</pre><p>No cron job. No status columns. No last_processed_id. You can deploy fifty times during those 90 days. You can delete the server and create a new one. When day 60 arrives, that email gets sent — and the code resumes on the exact line where it left off, with all its local variables intact.</p><p>Let me explain how that’s possible, because it’s not magic and understanding it is what separates “I copied a tutorial” from “I know what I’m doing.”</p><h3>The mental model: your code has a save point</h3><p>If you’ve played a video game, you already understand Temporal.</p><p>You’re deep into a boss fight. The power goes out. You turn the console back on, and you don’t start the game from the beginning — you resume at the last checkpoint, with your inventory, your health, and your progress intact.</p><p>Temporal does that for functions.</p><p>Here’s the actual mechanism. Every time your workflow does something meaningful — starts a timer, calls an external service, receives a message — Temporal writes that fact down in an append-only log called the <strong>event history</strong>. Think of it as a flight recorder, or a git commit log for one execution of your function.</p><pre>1. WorkflowStarted            input: userId = &quot;user-456&quot;<br>2. TimerStarted               duration: 60 days<br>3. TimerFired<br>4. ActivityScheduled          SendWarningEmail<br>5. ActivityCompleted          result: &quot;sent&quot;<br>6. TimerStarted               duration: 23 days<br>...<br>...</pre><p>Now, when the process running your workflow crashes and a new one picks it up, Temporal does something clever: it <strong>replays</strong> your function from the very first line, and every time your code asks for something it already did, Temporal answers instantly from the history instead of actually doing it again.</p><p>So on replay, DelayAsync(60 days) doesn&#39;t wait 60 days — Temporal looks at the history, sees &quot;that timer already fired,&quot; and returns immediately. SendWarningEmail doesn&#39;t send another email — Temporal sees &quot;that already completed and returned &#39;sent&#39;,&quot; and hands back the old result. Your code fast-forwards through everything it has already done, in microseconds, and then continues from the true edge of progress.</p><p>Your function <em>thinks</em> it has been running continuously for 60 days. It has no idea it was actually killed and resurrected eleven times.</p><p><strong>If you’ve done event sourcing, this will feel familiar:</strong> state is rebuilt by replaying events. The difference is that in Temporal, the “state” being rebuilt is <em>your program’s position in the code</em> — the call stack, the local variables, the loop counter, the line number. That’s the leap.</p><h3>The cast of characters</h3><p>Temporal has maybe six concepts you need. Let me walk through each one with an analogy, because the official terminology is precise but not friendly.</p><p>I’ll use a restaurant kitchen as the running metaphor, and it holds up surprisingly well.</p><h3>1. Workflow — the recipe</h3><p>A <strong>workflow</strong> is your orchestration logic. It’s the ordered story of <em>what should happen</em>: first this, then wait for that, then if X do Y.</p><p>In the kitchen: the recipe card. It says <em>make the sauce, then sear the meat, then rest it for ten minutes.</em> The recipe itself doesn’t cook anything. It’s a set of instructions.</p><p>A workflow is just a function. In C# it’s a class with a [Workflow] attribute; in Python it&#39;s a class with @workflow.defn. It looks like completely normal code — loops, if statements, try/catch, local variables. That&#39;s the point.</p><p>The important rule: <strong>workflow code must be deterministic.</strong> Same history in, same decisions out. More on that in a bit, because it’s the one thing that trips up everyone including me.</p><h3>2. Activity — the actual cooking</h3><p>An <strong>activity</strong> is a single unit of real work that touches the outside world. Sending an email. Charging a card. Calling an API. Writing to a database.</p><p>In the kitchen: the actual act of searing the meat. Messy, involves real heat, can go wrong.</p><p>Anything unreliable or non-deterministic goes into an activity. And this is where Temporal quietly hands you a gift: <strong>activities retry automatically.</strong> You configure a policy once and stop writing retry loops forever.</p><pre>await Workflow.ExecuteActivityAsync(<br>    (IInactivityActivities act) =&gt; act.SendWarningNotification(userId, 60),<br>    new ActivityOptions<br>    {<br>        StartToCloseTimeout = TimeSpan.FromMinutes(5),<br>        RetryPolicy = new RetryPolicy { MaximumAttempts = 3 },<br>    });</pre><p>That’s it. If the email service is down, Temporal backs off and tries again. If it’s down for six hours, Temporal keeps trying for six hours. Your workflow just sits patiently at that await, costing nothing.</p><h3>3. Worker — the chef</h3><p>A <strong>worker</strong> is a normal process you write and deploy — a console app, a container, whatever. It connects to Temporal, says “I know how to run these workflows and these activities,” and then waits for work.</p><p>In the kitchen: the chef. Reads tickets, follows recipes, does the cooking.</p><p>The critical thing to understand: <strong>your code runs in your worker, on your infrastructure.</strong> Temporal never executes your business logic. It never sees your database credentials. It’s a coordinator, not a runtime. This is a much bigger deal than it sounds when you’re comparing it to hosted workflow services.</p><p>Workers are stateless and disposable. Kill one, start three more, roll a deployment — the workflows keep going, because the state lives in Temporal’s history, not in the worker’s memory.</p><h3>4. Task Queue — the order rail</h3><p>A <strong>task queue</strong> is a named channel connecting Temporal to your workers. Temporal puts work on it; workers pull work off it.</p><p>In the kitchen: the rail where order tickets get clipped up. Chefs grab the next one.</p><p>It’s just a string, like &quot;account-inactivity&quot;. Both the worker and the client reference the same name and they find each other. No service discovery, no IP addresses, no inbound ports on your workers — workers <em>poll outward</em>, which also means they work fine behind a firewall.</p><h3>5. Temporal Service — the kitchen manager</h3><p>The <strong>Temporal Service</strong> (the server) is the part you run or buy. It stores event histories, fires timers on schedule, hands tasks to workers, and tracks what’s still in flight. Behind the scenes it’s a few services — frontend, history, matching, worker — plus a real database (PostgreSQL, MySQL, or Cassandra) holding the histories.</p><p>In the kitchen: the manager who tracks every open order, tells chefs what’s next, and knows that table 6 has been waiting eleven minutes.</p><p>You mostly don’t think about its internals. You point your code at localhost:7233 and get on with your life.</p><h3>6. Client — the person placing the order</h3><p>The <strong>client</strong> is any code that starts a workflow or talks to a running one. Your API controller, a CLI tool, a message consumer.</p><pre>await client.StartWorkflowAsync(<br>    (AccountInactivityWorkflow wf) =&gt; wf.RunAsync(userId, settings),<br>    new WorkflowOptions(id: userId, taskQueue: &quot;account-inactivity&quot;));</pre><p>Notice id: userId. Every workflow has a <strong>Workflow ID</strong> that you choose, and Temporal guarantees only one workflow with that ID is running at a time. This is a beautiful, underrated feature: it gives you distributed idempotency for free. Use the order ID as the workflow ID and you <em>cannot</em> accidentally process the same order twice, no matter how many times a flaky client retries the request.</p><h3>Two more pieces that unlock the good stuff</h3><p>Workflows aren’t sealed boxes. You can talk to them while they’re running.</p><h3>Signals — tapping the workflow on the shoulder</h3><p>A <strong>signal</strong> is a message you send into a running workflow. Fire-and-forget, and it can arrive at any time.</p><p>This is what solves the “if they log in, reset the clock” requirement. Here’s roughly what the real POC I’ve been working on does:</p><pre>[WorkflowSignal(&quot;UserLoggedIn&quot;)]<br>public Task OnUserLoggedInAsync()<br>{<br>    _loginSignalReceived = true;<br>    return Task.CompletedTask;<br>}</pre><p>And in the workflow, instead of only sleeping, we race the timer against the signal:</p><pre>var delayTask = Workflow.DelayAsync(delay);<br>var loginTask = Workflow.WaitConditionAsync(() =&gt; _loginSignalReceived);<br>await Workflow.WhenAnyAsync(delayTask, loginTask);</pre><p>Whichever happens first wins. If the 60-day timer fires first, we send the warning. If a login arrives first, we reset.</p><p>In our system, logins land in a Google Pub/Sub topic; a small subscriber service reads each message and sends a signal to the workflow whose ID matches that user. So the flow is: <em>user logs in → event bus → subscriber → signal → workflow wakes up.</em> The workflow doesn’t poll anything. It doesn’t scan a table. It just sits there being woken up by real events.</p><h3>Queries — asking the workflow a question</h3><p>A <strong>query</strong> reads state from a running workflow without changing it. “How many days until this account gets deactivated?” You can answer that by asking the workflow directly, instead of trying to reverse-engineer it from database columns.</p><h3>Continue-As-New — a fresh sheet of paper</h3><p>One catch with an append-only history: a workflow that runs for years accumulates events forever, and histories can’t grow without limit.</p><p><strong>Continue-As-New</strong> is the escape hatch. It ends the current run and immediately starts a fresh one with new inputs and an empty history — same workflow ID, clean slate. It’s the workflow equivalent of tail recursion.</p><p>We use it as the reset mechanism. When a login signal arrives, we don’t try to unwind timers and mutate state. We just start over:</p><pre>if (_loginSignalReceived)<br>{<br>    throw Workflow.CreateContinueAsNewException(<br>        (AccountInactivityWorkflow w) =&gt; w.RunAsync(userId, settings));<br>}</pre><p>New run, lastLoginTime = now, timers recalculated from scratch. One elegant line replaces every &quot;did I remember to clear all four warning columns?&quot; bug you&#39;ve ever written.</p><h3>“So is this just the Saga pattern?”</h3><p>If you’ve worked with microservices, your brain has probably been shouting <em>this is a Saga</em> for the last few minutes. Good instinct. Let me place Temporal next to the ideas you already know.</p><p><strong>Saga pattern.</strong> A Saga coordinates a multi-step distributed transaction and runs compensating actions when a step fails — refund the card if shipping falls through. Temporal is the <em>best tool I know for implementing an orchestrated Saga</em>, but it’s more general. In classic Saga implementations you hand-build the state machine and the compensation dispatcher, usually with a chain of events and a “saga state” table. In Temporal, your Saga is a try/catch:</p><pre>try<br>{<br>    await ChargeCard(order);<br>    await ReserveInventory(order);<br>    await ShipOrder(order);<br>}<br>catch (Exception)<br>{<br>    await RefundCard(order);      // compensation, right where you&#39;d expect it<br>    await ReleaseInventory(order);<br>}</pre><p>That’s a distributed transaction spanning three services and possibly several days, written as a try/catch that a first-year developer can read. The compensation logic sits next to the thing it compensates for, instead of in a separate handler in a separate file wired up by a separate event.</p><p><strong>Cron jobs.</strong> A cron job is <em>pull-based and stateless</em>: wake up, scan everything, figure out what to do. Temporal is <em>push-based and stateful</em>: each entity has its own little program that knows exactly where it is. Instead of one job scanning two million users hourly, you have two million sleeping workflows that each cost essentially nothing until their moment arrives.</p><p><strong>State machines.</strong> Temporal is a state machine where you never draw the state machine. The states are implicit in your code’s control flow — which line you’re paused on <em>is</em> the state. No enum, no transition table, no if (status == &quot;AWAITING_WARNING_2&quot;).</p><p><strong>Message queues.</strong> Queues give you durable <em>messages</em>. Temporal gives you durable <em>execution</em>. With a queue you still have to design who consumes what, what happens on poison messages, and how the steps know about each other. Temporal handles the sequencing for you, and gives you the one thing a queue can never give you: a single place to read the whole story.</p><p><strong>async/await.</strong> This is the closest analogy of all. await already means &quot;pause here, resume later&quot; — you just never worried about the process dying during the pause, because the pause was milliseconds. Temporal is await with the pause extended to months and the resume made crash-proof. <strong>Temporal is durable async/await.</strong></p><p><strong>AWS Step Functions / Camunda / BPMN engines.</strong> Same problem space, very different ergonomics. Those tools express workflows as JSON, XML, or drag-and-drop diagrams. Temporal expresses them as code in the language you already use, which means you get loops, functions, your IDE, your type system, your unit tests, and your code review process. Once you’ve written a workflow as plain code, going back to authoring a state machine in JSON feels like being asked to write your business logic in a spreadsheet.</p><h3>The one rule you must respect: determinism</h3><p>Here’s where beginners get burned, so let’s be direct about it.</p><p>Because Temporal recovers by <em>replaying your workflow code</em>, that code must make the same decisions every time it replays. If your workflow took the if branch on the first run, it must take the if branch on every replay, forever. Otherwise the code and the recorded history disagree, and Temporal — correctly — refuses to continue.</p><p>That means inside <strong>workflow</strong> code, these are off limits:</p><ul><li>DateTime.Now, time.time(), new Date() — the wall clock moves between replays. Use Workflow.UtcNow, which returns the <em>recorded</em> time.</li><li>Guid.NewGuid(), random() — different value every replay. Use Temporal&#39;s deterministic equivalents (Workflow.NewGuid(), workflow.random()).</li><li>Thread.Sleep — use Workflow.DelayAsync, the durable timer.</li><li>Direct HTTP calls, database reads, file access — these belong in activities.</li><li>Reading global mutable state or environment variables that might change.</li></ul><p>The rule of thumb that will keep you out of trouble: <strong>workflow code decides; activity code does.</strong> Anything that touches the messy outside world goes in an activity, and the activity’s <em>result</em> gets written to history — which is exactly why it’s safe on replay.</p><p>There’s a related gotcha worth knowing early: you can’t freely change a workflow’s code while old runs are still in flight, because the new code might make different decisions than the history recorded. Temporal has versioning tools (patching, worker versioning) for this. Just know it exists so it doesn’t surprise you in production.</p><h3>Why I think this is genuinely a big deal</h3><p>I don’t want to oversell a tool. But I do think durable execution changes how we build things, in the same way that garbage collection changed how we handle memory. Not “a nicer library” — more like “a category of bug stopped being your problem.”</p><p><strong>The status column dies.</strong> So much of our schema exists purely to remember where a process got to. payment_status, retry_count, last_attempted_at, email_sent. All of that is a hand-rolled, buggy reimplementation of a program counter. Temporal makes the program counter durable, so the columns evaporate.</p><p><strong>Business logic becomes readable again.</strong> Right now, if you want to know what happens when an order is placed, you read a controller, then a message handler, then a second service, then a retry policy in YAML, then a cron job someone wrote in 2021. The logic is real but it doesn’t live anywhere — it’s an emergent property of six files. In Temporal, it’s one function you can read top to bottom. A new hire can understand your order pipeline on day one. I struggle to overstate how much that’s worth.</p><p><strong>Failure stops being a special case.</strong> You stop writing “what if this crashes here?” branches, because the answer is always the same: it resumes. Your happy path <em>is</em> your only path. Realistically, most of the defensive code we write is guessing at failure modes we never actually tested. Temporal replaces the guessing with a guarantee.</p><p><strong>Debugging becomes archaeology instead of divination.</strong> When something goes wrong in a distributed system today, you correlate logs across five services and hope you have the right trace ID. With Temporal, you open the Web UI, find the workflow, and read the complete ordered history of everything that happened, including every failed attempt and every retry, with inputs and outputs. It’s the difference between a crime scene and a security tape.</p><p><strong>Time becomes a first-class thing.</strong> “Wait three days, then check if they responded” is a one-liner. Anyone who’s built a reminder system, a trial expiry, a multi-day approval chain, or a subscription dunning flow knows how much machinery that normally takes.</p><p>The honest summary: Temporal doesn’t make hard business problems easier. It makes <em>accidental</em> problems disappear so you can spend your attention on the hard business problems.</p><h3>When not to reach for it</h3><p>Because I’d rather you trust me than be excited.</p><p>Temporal is not a request/response framework. Don’t put it in the path of something that needs to answer in 20 milliseconds — there’s real overhead per workflow, and it’s designed for durability, not latency.</p><p>It’s not a data pipeline. Don’t push megabytes through workflow arguments or activity results; everything gets serialized into history. Pass IDs and pointers, not payloads.</p><p>It’s not free operationally. Self-hosting means running the server and a database you now have to care about. Temporal Cloud exists for exactly this reason, and for most teams it’s the right call.</p><p>And it’s not a small conceptual lift. Determinism, replay, and versioning take a couple of weeks to really internalize. If your whole app is three CRUD endpoints, you don’t need this. If you have anything that spans multiple services, multiple days, or multiple retries, you probably do.</p><h3>Try it in ten minutes</h3><p>Reading about replay is fine. Watching it happen is what actually makes it click.</p><p>Install the CLI and start a local server:</p><pre>brew install temporal          # or scoop install temporal on Windows<br>temporal server start-dev</pre><p>Open http://localhost:8233 for the Web UI. Then grab the SDK for your language — Go, Java, TypeScript, Python, .NET, PHP, Ruby — and run the hello-world sample.</p><p>Then do the exercise that taught me more than any blog post, including this one:</p><ol><li>Write a workflow with three activities that each print something and sleep for ten seconds.</li><li>Start it, and watch the events appear in the Web UI.</li><li>While it’s running, <strong>kill your worker process.</strong> Ctrl+C, no mercy.</li><li>Wait a while. Notice the workflow is still there in the UI, patiently waiting.</li><li>Start the worker again.</li></ol><p>It picks up exactly where it left off. Activities that already finished do not run again.</p><p>The first time I did that, I sat and stared at the terminal for a bit. It’s one of those rare moments in this job where a tool does something you didn’t think was allowed.</p><h3>Where I’d start</h3><p>If you’re new and want a path: build the inactivity workflow from the top of this article. It’s small enough to finish in an evening, and it forces you to touch timers, activities, signals, and Continue-As-New — which is most of Temporal.</p><p>Then go and look at whatever “status column plus cron job” system exists in your current codebase, and imagine it as a single function. That’s usually the moment people get it.</p><p><em>If you found this useful, I’d genuinely love to hear which analogy landed best — I’m still hunting for the perfect way to explain replay to someone on day one. And if you’re using Temporal for something interesting, tell me about it in the comments.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3ee618f74c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Protecting PII Data From AI Language Models]]></title>
            <link>https://sarinbhaskaran.medium.com/protecting-pii-data-from-ai-language-models-69deb4272bc2?source=rss-d69e530e03c3------2</link>
            <guid isPermaLink="false">https://medium.com/p/69deb4272bc2</guid>
            <category><![CDATA[pii-data]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Sarin Bhaskaran]]></dc:creator>
            <pubDate>Wed, 08 Oct 2025 20:56:42 GMT</pubDate>
            <atom:updated>2025-10-08T20:56:42.996Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Large language models (LLMs) like ChatGPT and Gemini are everywhere. They automate customer support, optimize logistics, and power cool new apps. But there’s a catch, these models can sometimes leak sensitive info, even by accident. As more businesses plug LLMs into their daily workflows, protecting personally identifiable information (PII) — things like phone numbers, addresses, or ID numbers — becomes essential.</p><p>Let’s explore why this matters, where the risks are, and how smart software design can keep your users, your business, and their data safe.</p><h3>Why Is PII a Problem With LLMs?</h3><p>Traditional security assumed sensitive info stayed tucked away in a database. But LLMs work differently, they generate text based on what they’ve seen in training, sometimes mixing in real-world details without meaning to. For example, a customer service model trained on old chat logs might spit out a real person’s phone number, or internal business details could pop up in answers to innocent questions.</p><p>Leaking PII like this is not just embarrassing but it can break privacy laws (like GDPR or CCPA), hurt your reputation, and create legal and financial headaches.</p><h3>Who Needs to Worry?</h3><ul><li>Logistics &amp; supply chain companies: Customer addresses, tracking data, and employee IDs all flow through LLM-powered tools.</li><li>Healthcare: Patient information in records and support requests is highly sensitive.</li><li>Financial services: Credit card numbers, transaction details, and account info.</li><li>HR: Employee data, salary details, reviews — a goldmine for attackers if mishandled.</li></ul><p>Even small organizations are vulnerable if they use LLMs on business or customer data.</p><h3>What Are Guardrails?</h3><p>Guardrails are safeguards that sit between the user and the LLM. Think of them as both “bouncers” and “editors”:</p><ul><li>On the way in, they check what users submit (and block or mask sensitive stuff).</li><li>On the way out, they review what the LLM generates, stopping risky info before it escapes.</li></ul><h3>How to Add Guardrails to Your LLM Solution</h3><p>Imagine your app as a flow from the user to the AI and back. Here’s a simple architecture:</p><p>LLM Guardrails Architecture Overview</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*cfr51LLxSzyF8EPA0f2gYA.png" /></figure><h3>1. Input Guardrails</h3><ul><li>Detect PII: Scan all incoming queries for things like phone numbers, emails, or addresses.</li><li>Check for attacks: Stop users from tricking the AI with “prompt injection” or sneaky questions.</li><li>Approve or block: If PII or risks are found, the request can be masked, flagged, or blocked before going to the LLM.</li></ul><h3>2. LLM Processing</h3><ul><li>The AI generates its response, but can include PII or sensitive content if unchecked.</li></ul><h3>3. Output Guardrails</h3><ul><li>Scan the response: Check answers for PII and risky content before they reach the user.</li><li>Filter, redact, or block: Mask sensitive info or return a safe version.</li><li>Audit and log: Record blocked attempts for review and improvement.</li></ul><h3>What Does This Look Like in Real Systems?</h3><p>Here’s a more detailed guardrails setup, showing each protection layer:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mRZheOlefBBt6onvEXdtCg.png" /></figure><p>Detailed LLM Guardrails Architecture with Security Layers</p><ul><li>UI Layer: Where users interact — web, mobile, or API.</li><li>Input Processing: Validate, scrub, and analyze what comes in.</li><li>Policy Engine: Makes decisions using business rules and risk scoring.</li><li>LLM: The large language model itself.</li><li>Output Processing: Reviews and cleans AI responses.</li><li>Monitoring: Logs everything for compliance and fixes.</li></ul><h3>Common PII Data — and Why It’s Risky</h3><p>PII Data Types and Risk Matrix in Logistics AI Systems</p><ul><li>Customer info: Names, addresses, emails, phone numbers</li><li>Employee data: IDs, payroll, contact details</li><li>Orders and shipments: Tracking codes, delivery details</li><li>Payments: Credit cards, bank accounts</li></ul><p>Risks if leaked:</p><ul><li>Data breaches (expensive!)</li><li>Legal fines</li><li>Damaged trust and brand</li><li>Business disruption</li></ul><h3>Best Practices for Guardrails</h3><ul><li>Classify your data: Know what is critical, high, medium, or low risk.</li><li>Use good detection tools: Start simple (regex, lists), then add advanced AI or named-entity recognition for trickier cases.</li><li>Don’t block everything: Avoid being so strict that your app is unusable. Tune the rules.</li><li>Continuously monitor: Log, review, and improve your rules over time, catching new edge cases.</li><li>Follow the law: Make sure your guardrails match the privacy laws for your industry and region.</li></ul><h3>Tool Examples</h3><ul><li>Open Source: Microsoft Presidio, spaCy, Guardrails AI</li><li>Cloud: Amazon Bedrock Guardrails, Azure AI Content Safety, Google Cloud DLP</li><li>Enterprise: Nightfall, BigID, OneTrust</li></ul><h3>Final Thoughts</h3><p>LLMs can supercharge your business — but only if you use them responsibly. By adding smart guardrails at both the input and output, you can prevent accidental PII leaks while still getting the benefits of AI. Start simple, use the right tools, and stay alert. With these steps, your organization can innovate confidently and keep everyone’s data safe.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69deb4272bc2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Agentic AI Architectures : A Practical Guide for Architects]]></title>
            <link>https://sarinbhaskaran.medium.com/agentic-ai-architectures-a-practical-guide-for-architects-0ddd925b0e49?source=rss-d69e530e03c3------2</link>
            <guid isPermaLink="false">https://medium.com/p/0ddd925b0e49</guid>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[solution-architecture]]></category>
            <category><![CDATA[agentic-ai-architecture]]></category>
            <dc:creator><![CDATA[Sarin Bhaskaran]]></dc:creator>
            <pubDate>Mon, 06 Oct 2025 19:18:30 GMT</pubDate>
            <atom:updated>2025-10-06T19:53:43.712Z</atom:updated>
            <content:encoded><![CDATA[<h3>Agentic AI Architectures : A Practical Guide for Architects</h3><h3>Why Agentic AI is becoming the next big thing</h3><p>Over the last year, you have probably heard the term <em>Agentic AI</em> pop up everywhere from OpenAI’s demos to enterprise architecture discussions.</p><p>At a simple level, <strong>Agentic AI</strong> means giving AI systems the ability to <em>reason, plan, act, and learn</em> like a digital agent , not just respond to a prompt.<br>Instead of a request-response pattern, these systems observe, decide what to do next, and even collaborate with other agents or humans.</p><p>Think of it like upgrading a chatbot into a full-fledged AI minion that can use tools, call APIs, and manage its own workflow.</p><h3>What makes an Agentic AI system?</h3><p>Every agentic architecture no matter how fancy boils down to four fundamental capabilities:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*Bizqc7JxQkG_brM1H36E5A.png" /></figure><p>Here’s how that typically looks:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*qJCSsEEXrAMcLnOWVq-Fgg.png" /><figcaption>It’s a continuous loop: sense, think, act, learn.</figcaption></figure><h3>Common Architecture Patterns</h3><p>Let us look at the most <strong>common patterns</strong> architects are using to design Agentic AI systems today.</p><h4>ReAct (Reason + Act) Pattern</h4><p>This is the <em>classic</em> agent loop.</p><p>The AI alternates between <strong>thinking</strong> (“what should I do?”) and <strong>acting</strong> (“let’s call an API”).<br> After each step, it reflects on the outcome before continuing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*kDXOTj532GIGw1QKQrrwMA.png" /></figure><p><strong>Use it when:</strong> you want the agent to make decisions dynamically and minimize hallucination.</p><h4>Reflexion / Self-Refine Pattern</h4><p>The agent reviews its own work before finalizing.<br> It’s like a built-in “peer reviewer” that checks output quality.</p><p>Example: After writing a summary, the agent critiques it (“too long”) and re-writes a shorter version.</p><p><strong>Use it when:</strong> reliability and quality matter more than speed (e.g., documentation, code generation).</p><h4>Planning and Decomposition</h4><p>For complex goals, agents first create a <strong>plan</strong> (a sequence of subtasks) and then execute each step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i0bi_VRQNXEhYPlvo2ce1g.png" /></figure><p><strong>Use it when:</strong> the task involves multiple dependent steps, typical in enterprise workflows.</p><h4>Tool-Use / Function Calling</h4><p>The agent doesn’t rely only on text as it knows when to call a <strong>function or API</strong>.</p><p>For instance, “calculate tax” → calls a finance API; “get shipment ETA” → queries a logistics DB.</p><p><strong>Use it when:</strong> you want real world integration, connecting LLMs to your existing systems.</p><h4>Memory-Augmented Agents</h4><p>Memory lets an agent <em>remember</em> what happened in earlier sessions.<br> This could be a short term context buffer or a long-term vector database.</p><p><strong>Use it when:</strong> continuity matters, like chat histories, customer support, or task hand-offs.</p><h4>Multi-Agent Collaboration</h4><p>Here, multiple specialized agents work together: one might plan, another execute, another review.</p><p>Example:</p><ul><li><strong>Planner Agent</strong> → creates subtasks</li><li><strong>Executor Agent</strong> → performs actions</li><li><strong>Reviewer Agent</strong> → checks results</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*Xv9NUmdqdM-7Xz8b6z017A.png" /></figure><p><strong>Use it when:</strong> your system mimics a team like product design, software dev, or multi-step reasoning.</p><h4>Event-Driven Orchestration</h4><p>As your AI systems mature, you’ll quickly realize that a single “agent loop” isn’t enough.<br> Real enterprise environments deal with <strong>many agents</strong> handling different parts of a workflow and that’s where <strong>Event-Driven Architecture (EDA)</strong> comes in.</p><p>Instead of tightly chaining one step after another, event-driven systems let agents <strong>react to events</strong> like messages, triggers, or state changes in real time.<br>This ensures scalability, observability, and fault tolerance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*_IHYMYVVxfHzyC6dPZKnDA.png" /></figure><p><strong>Use it when:</strong> you’re taking your prototype agent to the cloud or need to orchestrate multiple workflows.</p><h3>Enterprise-Ready Patterns</h3><p>Enterprises are now adopting <strong>Agentic Cloud Blueprints</strong>, especially from AWS, Azure, and Google.<br> They typically include:</p><ul><li><strong>Agent Orchestrator</strong> : manages lifecycle &amp; retries</li><li><strong>Memory Store</strong> : vector DB for persistence</li><li><strong>Tool Hub :</strong> function/API registry</li><li><strong>Observation Layer :</strong> logging, tracing, guardrails</li><li><strong>Human Oversight</strong> : review or escalation triggers</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*26xlxmSCFEroAyXPbW-Yvw.png" /></figure><p>This is the foundation for large-scale, compliant Agentic AI in enterprises.</p><h3>Communication &amp; Protocols</h3><p>To make different agents and tools talk to each other, new standards are emerging:</p><ul><li><strong>MCP (Model Context Protocol)</strong> : lets agents share context and tools securely</li><li><strong>A2A / Agent-to-Agent Protocol</strong> : defines structured inter-agent messaging</li><li><strong>Contract Net Protocol (CNP)</strong> : classic approach for task bidding and delegation</li></ul><p>These will shape how multi-agent ecosystems evolve in the next few years.</p><h3>Putting it all together</h3><p>In real-world systems, these patterns are <em>combined </em>and not isolated.</p><p>For example, your enterprise AI assistant might use:</p><ul><li><strong>ReAct</strong> for decision-making</li><li><strong>Tool Use</strong> for integration</li><li><strong>Memory</strong> for context</li><li><strong>Reflexion</strong> for QA</li><li><strong>Event-Driven Orchestration</strong> for reliability</li></ul><p>Result: a truly <strong>agentic system</strong> that learns, acts, and improves safely and transparently.</p><h3>Final Thoughts</h3><p>We’re still early in the Agentic AI era but the architecture patterns are stabilizing fast.<br>As architects, our job is to design systems that are <strong>reliable, observable, and extensible,</strong> not just “intelligent.”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0ddd925b0e49" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DeepSeek: The AI Revolution just got Smarter, Faster, and Cheaper]]></title>
            <link>https://sarinbhaskaran.medium.com/deepseek-the-ai-revolution-just-got-smarter-faster-and-cheaper-019afdb37be2?source=rss-d69e530e03c3------2</link>
            <guid isPermaLink="false">https://medium.com/p/019afdb37be2</guid>
            <category><![CDATA[deepseek]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Sarin Bhaskaran]]></dc:creator>
            <pubDate>Wed, 29 Jan 2025 22:01:17 GMT</pubDate>
            <atom:updated>2025-01-29T22:01:17.877Z</atom:updated>
            <content:encoded><![CDATA[<p>Artificial intelligence (AI) is evolving at lightning speed, and DeepSeek is one of the newest players making waves in this space. Designed to think and process information more like a human, DeepSeek is not just another AI tool — it’s a game-changer. What sets it apart is its ability to deliver results at 95% less cost than competitors. Let’s explore what makes DeepSeek unique, how it works, and why it matters.</p><h3>What Makes DeepSeek Different?</h3><p>Most AI systems, like traditional search engines or popular tools like ChatGPT, rely on matching keywords or processing their entire knowledge base for every task. DeepSeek takes a smarter approach by combining two cutting-edge technologies:</p><ul><li>Natural Language Processing (NLP): This enables DeepSeek to understand the meaning behind words. For example, it can distinguish whether “Apple” refers to the fruit or the tech company based on context.</li><li>Deep Neural Networks: These mimic how the human brain recognizes patterns in text, images, and data, allowing the system to “think” more like us.</li></ul><p>This combination allows DeepSeek to excel in tasks that were previously challenging for AI:</p><ul><li>Answering complex questions about medical research papers.</li><li>Predicting stock market trends by analyzing news articles.</li><li>Writing or debugging computer code while maintaining consistent style.</li></ul><h3>How it works : A Team of Specialists</h3><p>DeepSeek employs a clever system called <em>Mixture-of-Experts</em>, which functions like a team of specialists stepping in only when their expertise is needed. With 671 billion “knowledge points” (parameters), it activates just 5.5% (37 billion) for any specific task. This selective activation makes it faster and cheaper than other AI systems that use all their resources for every task.For example:</p><ul><li>When helping programmers debug code, its coding expert is activated.</li><li>For predicting stock trends, its financial analysis expert takes charge.</li></ul><p>This approach is akin to turning on only the kitchen lights while cooking — saving energy while focusing on what’s needed.</p><h3>DeepSeek vs. Traditional AI: The Efficiency Champion</h3><p>When compared to popular AI models like OpenAI’s GPT-4, DeepSeek stands out for its efficiency:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*gEWqxIW9e04FHcoEH24RRw.png" /></figure><p>DeepSeek processes information more efficiently by using only the necessary parameters for each task. It offers significant cost savings, faster processing speeds, and larger context memory. While OpenAI excels in creative writing tasks, DeepSeek is better suited for specialized applications like coding, financial analysis, or medical research.</p><h3>Why Is It Faster and Cheaper?</h3><p>DeepSeek’s design prioritizes time and cost efficiency:</p><ul><li>Instead of activating all its “brainpower” for every query, it uses only the relevant parts — like turning on just the kitchen lights when cooking instead of lighting up the whole house.</li><li>Its cost per million tokens is just $0.14 compared to GPT-4’s $30.</li></ul><h4>Examples:</h4><p><strong>Programmer Fixing Code</strong><br>A programmer debugging a Python script can process requests 3x faster with DeepSeek than GPT-4 because only coding-related parameters are activated.</p><p><em>Example:</em> If debugging takes 30 seconds with DeepSeek, it might take 90 seconds with GPT-4.</p><p><strong>Business Analyzing Financial Reports</strong><br>A company analyzing a 100-page financial report (~400,000 tokens) would save both time and money with DeepSeek.</p><p><em>Example:</em> DeepSeek completes the task in 20 minutes at a cost of $0.056, while GPT-4 might take an hour and cost $12.</p><h3>Hold your horses, its still not perfect</h3><p>Despite its strengths, DeepSeek isn’t perfect. Here are some challenges users have reported:</p><ol><li>Censorship and Bias: It avoids certain sensitive topics (e.g., Chinese political history) and selectively discusses others.</li><li>Security Issues: It’s vulnerable to “jailbreaking,” which lets users bypass safeguards to generate harmful content like ransomware instructions.</li><li>Privacy Concerns: User data is stored in China, raising fears about government access or cyberattacks.</li><li>Occasional Inaccuracies: Sometimes it fabricates information or struggles with reasoning tasks.</li><li>Technical Setup Needed: Setting up DeepSeek requires some technical knowledge.</li></ol><h3>Why DeepSeek Still Matters</h3><p>Even with its flaws, DeepSeek represents a major step forward in AI technology. Its open-source nature and affordability are democratizing access to advanced AI tools. For instance:</p><ul><li>Small startups can use it to analyze market trends without spending millions on AI tools.</li><li>Hospitals can deploy it locally to protect patient privacy while improving care.</li></ul><p>As more companies adopt tools like DeepSeek, we’ll likely see even better innovations in the future. As it evolves, DeepSeek could become the “electricity” of AI — an invisible, essential tool powering smarter decisions across industries. While not perfect, its balance of efficiency and capability makes advanced AI a reality for more people worldwide.</p><p>The best example for this is the Robinhood brokerage app, its $0 fee trading structure lead all brokerage firms to adopt a $0 fee structure. Sure Robinhood had its own issues but changed way stocks were traded forever. Similarly DeepSeek is definitely an amazing step forward in AI that will be beneficial to us all</p><h3>Conclusion: A Catalyst for Change</h3><p>DeepSeek isn’t just another AI — it’s a powerful tool that balances human-like understanding with cost-effective efficiency. While there’s room for improvement, its ability to handle specialized tasks at low costs makes it an exciting development in the AI world. Whether you’re a programmer fixing bugs, a researcher diving into medical studies, or a business analyzing financial trends, DeepSeek offers a glimpse into the future of AI: smarter, faster, cheaper — and more accessible than ever before.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=019afdb37be2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI for Dummies: From “Hello World” to “Hello Skynet?”]]></title>
            <link>https://sarinbhaskaran.medium.com/ai-for-dummies-from-hello-world-to-hello-skynet-841039cc29e2?source=rss-d69e530e03c3------2</link>
            <guid isPermaLink="false">https://medium.com/p/841039cc29e2</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[introduction]]></category>
            <dc:creator><![CDATA[Sarin Bhaskaran]]></dc:creator>
            <pubDate>Thu, 17 Oct 2024 19:07:22 GMT</pubDate>
            <atom:updated>2024-10-17T19:07:22.332Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey there, fellow code enthusiasts! When the AI revolution took off, it felt like there was this intense pressure for developers like me to dive in or risk being left behind. Every article I found seemed written for people already fluent in AI (or maybe I was just searching in the wrong places). After countless hours of scrolling through websites and YouTube tutorials, I finally started to wrap my head around some key concepts. Now, I’m here to share what I’ve learned in the simplest way possible, for anyone who’s curious about AI but unsure where to start — no PhD required! If you’ve ever thought AI was just “if-else statements on steroids,” trust me, you’re not alone. So, grab your coffee(or water), and let’s dive into my rollercoaster journey into the world of Artificial Intelligence — filled with facepalms, “aha!” moments, and more Python libraries than you can shake a stick at.</p><h3>What the Heck is AI Anyway?</h3><p>So there I was, feeling like a coding rockstar because I learnt to code in python in 5 days and felt I could learn anything in a week. Then I heard about AI and thought, “How hard could it be?” Spoiler alert: it’s like trying to teach a cat to bark — possible, but prepare for some scratches along the way. At its core, AI is about making machines smart enough to do things that would normally require a human brain. You know, like recognizing cat pictures or telling you that your Spotify playlist is stuck in the 90s (thanks, AI).</p><h3>Machine Learning: Teaching Computers to Be Know-It-Alls</h3><p>First stop on my AI adventure: Machine Learning. Imagine trying to teach a toddler to recognize a dog. Now imagine that toddler is made of silicon and has an insatiable appetite for data. That’s Machine Learning in a nutshell. Here’s how it goes:</p><ol><li>Data Collection - You feed the computer more information than a conspiracy theorist at an alien convention.</li><li>Training -The computer starts to see patterns. It’s like it’s playing the world’s most complicated game of Connect the Dots.</li><li>Model Creation - The computer creates a set of rules based on what it learned.</li><li>Prediction - Now it can make educated guesses about new stuff. Sometimes it’s spot on, other times it’s… well, let’s just say AI won’t be replacing fortune tellers anytime soon.</li></ol><p>So in Machine Learning, the data feeds the training process, which creates a model that can make predictions on new, unseen data.</p><p>Here’s a simple example:</p><p>Imagine you want to teach a computer to recognize dogs. You’d show it thousands of dog pictures. After a while, it starts to figure out on its own what makes a dog a dog — floppy ears, wagging tails, wet noses, you name it.</p><pre>from sklearn import tree<br><br># Features: [height, weight, bark_pitch]<br>dog_features = [<br>    [60, 20, 100],  # Small dog<br>    [80, 30, 80],   # Medium dog<br>    [100, 45, 70]   # Large dog<br>]<br>labels = [&#39;small&#39;, &#39;medium&#39;, &#39;large&#39;]<br><br>clf = tree.DecisionTreeClassifier()<br>clf = clf.fit(dog_features, labels)<br><br># Predict the size of a new dog<br>new_dog = [[70, 25, 90]]<br>prediction = clf.predict(new_dog)<br>print(f&quot;This dog is probably {prediction[0]}&quot;)</pre><p>In this example, we’re teaching the computer to guess a dog’s size based on its height, weight, and bark pitch. It’s like teaching a kid to identify dogs, but with numbers!</p><h3>Neural Networks: When Your Computer Starts Thinking It’s a Brain</h3><p>Next up: Neural Networks. This is where things got weird. Imagine if your computer suddenly decided it wanted to cosplay as a human brain. That’s essentially what’s happening here. Imagine a bunch of kids passing messages in class, each adding their own twist to the message.</p><p>You’ve got:</p><ul><li>Neurons - The drama queens of the network. They’re always passing messages and can’t seem to make a decision without consulting all their friends.</li><li>Layers - Like a giant game of telephone, but with math.</li><li>Connections -The social network of the AI world. Each connection has a “weight,” kind of like how much you trust your friend’s opinion on whether you should get bangs.</li></ul><p>So, in a Neural Network, neurons are organized into layers, with connections between neurons in adjacent layers allowing information to flow and be processed from input to output.</p><p>Here’s a super simple example:</p><p>Let’s say we want to predict if you’ll like a movie based on three factors: how much action it has, how funny it is, and if your best friend liked it.</p><pre>import numpy as np<br><br>def simple_neural_network(action, humor, friend_likes):<br>    # Weights (how important each factor is)<br>    w1, w2, w3 = 0.3, 0.5, 0.2<br>    <br>    # Combine all factors<br>    weighted_sum = (action * w1) + (humor * w2) + (friend_likes * w3)<br>    <br>    # Decision (1 for like, 0 for dislike)<br>    return 1 if weighted_sum &gt; 0.5 else 0<br><br># Let&#39;s predict if you&#39;ll like &quot;Funny Action Movie&quot;<br>prediction = simple_neural_network(action=0.8, humor=0.6, friend_likes=1)<br>print(&quot;You&#39;ll probably &quot; + (&quot;like&quot; if prediction == 1 else &quot;dislike&quot;) + &quot; this movie!&quot;)</pre><p>This tiny “neural network” decides if you’ll like a movie by weighing different factors. It’s like your brain making a decision, but way simpler!</p><h3>Natural Language Processing: Teaching Siri to Understand Your 3 AM Texts</h3><p>Ever wonder how Siri manages to understand you when you ask for “pizza” at 3 AM, but somehow autocorrect still thinks you meant “ducking”? Welcome to the wild world of Natural Language Processing (NLP). Key things I learned:</p><ul><li>Tokenization - Breaking text into bite-sized pieces. It’s like when you’re trying to eat a whole pizza by yourself — sometimes you need to take it one slice at a time.</li><li>Sentiment Analysis - Teaching a computer to understand emotion in text. Because apparently, my passive-aggressive emails weren’t clear enough.</li></ul><p>NLP combines tokenization to break down text, part-of-speech tagging to understand grammar, and sentiment analysis to grasp emotion, all working together to help computers understand and generate human language.</p><p>Let’s create a super basic chatbot that responds to your mood:</p><pre>import random<br><br>def simple_chatbot(user_input):<br>    user_input = user_input.lower()<br>    <br>    if &quot;happy&quot; in user_input:<br>        responses = [&quot;That&#39;s great!&quot;, &quot;Awesome!&quot;, &quot;Keep smiling!&quot;]<br>    elif &quot;sad&quot; in user_input:<br>        responses = [&quot;Cheer up!&quot;, &quot;Tomorrow will be better&quot;, &quot;Want to talk about it?&quot;]<br>    else:<br>        responses = [&quot;Interesting&quot;, &quot;Tell me more&quot;, &quot;I see&quot;]<br>    <br>    return random.choice(responses)<br><br># Let&#39;s chat!<br>user_mood = input(&quot;How are you feeling? &quot;)<br>print(&quot;Bot:&quot;, simple_chatbot(user_mood))</pre><p>This chatbot is like a very basic version of Siri or Alexa. It’s trying to understand your mood and respond appropriately. It’s not winning any Turing tests, but it’s a start!</p><h3>Computer Vision: When Your Laptop Starts Judging Your Selfies</h3><p>This is exactly what you guessed, Computer Vision is all about teaching machines to see. It’s like giving your computer a pair of eyes, except it doesn’t blink and watching it stare at things is way creepier. What it can do:</p><ul><li>Image Classification - “Yep, that’s a cat.”</li><li>Object Detection - “There’s a cat… and another cat… and oh look, another cat.” (Can you tell I like cats?)</li></ul><p>Computer Vision uses image classification to identify what’s in an image, object detection to locate specific items, and image segmentation to divide the image into meaningful parts, all contributing to a machine’s ability to “see” and understand visual information.</p><p>Imagine we’re teaching a computer to count how many red pixels are in an image. This could be a baby step towards identifying ripe strawberries in a field!</p><pre>from PIL import Image<br><br>def count_red_pixels(image_path):<br>    image = Image.open(image_path)<br>    width, height = image.size<br>    red_pixels = 0<br>    <br>    for x in range(width):<br>        for y in range(height):<br>            r, g, b = image.getpixel((x, y))<br>            if r &gt; 200 and g &lt; 100 and b &lt; 100:  # This is roughly &quot;red&quot;<br>                red_pixels += 1<br>    <br>    return red_pixels<br><br># Let&#39;s count red pixels!<br>red_count = count_red_pixels(&#39;strawberry_field.jpg&#39;)<br>print(f&quot;There are {red_count} red pixels in this image!&quot;)</pre><p>This script is like teaching a kid to count red cars on the street. It’s a tiny step towards more complex image recognition, like identifying entire objects or faces!</p><h3>Reinforcement Learning: Teaching AI Through Bribery and Mild Threats</h3><p>Last but not least, we have Reinforcement Learning. This is basically like training a dog, if the dog was made of silicon and could process a million treats per second. The gist:</p><ul><li>You have an Agent (the AI) in an Environment (the world it’s learning about).</li><li>The Agent takes Actions and gets Rewards or punishments.</li><li>Over time, it learns which actions lead to treats… I mean, rewards.</li></ul><p>So basically in Reinforcement Learning, an agent interacts with an environment by taking actions, observing the resulting state changes, and receiving rewards, gradually learning a policy to maximize cumulative rewards over time.</p><p>For example: Imagine teaching an AI to play a simple game where it needs to navigate a maze to find a treasure.</p><pre>import random<br><br>def simple_maze_game(action):<br>    # Simplified maze: 0 is path, 1 is wall, 2 is treasure<br>    maze = [0, 0, 1, 0, 2]<br>    current_position = 0<br>    <br>    if action == &quot;right&quot; and current_position &lt; len(maze) - 1:<br>        current_position += 1<br>    <br>    if maze[current_position] == 1:<br>        return -1  # Hit a wall, bad!<br>    elif maze[current_position] == 2:<br>        return 10  # Found the treasure, great!<br>    else:<br>        return 0  # Just moved, neutral<br><br># Let&#39;s play!<br>total_reward = 0<br>for _ in range(5):  # 5 attempts to find the treasure<br>    action = random.choice([&quot;right&quot;, &quot;stay&quot;])<br>    reward = simple_maze_game(action)<br>    total_reward += reward<br>    print(f&quot;Action: {action}, Reward: {reward}&quot;)<br><br>print(f&quot;Total reward: {total_reward}&quot;)</pre><p>This simple game demonstrates how an AI might learn to navigate a maze through trial and error.</p><h3>Wrapping Up: From AI Newbie to… Slightly Less Confused AI Newbie</h3><p>So there you have it — my journey from AI cluelessness to… well, slightly less AI cluelessness. It’s been a wild ride full of “what the heck am I doing” moments, late-night coding sessions, and enough caffeine to power a small country. If there’s one thing I’ve learned, it’s that AI is like a box of chocolates — you never know what you’re gonna get, but it’s probably going to involve Python and a lot of Googling. To all you aspiring AI enthusiasts out there: embrace the confusion, laugh at your mistakes, and remember — even the most sophisticated AI started as a bunch of “if” statements. Happy coding, and may your neural networks be with you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=841039cc29e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Rise of Small Language Models: Democratizing AI]]></title>
            <link>https://sarinbhaskaran.medium.com/the-rise-of-small-language-models-democratizing-ai-02a8799ebcfc?source=rss-d69e530e03c3------2</link>
            <guid isPermaLink="false">https://medium.com/p/02a8799ebcfc</guid>
            <dc:creator><![CDATA[Sarin Bhaskaran]]></dc:creator>
            <pubDate>Tue, 08 Oct 2024 14:26:26 GMT</pubDate>
            <atom:updated>2024-10-08T14:26:26.640Z</atom:updated>
            <content:encoded><![CDATA[<p>Currently we’re witnessing a significant shift in the artificial intelligence (AI) landscape. Small Language Models (SLMs) are emerging as a powerful alternative to their larger counterparts, known as Large Language Models (LLMs). This trend is making advanced language processing more accessible to a wider range of users and businesses. Let’s explore this development and its implications.</p><h3>Understanding SLMs vs LLMs</h3><p>To understand the significance of SLMs, it’s helpful to compare them with LLMs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*KYWdiqU_oHGwnXRKzDbSqQ.png" /></figure><h3>Why is SLM gaining popularity</h3><ol><li><strong>Enhanced Efficiency</strong><br>Unlike LLMs that require substantial computing resources, SLMs can run on less powerful hardware. This efficiency translates to lower operational costs and reduced energy consumption, making AI more accessible to smaller organizations and individual developers.</li><li><strong>Specialized Performance</strong><br>While LLMs excel at general tasks, SLMs are often fine-tuned for specific domains. This specialization allows them to achieve comparable or even superior performance in targeted areas, making them ideal for industry-specific applications.</li><li><strong>Improved Privacy and Security</strong><br>The compact nature of SLMs enables on-device processing, reducing the need to transmit sensitive data to cloud servers. This feature is particularly crucial for applications in healthcare, finance, and other privacy-sensitive sectors, addressing concerns that often arise with cloud-based LLMs.</li><li><strong>Faster Deployment and Iteration</strong><br>Smaller models can be trained and updated more quickly than their larger counterparts. This agility is especially valuable in fast-paced business environments, allowing for rapid iteration and deployment of AI solutions.</li></ol><h3>How does it work</h3><p>Small language models typically use architectures similar to larger models but with reduced layers and parameters. Common architectures include:</p><ul><li><strong>Transformer-Based Models</strong>: Utilize self-attention mechanisms to process input data.</li><li><strong>Recurrent Neural Networks (RNNs)</strong>: Handle sequences of data by maintaining a hidden state.</li></ul><p>These models are trained on large text datasets to learn language patterns. However, due to their smaller size, they require less data and computational power for training.<br>To enhance performance, small language models employ optimization techniques such as:</p><ul><li>Parameter Sharing: Reusing weights across different parts of the model to reduce the total number of parameters.</li><li>Quantization: Reducing the precision of the model’s weights to save space.</li><li>Knowledge Distillation: Transferring knowledge from a larger model to a smaller one.</li></ul><h3>Real-World Applications of SLM</h3><p><strong>Healthcare</strong><br>SLMs are making significant strides in medical applications:</p><ul><li>Analyzing Medical Records: They efficiently process patient histories to extract crucial information.</li><li>Assisting Diagnoses: By analyzing symptoms and test results, SLMs support doctors in making more accurate diagnoses.</li><li>Drug Discovery: Researchers use SLMs to analyze chemical compounds and predict potential new medicines.</li></ul><p>In contrast, LLMs might be used for more comprehensive medical research or handling complex, multifaceted medical queries.</p><p><strong>Smart Devices and Edge Computing</strong><br>SLMs are powering a new generation of intelligent devices:</p><ul><li>Smartphones: Enabling more accurate voice commands and text prediction, even offline.</li><li>IoT Devices: Enhancing the capabilities of smart home systems and wearable technology.</li></ul><p>LLMs, on the other hand, typically power more extensive virtual assistants that require cloud connectivity for their broad knowledge base.</p><p><strong>Language Services</strong><br>SLMs are also impacting language-related tasks:</p><ul><li>Real-Time Translation: Powering earbuds and apps for instant, accurate translations.</li><li>Content Summarization: Providing quick, precise summaries of articles and documents.</li></ul><p>While LLMs excel in generating long-form content and handling complex language tasks, SLMs offer more efficient, specialized language services.</p><p><strong>Business Application</strong><br>Companies are leveraging SLMs in various ways:</p><ul><li>Customer Service Chatbots: Creating more efficient, task-specific AI assistants.</li><li>Market Analysis: Processing data to provide targeted insights into market trends.</li><li>Personalized Marketing: Analyzing customer data for more effective, tailored campaigns.</li></ul><p>LLMs might be used for more comprehensive business intelligence systems or handling a wide range of customer inquiries.</p><h3>Challenges and Limitations</h3><p>Despite their advantages, SLMs face certain challenges:</p><ol><li><strong>Limited Scope</strong> - They may struggle with tasks requiring broad knowledge or complex reasoning, areas where LLMs still excel.</li><li><strong>Training Data Quality</strong> - Performance heavily depends on the quality and relevance of training data.</li><li><strong>Balancing Act</strong> - Developers must carefully balance model size with performance to meet accuracy requirements.</li></ol><h3>Conclusion</h3><p>As SLMs continue to evolve, we can expect:</p><ol><li>Increased Accessibility: More businesses and individual developers will be able to leverage AI technologies.</li><li>Hybrid Approaches: Combinations of SLMs and LLMs may emerge, offering the best of both worlds in terms of efficiency and capability.</li><li>Ethical Considerations: As AI becomes more widespread, discussions around responsible AI development and deployment will intensify.</li></ol><p>The rise of Small Language Models marks a significant step towards democratizing AI. By offering efficient, specialized, and accessible solutions, SLMs are enabling a wider range of organizations and individuals to harness the power of artificial intelligence. While Large Language Models will continue to play a crucial role in complex, broad-spectrum applications, SLMs are opening up new possibilities for targeted, efficient AI solutions across various sectors.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=02a8799ebcfc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Parking Spot Detection: A Case Study on Spot Detection Using .NET and Deep Learning]]></title>
            <link>https://sarinbhaskaran.medium.com/parking-spot-detection-a-case-study-on-spot-detection-using-net-and-deep-learning-7b19587d67bc?source=rss-d69e530e03c3------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b19587d67bc</guid>
            <dc:creator><![CDATA[Sarin Bhaskaran]]></dc:creator>
            <pubDate>Tue, 08 Oct 2024 14:09:32 GMT</pubDate>
            <atom:updated>2024-10-08T14:09:32.030Z</atom:updated>
            <content:encoded><![CDATA[<h3>Parking Spot Detection: A Case Study on Spot Detection Using .NET and Deep Learning</h3><p>In today’s urban landscape, finding a parking spot can be a frustrating experience. This case study explores an innovative solution to this problem using .NET technology and deep learning algorithms. We’ll dive into the challenges, immediate solutions, and long-term strategies for creating an efficient parking spot detection system.</p><h3>The Challenge: Crowdsourcing Parking Information</h3><p>Our task was to develop a system that allows users to report total parking slots and identify empty spots easily. The key requirements were:</p><ol><li>User-friendly interface with photo capture option</li><li>Automatic detection of empty parking spots</li><li>Fast and accurate reporting via API or webhook</li></ol><h3>Immediate Solution: Leveraging YOLO v8 for Quick Results</h3><p>To provide a rapid solution, we turned to the YOLO (You Only Look Once) v8 object detection model. This approach offers several advantages:</p><ul><li>Pre-trained model: YOLO v8 can detect cars out-of-the-box, saving time on model training.</li><li>Simple calculation: Total available parking = Total slots — Detected cars</li><li>.NET integration: Utilizing ONNX runtime for cross-platform compatibility</li></ul><p>Here’s a simplified formula for our immediate solution:</p><pre>int availableSpots = totalParkingSlots - detectedCars;<br></pre><p>Demo Code: For a working example, check out our repo <a href="https://github.com/SarinBhaskaran/ParkingSpotDetection">https://github.com/SarinBhaskaran/ParkingSpotDetection</a></p><h3>Long-Term Solution: Advanced Techniques for Precision</h3><p>While the immediate solution provides quick results, our long-term strategy focuses on increased accuracy and real-time capabilities. This approach combines YOLO with TensorFlow and OpenCV, following these steps:</p><ol><li>Detect available parking spots: Use OpenCV’s edge detection to identify parking lines.</li><li>Identify cars: Apply YOLO to detect vehicles in images or video feeds.</li><li>Calculate occupancy: Utilize Intersection over Union (IoU) to determine if a spot is occupied.</li></ol><h3>Intersection over Union (IoU)</h3><p>IoU is a crucial metric in our long-term solution. It’s calculated as follows:</p><p><em>IoU</em>=<em>AreaofOverlap/AreaofUnion</em></p><p>​We use the Shapely library to compute IoU, considering a parking spot occupied if the IoU exceeds a predefined threshold.</p><h3>Scaling to Real-Time Parking Detection</h3><p>To extend our solution to real-time scenarios, we propose:</p><ol><li>Lightweight models: Implement ThinYOLO for computational efficiency without sacrificing accuracy.</li><li>Pub-sub architecture: Enable real-time updates through a publish-subscribe model.</li><li>CCTV integration: Process live video feeds for up-to-the-minute parking information.</li></ol><h3>Benefits and Conclusion</h3><p>Implementing YOLO-based parking spot detection offers numerous advantages:</p><ul><li>Improved user experience: Quickly guide drivers to available spots</li><li>Increased efficiency: Optimize parking space utilization</li><li>Scalability: Adapt to various parking lot sizes and configurations</li><li>Real-time insights: Enable data-driven decisions for parking management</li></ul><p>By combining .NET technology with cutting-edge deep learning algorithms, we’ve created a powerful solution to the perennial problem of parking. This system not only enhances the user experience but also paves the way for smarter, more efficient urban planning. As we continue to refine and expand this technology, the future of parking looks brighter — and significantly less stressful — for drivers everywhere.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b19587d67bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>