<?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 Ramya Ravi on Medium]]></title>
        <description><![CDATA[Stories by Ramya Ravi on Medium]]></description>
        <link>https://medium.com/@ramyaravi19?source=rss-c0364f3bd739------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*kVsODszRtPtvqxZGmHC6tA.jpeg</url>
            <title>Stories by Ramya Ravi on Medium</title>
            <link>https://medium.com/@ramyaravi19?source=rss-c0364f3bd739------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 21:06:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ramyaravi19/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[Inside agentgateway: How Gateways, Listeners, Routes, and Backends Actually Fit Together]]></title>
            <link>https://medium.com/open-source-journal/inside-agentgateway-how-gateways-listeners-routes-and-backends-actually-fit-together-a7f3aae886b1?source=rss-c0364f3bd739------2</link>
            <guid isPermaLink="false">https://medium.com/p/a7f3aae886b1</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[agentgateway]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Ramya Ravi]]></dc:creator>
            <pubDate>Tue, 03 Nov 2026 22:36:20 GMT</pubDate>
            <atom:updated>2026-12-02T02:37:46.750Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A practical walkthrough of agentgateway’s request pipeline — and why the same four building blocks power service traffic, LLM routing, MCP, and agent-to-agent communication.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_0j8YTQSz23McxZ3tx8PCg.png" /></figure><p>If you’ve looked at <a href="https://agentgateway.dev/">agentgateway</a> and seen it described as “one gateway for service traffic, LLM traffic, MCP, and A2A,” your first question is probably: <em>how is that actually one thing and not four things glued together?</em></p><p>The answer is architectural. agentgateway runs every request — no matter what kind — through the same four-stage pipeline: <br><strong>Gateway </strong>→ → <strong>Listener </strong>→ → <strong>Route </strong>→ → <strong>Backend</strong>. <br>The only thing that changes between calling an internal microservice, calling GPT-4, and invoking an MCP tool is what sits in the last slot: the backend. Everything upstream of that is identical.</p><p>Let’s build this up one piece at a time.</p><p><strong>1. Gateway — the entry point</strong></p><p>A gateway is a named port that agentgateway listens on.</p><pre>gateways: <br><br>  default: <br><br>    port: 3000 </pre><p>That’s it: “traffic arriving on port 3000 is handled here.” A deployment might define multiple gateways if it needs to serve multiple ports for different purposes, but most setups only need one.</p><p><strong>2. Listener — subdividing a gateway</strong></p><p>A listener subdivides a gateway when a single port needs to serve multiple hostnames with different TLS certificates — e.g., api.example.com and admin.example.com both arriving on port 3000 but needing different certs.</p><p>A gateway without listeners has a single implicit listener. Most simple setups skip this entirely and attach everything directly to the gateway.</p><p><strong>3. Route — matching and forwarding</strong></p><p>A route matches incoming requests — by path, hostname, or headers — and decides where they go next.</p><pre>routes: <br><br>- matches: <br><br>  - path: <br><br>      pathPrefix: /api <br><br>  backends: <br><br>  - host: localhost:8000 </pre><p>A route always attaches to a gateway by name — it’s a rule for traffic that came in through that particular port.</p><p><strong>4. Backend — where the request actually lands</strong></p><p>This is the piece that makes everything click. A backend is the final destination, and critically, it isn’t always a plain web service. It can be:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cmQUZEQVzyaHGWrMXsIo7w.png" /></figure><p>This is the core mechanism. The gateway/listener/route machinery is identical regardless of what’s behind it. Swap the backend type, and the exact same pipeline becomes an LLM router, an MCP proxy, or an A2A router. agentgateway isn’t four separate gateways bundled under one name — it’s one pipeline with a pluggable final stage.</p><h3><strong>Putting it together: the full request path</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yTeV1KaF3VIEXp9xsrIEmg.png" /></figure><p>If you’ve seen the simplified llm: or mcp: sections in agentgateway’s quickstart configs, those aren’t a separate system — they’re shortcuts that compile down into this exact same route-and-backend model, so you don’t have to hand-write a full route just to proxy to an MCP server.</p><h3><strong>Policies run at different phases</strong></h3><p>Policies — JWT validation, CORS, rate limiting, MCP authorization, etc — don’t all fire at the same moment. They attach at three distinct points in the pipeline, and each point corresponds to a different phase of request processing:</p><p>Consider MCP authorization — rules like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*Jx5ZZyGrORNgL09pWiMAUQ.png" /></figure><pre>mcpAuthorization: <br><br>  rules: <br><br>  - &#39;mcp.tool.name == &quot;echo&quot;&#39; <br><br>  - &#39;jwt.sub == &quot;test-user&quot; &amp;&amp; mcp.tool.name == &quot;add&quot;&#39; </pre><p>These rules reference a specific tool name. That information doesn’t exist when the request first arrives at the gateway. It only becomes known once agentgateway has parsed the MCP request and knows which tool is being called. That’s why MCP authorization attaches at the route or backend level and is evaluated on each MCP call, never at the gateway level. The architecture reflects what information is actually available at each stage, not an arbitrary design choice.</p><p>If you attach the same kind of policy at multiple levels — say, CORS at both the gateway and a specific route — both apply. They stack rather than override.</p><h3><strong>Why this matters</strong></h3><p>Reading an agentgateway config file stops being guesswork once this pipeline is clear. Any feature -multiplexing multiple MCP servers into one endpoint, routing across multiple LLM providers, applying tool-level authorization — reduces to two questions: what’s sitting in the backend slot, and at which of the three phases does a given policy attach. Looking at where a policy is placed in a config file tells you immediately what information it has access to and when it runs, without needing to memorize a feature-by-feature list.</p><p><em>If you enjoyed this, I write more about AI search, RAG, Agentic AI, and open source technologies. Follow me to catch future posts like this one.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a7f3aae886b1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/open-source-journal/inside-agentgateway-how-gateways-listeners-routes-and-backends-actually-fit-together-a7f3aae886b1">Inside agentgateway: How Gateways, Listeners, Routes, and Backends Actually Fit Together</a> was originally published in <a href="https://medium.com/open-source-journal">Open Source Journal</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RAG is Only as Good as its Search: Why AI Search is the Real Differentiator]]></title>
            <link>https://pub.towardsai.net/rag-is-only-as-good-as-its-search-why-ai-search-is-the-real-differentiator-531d33fbab71?source=rss-c0364f3bd739------2</link>
            <guid isPermaLink="false">https://medium.com/p/531d33fbab71</guid>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[opensearch]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[enterprise-ai]]></category>
            <dc:creator><![CDATA[Ramya Ravi]]></dc:creator>
            <pubDate>Sat, 01 Aug 2026 20:01:01 GMT</pubDate>
            <atom:updated>2026-08-01T20:01:01.463Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HCE_1uNELozkZu-ZmEyeig.png" /></figure><p>There’s a pattern that plays out in almost every RAG implementation. The team spends weeks evaluating language models, GPT-4 vs. Claude vs. Gemini, fine-tuning vs. prompt engineering, temperature settings and system prompts. They get the generation step looking good in demos. Then they ship, and the answers are still wrong.</p><p>Not hallucination-wrong. Not obviously broken. Just quietly, confidently wrong in ways that are hard to pin down and even harder to explain to stakeholders.</p><p>The problem is almost never the language model. It’s retrieval.</p><h4><strong>Are you Drawing your RAG Architecture backwards?</strong></h4><p>When engineers sketch out a RAG system, the LLM usually ends up at the centre, with data feeding in from one side and answers coming out the other. But that’s backwards: the search layer is the system. The LLM is really just the output formatter. Retrieval decides what information the model has to work with, and the model then does something useful with that: summarizing it, synthesizing it, pulling out what’s relevant. But it can’t fix bad inputs. Give it the wrong document and it’ll confidently summarize the wrong document. Give it nothing relevant and it’ll improvise.</p><p>Nearly every quality problem in a RAG system comes down to one of two things. Either retrieval handed the model the wrong context, or it handed over nothing useful at all. The model itself is rarely where things actually go wrong.</p><p>The most important infrastructure decision in a RAG deployment isn’t which LLM you pick. It’s how you build the search layer underneath it.</p><h4><strong>Why Traditional Keyword Search breaks RAG</strong></h4><p>Most enterprise data already lives behind some form of search: an OpenSearch cluster for logs and documents, a database with full-text search, a SharePoint index somewhere. So when teams start building RAG, they naturally reach for whatever’s already there.</p><p>Keyword search, BM25-based retrieval, is genuinely good at what it was built for: finding documents that contain specific terms. For decades it was the best tool around, and for certain kinds of queries it still holds up fine.</p><p>But it breaks RAG in three specific ways.</p><ol><li><strong>The vocabulary mismatch problem — </strong>Users don’t ask questions using the exact words your documents use. A customer asks about “cancelling my subscription.” Your documentation calls it “account termination.” Keyword search comes back empty. The information is right there, but the search can’t bridge the gap between how the user phrased it and how the document was written.<br>This happens constantly in enterprise environments. Different teams describe the same concept differently. Engineers write documentation one way; support staff phrase questions another way. Acronyms, synonyms, domain-specific phrasing, keyword search treats all of it as unrelated, because as far as it’s concerned, it is.</li><li><strong>The intent blindness problem — </strong>Keyword search has no way of grasping what a question is actually trying to accomplish. “Can I get a refund?” and “what is the returns policy?” are asking for the same thing. BM25 sees two unrelated queries and may hand back two unrelated sets of results.<br>That matters because the quality of a RAG answer depends on whether the retrieved context actually addresses what the user was trying to find out, not just whether it happens to share a few words with the question.</li><li><strong>The always-returns-something problem.</strong> Keyword search, like vector search, never comes back empty. It has no way of saying “I don’t have anything relevant here.” So if your enterprise returns policy doesn’t exist as a written document, and you only have the consumer version on file, keyword search will hand over the closest thing it can find. The LLM summarizes that as if it were the answer, and the user walks away with confident misinformation, citation attached.<br>It looks like hallucination. It isn’t. The model didn’t invent anything, it faithfully summarised exactly what retrieval gave it. The failure happened a step earlier.</li></ol><h4><strong>What AI Search actually adds</strong></h4><p>AI search, semantic search built on embedding models and vector similarity, directly fixes the first two problems, and changes how you can even approach the third.</p><p><strong>It retrieves by meaning, not by words.</strong></p><p>An embedding model turns text into a high-dimensional vector, essentially a point in a space where meaning, not exact wording, determines how close two things sit to each other. Documents and queries that mean similar things end up near each other, whether or not they share any vocabulary at all.</p><p>That’s how a search for “how do I reset my credentials” can surface a document titled “Account Recovery Procedures” even though none of those words appear in the query. The meaning lines up, the vectors sit close together, and retrieval succeeds exactly where keyword search would have come up empty.</p><p>OpenSearch’s neural search is built around exactly this idea. A query comes in, it passes through the same embedding model used when the documents were indexed, gets converted into a vector, and OpenSearch finds the nearest matches using approximate nearest neighbour search, all inside the same platform already running your keyword search. No separate vector database bolted on, no extra infrastructure to babysit.</p><p><strong>It picks up on intent in a way keyword search never could.</strong></p><p>Embedding models are trained on enormous amounts of natural language, so they’ve picked up something real about how meaning works, not just which words tend to appear together, but what a question is actually reaching for. Someone asking “am I covered if my laptop gets stolen?” and a document titled “theft protection coverage” end up close together in vector space, because the intent behind the question and the substance of the document line up. The search picks up on that alignment even though the wording doesn’t match at all.</p><p><strong>It gives you a confidence score you can actually do something with.</strong></p><p>Vector similarity returns a distance metric. A high-similarity result is a strong match, a low-similarity one is weak. That opens up something keyword search never really allowed: setting a threshold. If nothing clears a minimum similarity score, the system can say “I don’t have reliable information on that” instead of surfacing a mediocre match and letting the model run with it anyway.</p><p>It doesn’t fully solve the always-returns-something problem, but it gives you a lever to pull. Tuning that threshold against a real evaluation set is one of the more valuable, and more overlooked, calibration steps in a RAG deployment.</p><h4><strong>The Limits of Vector Search, and Why Hybrid Matters</strong></h4><p>Vector search isn’t a silver bullet either. It has its own failure modes, and understanding them is really what separates a search layer that works in a demo from one that holds up once it’s live.</p><p><strong>Precision failures.</strong> Vector search is approximate by design, it finds what’s close, not what’s exact. Search for invoice number “INV-2024–0098” and you might get back a handful of similar-looking invoices instead. For exact identifiers, product codes, order numbers, error codes, contract references, that’s actually a step backwards from keyword search.</p><p><strong>Nuance failures.</strong> Embedding models squeeze meaning into fixed-size vectors, and something gets lost in that compression. The gap between “liability is capped” and “liability is not capped” is one word, but it flips the meaning entirely, and that distinction can wash out in vector space. Two documents reaching opposite legal conclusions can end up sitting right next to each other.</p><p><strong>Domain failures.</strong> General-purpose embedding models are trained on general-purpose text. They don’t necessarily capture your domain’s specific terminology or relationships with much precision. A model that’s great with everyday English can fall apart on specialised legal, medical, financial, or technical content.</p><p>The fix for all three is hybrid search: running semantic vector search and keyword search side by side, then combining what each one finds. They fail in opposite directions, so together they cover each other’s blind spots. Keyword catches exact terms and identifiers where vector search gets fuzzy. Semantic catches meaning and intent where keyword search goes blind. Across real enterprise data, hybrid consistently beats either approach running alone.</p><p>This is one of the places where OpenSearch’s design quietly pays off. Because it stores your text fields and your vector fields in the same index, a hybrid query is a single request, not two separate systems whose results you’re stitching together in application code. The platform runs both searches in parallel and handles the combining itself, through what it calls a search pipeline. At any real scale, that simplicity adds up.</p><p>The combining step is something most articles skip past entirely. BM25 scores and cosine similarity scores sit on completely different scales, so you can’t just merge the two lists and hope for the best. OpenSearch’s normalisation step puts both sets of scores onto a shared scale first, then blends them. You get to decide the weighting, how much to lean toward meaning versus exact terms. A corpus full of identifiers and codes leans keyword-heavy. A conversational knowledge base leans semantic. Where exactly that balance sits is something you tune against your own data, not something you set once and forget.</p><p>Re-ranking sits on top of all that. Once hybrid retrieval returns its top candidates, a cross-encoder model scores each one against the original query with more precision than the retrieval step could manage on its own. In a lot of mature RAG systems, re-ranking ends up being the single biggest quality improvement you can make. OpenSearch runs it as part of the same search pipeline, so retrieve, normalise, and re-rank all happen in one query, with one response, from one platform.</p><h4><strong>AI Search is Infrastructure, Not a Feature</strong></h4><p>Calling AI search a feature, something you bolt on to make search a bit better, undersells what it actually is, and it leads teams to make real architectural mistakes.</p><p>In a RAG system, AI search is the thing everything else stands on.</p><p><strong>The LLM’s quality is bounded by retrieval quality.</strong> Swap in a more capable model and you’ll gain nothing if retrieval keeps handing it the wrong context. Run something smaller and cheaper and you can get excellent answers, as long as retrieval is reliably surfacing the right one. The model sits downstream of search, directly and consequentially.</p><p><strong>Data quality only matters because search expresses it.</strong> A well-maintained corpus, clean metadata, no duplicates, nothing stale, is valuable precisely because good retrieval can actually surface it. That’s the whole point of the search layer: it turns data quality into answer quality. But no search platform, however good, can rescue a badly maintained corpus. It can only find what’s actually there. OpenSearch gives you the filtering, the metadata indexing, the field-level control to make data quality something you can act on. What it can’t do is invent a needle that was never in the haystack to begin with.</p><p><strong>Security and access control belong in the search layer, not somewhere downstream.</strong> Enterprise RAG has to respect whatever permissions already govern the data. If someone isn’t allowed to see a document, retrieval shouldn’t surface it, no matter how relevant it looks. That’s not something you can patch at the model level. OpenSearch’s document-level security handles it right at retrieval time: roles get defined, documents get tagged, and filtering happens before anything reaches the LLM. The model never even sees what the user isn’t supposed to see, because it was never pulled in the first place.</p><p><strong>And evaluation, at its core, is a retrieval question.</strong> When a RAG answer comes back wrong, the first thing to ask is whether retrieval failed to find the right document, or found it and the model failed to use it properly. In practice, across most production systems, it’s almost always the first one. Which tells you where the bulk of your measurement and improvement effort should actually go: into tracking precision, recall, and ranking quality, not just judging the final answer.</p><h4><strong>What this means in practice</strong></h4><p>So what does all this actually change about how you’d build and evaluate a RAG system?</p><p>Start by evaluating retrieval on its own. Build a real evaluation set, actual questions with known correct answers, and measure retrieval quality (precision at k, recall at k, mean reciprocal rank) separately from how the final answer reads. Teams that do this honestly are often surprised by how often retrieval is simply wrong. No amount of prompt tweaking fixes that.</p><p>Default to hybrid rather than pure vector search. If you’re already on OpenSearch, both search types live in the same index and a hybrid query is one API call, so the extra cost is minimal. The quality gain on real enterprise data is consistently worth it. Don’t skip it just because pure vector worked fine in the demo.</p><p>Treat your embedding model as a real system dependency, not an implementation detail. It sets your retrieval ceiling, so it deserves the same scrutiny as your LLM choice. OpenSearch’s ML Commons lets you run embedding models on dedicated ML nodes inside the cluster, with ingest pipelines that generate vectors automatically at index time, so switching models later means re-indexing rather than rewriting application logic. That makes iterating easier, but it also means your first choice matters. Test it against your own domain’s vocabulary before building anything on top of it.</p><p>Design for the “I don’t know” case on purpose. Set a similarity threshold below which the system openly admits it doesn’t have reliable information, rather than quietly surfacing a weak match. It’s an uncomfortable trade-off, some questions will come back unanswered, but it heads off the much worse failure where confident misinformation goes out the door just because something happened to get retrieved.</p><p>And put real effort into data hygiene, proportional to how much you’re investing in retrieval technique. Hybrid search with re-ranking can find the needle. It cannot find a needle that was never there. Stale documents, contradictory versions, duplicates nobody’s cleaned up, none of that gets fixed by better search technique. It’s unglamorous work, and it’s also some of the highest-leverage work available.</p><h4><strong>Conclusion</strong></h4><p>Every conversation about which LLM to use for a RAG system is a conversation that isn’t happening about retrieval quality, data freshness, hybrid search tuning, and evaluation. Those are the harder conversations to have. The answers are messier, the improvements take longer to show up, and there’s no leaderboard ranking retrieval quality on your specific domain.</p><p>But they’re the conversations that actually matter.</p><p>The LLM will keep getting better. Whatever’s released six months from now will outperform what’s available today, and that improvement will compound on top of good retrieval, and mostly go to waste on top of bad retrieval.</p><p>OpenSearch has quietly become the practical foundation for a lot of production AI search, not because it’s the newest thing out there, but because it brings keyword search, neural search, hybrid pipelines, re-ranking, access control, and real operational maturity together in one platform that enterprises already know how to run. The teams getting the most out of it aren’t the ones who tacked neural search onto an existing cluster as an afterthought. They’re the ones who rebuilt their retrieval layer from the ground up with AI search as the foundation, and then actually measured whether it worked.</p><p>The teams building AI systems people can trust are the ones treating retrieval as the system itself. Not the LLM, not the prompt, not how big the model is. The ones who measured it, tuned it, and built their data infrastructure around it from the start.</p><p>AI search isn’t something you bolt onto RAG. It’s the infrastructure RAG runs on. Treat it that way.</p><p><em>NetApp Instaclustr provides fully managed OpenSearch with native support for neural search, hybrid search pipelines, ML Commons, and document-level security, the retrieval layer that enterprise RAG runs on.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=531d33fbab71" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/rag-is-only-as-good-as-its-search-why-ai-search-is-the-real-differentiator-531d33fbab71">RAG is Only as Good as its Search: Why AI Search is the Real Differentiator</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The 5 Concepts Every Developer Should Understand Before Building AI Features]]></title>
            <link>https://pub.towardsai.net/the-5-concepts-every-developer-should-understand-before-building-ai-features-22d5c5b78de0?source=rss-c0364f3bd739------2</link>
            <guid isPermaLink="false">https://medium.com/p/22d5c5b78de0</guid>
            <category><![CDATA[ai-search]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[genai]]></category>
            <dc:creator><![CDATA[Ramya Ravi]]></dc:creator>
            <pubDate>Mon, 11 May 2026 12:01:00 GMT</pubDate>
            <atom:updated>2026-05-11T12:01:00.607Z</atom:updated>
            <content:encoded><![CDATA[<h4>Build AI features that hold up in production.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ORov_3lx31yFV2Az31OTVg.png" /></figure><p>These days, adding an AI feature to your application is easier than ever — a few API calls, a model endpoint, some glue code, and you have semantic search, summarization, or a chatbot working. The hard part is not building it but understanding what is actually happening underneath — because that is what determines whether your feature holds up when real users arrive.</p><p>Here are five foundational concepts that show up in nearly every AI feature you will build. If you get these right, the rest of your architectural decisions become considerably easier.</p><p><strong>1. Tokens</strong></p><p>A token is the unit of text an AI model operates on — sometimes a whole word, sometimes a fragment, sometimes punctuation. The sentence “I love building things” is roughly four tokens. A less common word like “reindexing” might be split into two or three tokens because that word does not appear frequently enough in the model’s training data to be assigned its own token.</p><p>Tokens matter because every AI model has a token limit per request. Send too much, and the model truncates, refuses, or returns lower-quality output.</p><p><strong><em>Note: </em></strong><em>Before integrating any AI model, check its token limit and design your data pipeline around it. If you are summarizing documents or building a knowledge base, plan your chunking strategy upfront — not after a user submits a 50-page PDF.</em></p><p><strong>2. Embeddings</strong></p><p>An embedding is a piece of text converted into a fixed-size list of numbers that represents its meaning. Similar content produces similar numbers. Different content produces very different numbers.</p><p>This is what powers semantic search, recommendation engines, duplicate detection, and most AI-driven retrieval features. It is also what makes a search for “comfortable running shoes” return athletic footwear results without sharing a single word. In production, these embeddings live in dedicated vector field types — like <a href="https://www.instaclustr.com/blog/understanding-opensearch-vector-field-types-part-1-knn-vector/">OpenSearch’s knn_vector </a>— that are designed for similarity search at scale.</p><p>Two things developers consistently miss:</p><ul><li>Embeddings are model-specific, and numbers produced by one model are not compatible with another. If you switch models, then every stored embedding becomes meaningless, and you will be reindexing.</li><li>Dimensions matter and different models produce different-length embeddings — 384, 768, 1536. Length affects storage cost, query latency, and how much meaning the model can encode.</li></ul><p><strong><em>Note: </em></strong><em>Remember to treat your embedding model choice like a database schema decision. Document the model and version and plan reindexing workflows before you need them.</em></p><p><strong>3. Context Windows</strong></p><p>Large language models process input as a single block of text — the context window. The model can only reason about what is in the window, and anything outside it does not exist as far as the model is concerned.</p><p>This catches developers off guard in two common scenarios:</p><ul><li>Long chatbot conversations — when the conversation exceeds the context window, your application has to drop earlier messages before sending them to the model. From the user’s perspective, the chatbot “forgets” what they said.</li><li>Long documents — feed in a document larger than the context window, and depending on the model, the request might be rejected with an error; the input gets silently truncated, or the output quality degrades. For self-hosted models running on GPUs, oversized inputs can also trigger out-of-memory crashes.</li></ul><p>The patterns for handling this are well-established:</p><ul><li>Chunking — break content into smaller pieces and process them individually</li><li>Retrieval-augmented generation (RAG) — retrieve only the most relevant content and include only that in the context</li><li>Summarization pipelines — compress earlier content before adding new content</li></ul><p><strong><em>Note: </em></strong><em>Design your data pipeline with the context window as a first-class constraint. Discovering the limit only when a user submits a real-world input is one of the most common production failures.</em></p><p><strong>4. Semantic vs. Keyword Search</strong></p><p>Keyword search finds documents that contain the typed words. It is exact, fast, and predictable.</p><p>Semantic search finds documents that mean what was typed, using embeddings to match conceptual similarity. It handles vocabulary variation gracefully — different words for the same concept.</p><p>The common mistake is assuming semantic search is simply better and should replace keyword search. It should not.</p><p>Semantic search dilutes precise terms. A developer searching for an exact function name. A user looking up a specific product code. A medical professional searching for a diagnostic code. These queries depend on exact terminology, and semantic search can return conceptually similar — but terminologically wrong — results.</p><p>Most production search systems use both. Search platforms like OpenSearch make this straightforward through hybrid search — combining semantic and keyword retrieval in a single pipeline. Semantic search handles conceptual queries and keyword search anchors specific terms. This combination serves a wider range of real user behavior than either approach alone. And when term-level precision is non-negotiable — exact product codes, technical terminology, medical codes — OpenSearch also offers <a href="https://www.instaclustr.com/blog/understanding-opensearch-vector-field-type-part-2-sparse_vector/">sparse_vector</a>, a field type that preserves the importance of specific terms inside the vector representation itself.</p><p><strong><em>Note: </em></strong><em>Define what a failed search looks like for your users. That answer tells you which approach to weight — or whether you need both.</em></p><p><strong>5. Approximate vs. Exact Search</strong></p><p>A traditional database query returns exact, deterministic results — every matching row appears, and no matches are missed.</p><p>Vector search does not work this way. Computing the mathematically exact nearest neighbors across millions of embeddings is too expensive at scale. Most vector systems use approximate nearest neighbor (ANN) search instead — clever algorithms that find results that are very likely to be the closest matches without scanning every document.</p><p>The trade-off is small recall loss for major speed gain. You might miss one or two highly relevant documents in some queries, and in most production systems, users do not notice.</p><p>But it matters in:</p><ul><li>Safety-critical applications where a missed result has consequences</li><li>Legal or compliance search where completeness is required</li><li>Small datasets where exact search is fast enough that approximation is unnecessary</li></ul><p><strong><em>Note: </em></strong><em>Most vector search tools (including OpenSearch) expose a setting that controls the trade-off between speed and recall. Check the default in your tool and decide whether it matches your application’s tolerance for missed results.</em></p><h3><strong>Why These Five</strong></h3><p>Tokens, embeddings, context windows, semantic vs. keyword search, and approximate vs. exact search are not the only concepts worth knowing. But they shape the most consequential decisions you make in the first weeks of building an AI feature — decisions about data pipelines, model selection, search architecture, and production behavior.</p><p>Every AI feature touches at least three of these. Most touch all five.</p><p>The mental model these concepts give you is what turns “it works in the demo” into “it still works six months later when real users do unexpected things.”</p><p><em>Which of these have caught you off guard in production? Drop your story below — always curious how other developers learn these the hard way.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22d5c5b78de0" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/the-5-concepts-every-developer-should-understand-before-building-ai-features-22d5c5b78de0">The 5 Concepts Every Developer Should Understand Before Building AI Features</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Fine-Tuning to Inference: The New LLM Optimization Stack with Unsloth, SGLang, and AutoAWQ]]></title>
            <link>https://pub.towardsai.net/from-fine-tuning-to-inference-the-new-llm-optimization-stack-with-unsloth-sglang-and-autoawq-405e113ff5e0?source=rss-c0364f3bd739------2</link>
            <guid isPermaLink="false">https://medium.com/p/405e113ff5e0</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[ai-tools]]></category>
            <dc:creator><![CDATA[Ramya Ravi]]></dc:creator>
            <pubDate>Sun, 12 Oct 2025 23:02:07 GMT</pubDate>
            <atom:updated>2025-10-12T23:02:07.138Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W66-KhklRCIlnO6-H5DB3Q.jpeg" /></figure><p>Training and deploying LLMs has remained expensive and resource-intensive as LLMs become more powerful. In recent times, a new generation of lightweight AI optimization frameworks has emerged, which enables developers to train, compress, and serve models more efficiently.</p><p>This new stack is built around three core frameworks:</p><ul><li>Unsloth — accelerates fine-tuning with memory-efficient kernels</li><li>AutoAWQ — automates quantization to shrink models for cheaper inference</li><li>SGLang — provides high-throughput and structured inference for production</li></ul><p>This stack creates a seamless, end-to-end workflow that reduces compute costs, accelerates experimentation, and scales better than traditional stacks.</p><p>Let’s look at each framework, why it matters, and how they fit together to give AI developers a high-performance and cost-effective workflow.</p><h4>1. Unsloth — Fast &amp; Efficient Fine-Tuning</h4><p>Fine-tuning has traditionally been one of the biggest bottlenecks in working with LLMs. Even for mid-sized models with ~7B parameters, running full fine-tuning or LoRA requires massive GPU memory and long training cycles.</p><p>Unsloth solves this with kernel-level optimizations and efficient LoRA/QLoRA implementations. Also, it supports popular models such as LLaMA, Mistral, Phi, and Gemma.</p><p><strong>Key Benefits</strong></p><p>· 2–3x faster training compared to standard Hugging Face + PEFT setups</p><p>· Memory-efficient LoRA/QLoRA implementations — train 7B-13B models on consumer GPUs</p><p>· Optimized CUDA kernels for transformer layers to reduce training overhead</p><p><strong>Example — How to fine-tune a Llama 3 model</strong></p><pre># Install Unsloth<br>pip install unsloth<br><br># Start fine-tuning<br>unsloth finetune \<br>  --model llama-3-8b \<br>  --dataset ./data/instructions.json \<br>  --output ./finetuned-llama \<br>  --lora-r 8 --lora-alpha 16 --bits 4</pre><p>Unsloth allows developers and startups to train models at a fraction of the usual cost, without needing large GPU clusters.</p><h4>2. AutoAWQ — Smarter Quantization, Smaller Models</h4><p>After fine-tuning, LLM models are still typically too large for cost-effective inference. That’s where AutoAWQ comes in. AutoAWQ automates the quantization process for popular LLM architectures, building on top of the AWQ (Activation-Aware Weight Quantization) method. It applies AWQ automatically, reducing precision while maintaining accuracy.<br> <br><strong> Key Benefits</strong></p><p>· Reduce model size by 50–75% with INT4 quantization</p><p>· Compatible with Unsloth fine-tuned models and SGLang inference</p><p>· Enables running large models on consumer or edge hardware</p><p>· Cuts inference costs drastically</p><p><strong>Quantization Example</strong></p><pre># Install AutoAWQ<br>pip install autoawq<br><br># Quantize your model<br>autoawq quantize \<br>  --model ./finetuned-llama \<br>  --output ./llama-awq \<br>  --wbits 4</pre><p>By using AutoAWQ after fine-tuning, before deployment, you can shrink your models and reduce inference costs at scale.</p><h4>3. SGLang — High-Performance Structured Inference</h4><p>After training the model, the next challenge is serving it efficiently. SGLang is a next-generation inference engine built for structured generation and high throughput. It can act as a drop-in replacement for inference frameworks like vLLM while offering more control over the structure of generated outputs which is ideal for applications like function calling, JSON generation, or agent frameworks.</p><p>SGLang uses vLLM’s optimized runtime but adds an abstraction layer to make structured and multi-step generation easier.</p><p><strong>Key Benefits</strong></p><p>· Faster inference through optimized KV cache handling and token streaming</p><p>· Structured output support — ensures models produce parseable, predictable formats (no regex hacks)</p><p>· High throughput for multi-user environments</p><p>· Lightweight and production-ready without custom hacks</p><p><strong>Serving Example</strong></p><pre># Install SGLang<br>pip install sglang<br><br># Serve your Model<br>sglang serve --model ./llama-awq --port 8080</pre><p>Then, you can send structured queries:</p><pre>from sglang.client import Client<br><br>client = Client(&quot;http://localhost:8080&quot;)<br><br>response = client.generate(<br>    prompt=&quot;Return a JSON object with two fields: framework and benefit&quot;,<br>    format=&quot;json&quot;<br>)<br><br>print(response.text)</pre><p>With SGLang, developers can scale inference to thousands of concurrent users while keeping responses well-structured for downstream applications.</p><h4>How do these frameworks fit together?</h4><p>By combining Unsloth, AutoAWQ, and SGLang, developers can build an end-to-end pipeline:</p><p>1. Fine-tune with Unsloth — Fast, efficient training even on single GPUs</p><p>2. Quantize with AutoAWQ — Shrink models for cheaper, faster inference</p><p>3. Serve with SGLang — Deploy structured, high-throughput inference at scale</p><p>Together, they form a modern, modular optimization workflow that saves money, accelerates development, and scales production.</p><h4>Summary and Next Steps</h4><p>If you’re an AI developer, now is the time to experiment with this modular stack. These frameworks reflect a broader shift in the AI ecosystem:</p><p>· Instead of one-size-fits-all tools, developers are assembling tailored stacks</p><p>· GPU time = money — optimization directly impacts viability</p><p>· These tools let small teams do what they used to require large research labs</p><p>· Fine-tuning, quantization, and serving are becoming plug-and-play</p><p>While Unsloth, AutoAWQ, and SGLang cover the core stages, the ecosystem is evolving rapidly. Some complementary tools worth noting are vLLM (great choice for high-throughput inference, especially for cloud-native deployments), Axolotl (popular fine-tuning orchestration tool that can integrate with Unsloth).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=405e113ff5e0" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/from-fine-tuning-to-inference-the-new-llm-optimization-stack-with-unsloth-sglang-and-autoawq-405e113ff5e0">From Fine-Tuning to Inference: The New LLM Optimization Stack with Unsloth, SGLang, and AutoAWQ</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to LLM Serving Frameworks: How to Host Language Models]]></title>
            <link>https://pub.towardsai.net/introduction-to-llm-serving-frameworks-how-to-host-language-models-59ded8eb9657?source=rss-c0364f3bd739------2</link>
            <guid isPermaLink="false">https://medium.com/p/59ded8eb9657</guid>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[genai]]></category>
            <dc:creator><![CDATA[Ramya Ravi]]></dc:creator>
            <pubDate>Tue, 24 Jun 2025 20:01:38 GMT</pubDate>
            <atom:updated>2025-06-24T20:01:38.934Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*loQZOH0tILTYgsHSsN5_aA.png" /></figure><p>Deploying LLMs in real-world applications goes far beyond loading weights and generating text. It’s about addressing key challenges like reducing latency, scaling across GPUs, efficiently routing between models, and exposing reliable APIs. To overcome these challenges, LLM serving frameworks provide optimized inference performance, built-in autoscaling capabilities, uniform API standards, and close integration with retrieval systems and agent toolkits.</p><p>In this article, we’ll look at the different types of LLM serving frameworks and demonstrate when to use each with code snippets to get started.</p><h3>What is an LLM Serving Framework?</h3><p>LLM serving framework is a software platform built to handle the deployment, execution, and management of LLMs at production scale. These frameworks allow us to deploy LLMs at scale without building complex serving infrastructure from scratch.</p><p>It handles tasks like:</p><p>· Loading and running large models on GPUs or CPUs</p><p>· Managing API requests for chat, completions, and embeddings</p><p>· Batching and scheduling requests to maximize efficiency</p><p>· Scaling horizontally across machines or GPUs</p><p>· Exposing REST or OpenAI-compatible APIs</p><h3>Types of LLM Serving Frameworks</h3><p><strong>A. Optimized Inference Engines:</strong> These frameworks focus on delivering low latency and high token throughput. They deliver optimized GPU utilization and high-throughput token generation, with support for OpenAI-compatible API endpoints.<br><strong>Examples:</strong> vLLM, Text Generation Inference (TGI), and TensorRT-LLM<br><strong>When to Use:</strong><br>· For serving single models<br>· APIs that demand fast response times<br><strong>Architecture:</strong></p><pre>[Client Request]<br>      ↓<br>[REST / OpenAI-Compatible API]<br>      ↓<br>[LLM Inference Server (vLLM / TGI)]<br>  ├── Batching scheduler<br>  ├── GPU memory manager<br>  └── Token generator<br>      ↓<br>[Response to client]</pre><p><strong>Code Example: </strong>How to launch a simple OpenAI-style API server using vLLM</p><pre>pip install vllm<br>python -m vllm.entrypoints.openai.api_server \<br>  --model facebook/opt-1.3b \<br>  --port 8000</pre><p><strong>B. Orchestration and Autoscaling Frameworks:</strong> These manage the deployment of multiple models or services, handle autoscaling, routing, and lifecycle management in cloud or distributed environments.<br><strong>Examples:</strong> Ray Serve, Modal, and KServe<br><strong>When to Use:</strong><br>· Multi-model coordination<br>· Agent workflows<br>· Cloud-scale systems<br><strong>Architecture:</strong></p><pre>[Client Request]<br>      ↓<br>[API Gateway / Load Balancer]<br>      ↓<br>[Orchestrator (Ray Serve / Modal)]<br>  ├── Route to appropriate model/service<br>  ├── Autoscale workers<br>  ├── Health &amp; lifecycle management<br>      ↓<br>[LLM worker / tool / embedding service]<br>      ↓<br>[Response to client]</pre><p><strong>Code Example: </strong>How to deploy a Hugging Face sentiment analysis model via Ray Serve</p><pre>from ray import serve<br>from transformers import pipeline<br><br># Initialize Ray Serve<br>serve.start()<br><br>@serve.deployment<br>class SentimentService:<br>    def __init__(self):<br>        self.classifier = pipeline(&quot;sentiment-analysis&quot;)<br><br>    async def __call__(self, request):<br>        data = await request.json()<br>        text = data.get(&quot;text&quot;, &quot;&quot;)<br>        result = self.classifier(text)<br>        return result<br><br># Deploy the service<br>SentimentService.deploy()<br><br># The service is now accessible at http://127.0.0.1:8000</pre><p><strong>C. Integrated RAG &amp; Agent Frameworks:</strong> These provide retrieval, memory, and chaining features alongside model serving.<br><strong>Examples:</strong> LangChain, LlamaIndex, and Haystack<br><strong>When to Use:<br></strong>· Knowledge bots<br>· Q&amp;A systems<br>· Rapid prototyping<br><strong>Architecture:</strong></p><pre>[Client Query]<br>      ↓<br>[LangChain / LlamaIndex Pipeline]<br>  ├── Retrieve context from Vector DB (Chroma / Pinecone)<br>  ├── Inject retrieved docs into prompt<br>  ├── Call LLM (via vLLM / OpenAI / TGI)<br>  └── Optional: Chain to tool or function<br>      ↓<br>[Answer returned to client]</pre><p><strong>Code Example: </strong>A simple RAG pipeline using LangChain, Chroma, and an OpenAI-compatible LLM API</p><pre>from langchain.vectorstores import Chroma<br>from langchain.embeddings import HuggingFaceEmbeddings<br>from langchain.llms import OpenAI<br>from langchain.chains import RetrievalQA<br><br>vectorstore = Chroma(persist_directory=&quot;./db&quot;, embedding_function=HuggingFaceEmbeddings())<br>llm = OpenAI(base_url=&quot;http://localhost:8000/v1&quot;, openai_api_key=&quot;EMPTY&quot;)<br>qa = RetrievalQA.from_chain_type(llm=llm, retriever=vectorstore.as_retriever())<br>print(qa.run(&quot;What is LoRA fine-tuning?&quot;))</pre><h3>LLM Deployment Best Practices</h3><p><strong>1. Start Small and Scale Gradually: </strong>Test your pipeline on a single CPU or GPU, then scale out smoothly using autoscaling frameworks like Ray Serve.</p><p><strong>2. Use Batching to Maximize Throughput: </strong>Batching aggregates multiple requests, optimizing GPU utilization and maximizing token throughput. vLLM and TGI can handle this automatically.</p><p><strong>3. Monitor Latency and Throughput Closely: </strong>Use tools such as Prometheus and Grafana to monitor latency, GPU usage, and errors, integrating these into your orchestration stack for real-time insights.</p><p><strong>4. Leverage Mixed Precision and Quantization: </strong>FP16 and INT8 models reduce memory usage and speed up inference while keeping accuracy high.</p><p><strong>5. Isolate Models and Services: </strong>Run models and auxiliary services (like vector stores or embedding APIs) in isolated containers or services to improve fault isolation and maintainability.</p><p><strong>6. Secure Your Endpoints:</strong> Apply authentication, rate limits, and encryption to secure endpoints and protect against misuse.</p><h3>Conclusion</h3><p>The world of LLM serving frameworks is evolving fast, unlocking new opportunities for building powerful AI applications. By choosing frameworks that match your performance and scalability requirements today — and staying informed about trends like modular designs and multi-modal capabilities — you can create AI systems that are both innovative and future-ready.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59ded8eb9657" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/introduction-to-llm-serving-frameworks-how-to-host-language-models-59ded8eb9657">Introduction to LLM Serving Frameworks: How to Host Language Models</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LLMs vs AI Agents: What’s the Difference, and Why It Matters]]></title>
            <link>https://medium.com/@ramyaravi19/llms-vs-ai-agents-whats-the-difference-and-why-it-matters-4c65ffdae819?source=rss-c0364f3bd739------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c65ffdae819</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[agents]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Ramya Ravi]]></dc:creator>
            <pubDate>Wed, 18 Jun 2025 13:48:09 GMT</pubDate>
            <atom:updated>2025-06-18T13:48:09.638Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M-NmN4JMGEjCyv5ziTcHmQ.png" /></figure><p>As AI developers, we have used LLMs like GPT-4, Claude, or Llama. These models are proficient in understanding natural language, creating content, and reasoning through problems. But the moment you try to build something that acts toward a goal — not just responds— you’ll start to see where LLMs fall short. This is where AI agents come in.</p><p>In this article, we will dive into what sets these approaches apart and discuss when and how to use them effectively in your applications. We’ll also explore why traditional programming is still the best tool for certain tasks.</p><h3>What are LLMs?</h3><p>LLMs are deep learning architectures trained on diverse, large-scale text data, designed to understand and generate natural language. They are well-suited for single-turn tasks such as:</p><p>· NLP: Sentiment analysis, summarization, translation</p><p>· Content creation: Writing, code generation, chatbots</p><p><strong>Limitations of LLMs</strong></p><p>· Stateless: No persistent memory between interactions</p><p>· Passive: Cannot interact with external tools</p><p>· Context-limited: Complete dependence on the input prompt for context</p><p>· Task-challenged: Difficulty handling multi-step tasks or long-term planning</p><p>For example, building goal-oriented assistants or smart productivity tools requires agent-based architecture — prompting alone isn’t enough.</p><h3>What are AI Agents?</h3><p>An agent is a system that uses an AI model (often an LLM), which serves as its core reasoning engine. It is designed to:</p><p>· Interpret and understand human instructions.</p><p>· Analyze information, determine next steps, and plan strategically to solve problems.</p><p>· Interact dynamically with its environment by executing tasks and evaluating outcomes.</p><p><strong>Key functions of AI Agents: Capabilities Beyond LLMs</strong></p><p>1. Handles multi-step tasks</p><p>2. Access real-time data</p><p>3. Maintain long-term memory</p><p>4. Use external systems like files, APIs or databases</p><p>5. Dynamic goal planning</p><p><strong>Architecture Workflow</strong></p><pre>[1] User Input<br>   ⬇<br> Natural Language Instruction<br><br>[2] Language Model (LLM)<br>   ⬇<br> Core Reasoning Engine  <br> - Parses input<br> - Understands intent<br> - Performs step-level reasoning<br><br>[3] Agent Controller / Task Planner<br>   ⬇<br> Orchestrates tasks  <br> - Breaks down the goal  <br> - Plans the sequence of actions  <br> - Selects tools or APIs<br><br>[4] Memory Module (optional)<br>   ⬇<br> Short-term or long-term memory  <br> - Stores context, history, results  <br> - Enhances personalization and state tracking<br><br>[5] Tool &amp; API Executor<br>   ⬇<br> Executes actions via:<br> - Web search  <br> - Code execution  <br> - API calls  <br> - File I/O  <br> - Database queries<br><br>[6] Iteration &amp; Feedback Loop<br>   ⬇<br> - Validates outcomes  <br> - Handles errors  <br> - Retries or re-plans steps<br><br>[7] Output Generator<br>   ⬇<br> Final response or completed task</pre><h3>Top Frameworks for building AI Agents — from lightweight tools to multi-agent systems</h3><p>· AutoGen: Microsoft’s multi-agent framework where agents can collaborate and self-improve.</p><p>· LangGraph: A flow-based execution model for stateful or multi-agent systems.</p><p>· LlamaIndex: Helps agents retrieve and reason over large external datasets.</p><p>· smolagents: A minimal, developer-first framework that turns LLMs into code-writing bots.</p><p><strong><em>Tip:</em></strong><em> While AI agents are powerful, traditional programming is often the better choice for tasks that demand determinism, speed, and control. Unlike agents, whose probabilistic reasoning can introduce variability — code executes exactly as written, making it more predictable and reliable.</em></p><p><em>The most effective systems are hybrid — combining LLMs for reasoning, traditional programming for structure, and agents for real-world execution.</em></p><h3>Conclusion</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OCB3yi72U5mOPilq59_Psg.jpeg" /></figure><p>To summarize, LLMs and AI Agents are foundational to today’s AI systems. Understanding when and how to deploy these technologies can significantly enhance your development process — enabling you to build more robust, flexible, and intelligent applications, whether it’s a chatbot, an autonomous agent, or a complex multimodal system.</p><p><em>Thanks for reading! </em><a href="https://medium.com/@ramyaravi19"><em>Follow my profile</em></a><em> for more content on AI, LLMs, and beyond.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c65ffdae819" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LLM Customization Cheat Sheet: Fine-Tuning vs. LoRA vs. RAG Explained]]></title>
            <link>https://medium.com/@ramyaravi19/llm-customization-cheat-sheet-fine-tuning-vs-lora-vs-rag-explained-bc43aa713b34?source=rss-c0364f3bd739------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc43aa713b34</guid>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[fine-tuning]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Ramya Ravi]]></dc:creator>
            <pubDate>Mon, 16 Jun 2025 13:35:39 GMT</pubDate>
            <atom:updated>2025-06-16T13:35:39.276Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZhnIuI7_1vubc9OvW8Vj0w.png" /></figure><p>With the rise of powerful foundation models, customizing LLMs for domain-specific tasks is both essential and more feasible than ever. But when should you use fine-tuning, Low-Rank Adaptation (LoRA), or RAG? This cheat sheet walks you through the options and shows when each approach makes the most sense.</p><h3>1. Fine-Tuning — Maximum Control, Maximum Effort</h3><p>Fine-tuning is the process of adapting a pre-trained LLM by training it further on your own dataset. Adjusting the model’s weights tailors its performance to better handle specific tasks or domains.</p><p><strong>When to Use</strong></p><p>· Your task is closely aligned with the pre-trained model’s capabilities.</p><p>· You have a substantial amount of labeled data specific to your task.</p><p><strong>When to Avoid</strong></p><p>· You have limited compute resources.</p><p>· You need frequent updates or when operating in a rapidly changing domain.</p><p><strong>Code</strong></p><pre>from transformers import AutoTokenizer, AutoModelForCausalLM, Trainer, TrainingArguments<br>from datasets import load_dataset<br><br># Load model and tokenizer<br>model = AutoModelForCausalLM.from_pretrained(&quot;tiiuae/falcon-7b&quot;, device_map=&quot;auto&quot;, load_in_8bit=True)<br>tokenizer = AutoTokenizer.from_pretrained(&quot;tiiuae/falcon-7b&quot;)<br><br># Load dataset<br>dataset = load_dataset(&quot;your_dataset_name&quot;)[&quot;train&quot;]<br><br># Define training config<br>training_args = TrainingArguments(<br>    output_dir=&quot;./finetuned&quot;,<br>    num_train_epochs=3,<br>    per_device_train_batch_size=2,<br>    fp16=True<br>)<br><br>trainer = Trainer(<br>    model=model,<br>    args=training_args,<br>    train_dataset=dataset,<br>)<br><br>trainer.train()</pre><p><strong><em>Key Difference in the code:</em></strong><em> All model weights updated — high compute &amp; storage cost.</em></p><h3>2. LoRA — Efficient, Adaptable, Lightweight</h3><p>LoRA is a lightweight fine-tuning strategy for LLMs that introduces low-rank matrices to reduce training overhead. By freezing the original weights and training only a few new parameters, it enables efficient model adaptation with minimal compute.</p><p><strong>When to Use</strong></p><p>· You want the benefits of fine-tuning but with lower cost and compute.</p><p>· You’re dealing with limited labeled data.</p><p>· You want to preserve the original model’s weights while enabling task-specific performance.</p><p><strong>When to Avoid</strong></p><p>· You need real-time factual updates.</p><p>· You require significant shifts in base model behavior.</p><p><strong>Code</strong></p><pre>from peft import get_peft_model, LoraConfig, TaskType<br>from transformers import AutoModelForCausalLM, AutoTokenizer, Trainer, TrainingArguments<br>from datasets import load_dataset<br><br># Load base model<br>model = AutoModelForCausalLM.from_pretrained(&quot;tiiuae/falcon-7b&quot;, load_in_8bit=True, device_map=&quot;auto&quot;)<br>tokenizer = AutoTokenizer.from_pretrained(&quot;tiiuae/falcon-7b&quot;)<br><br># Inject LoRA adapters<br>lora_config = LoraConfig(<br>    r=8,<br>    lora_alpha=32,<br>    target_modules=[&quot;query_key_value&quot;],<br>    lora_dropout=0.05,<br>    task_type=TaskType.CAUSAL_LM<br>)<br>model = get_peft_model(model, lora_config)<br><br># Load dataset<br>dataset = load_dataset(&quot;your_dataset_name&quot;)[&quot;train&quot;]<br><br># Define training<br>training_args = TrainingArguments(<br>    output_dir=&quot;./lora-adapter&quot;,<br>    per_device_train_batch_size=4,<br>    num_train_epochs=3<br>)<br><br>trainer = Trainer(<br>    model=model,<br>    args=training_args,<br>    train_dataset=dataset<br>)<br><br>trainer.train()</pre><p><strong><em>Key Difference in the code:</em></strong><em> Only adapter weights are trained — low cost, highly modular.</em></p><h3>3. RAG: Factual, Flexible, and Scalable</h3><p>RAG combines an LLM with an external knowledge source (typically a vector database). It retrieves contextually relevant documents from a knowledge base and integrates them into the LLM’s response to improve accuracy and relevance.</p><p><strong>When to Use</strong></p><p>· Your application requires up-to-date, factual, or large-scale data.</p><p>· You want to avoid training and rely on structured/unstructured data.</p><p>· For tasks like question-answering or conversational agents that benefit from contextual information.</p><p><strong>When to Avoid</strong></p><p>· You need high-speed inference (retrieval adds latency).</p><p>· You lack infrastructure for data ingestion, chunking, and embedding.</p><p><strong>Code</strong></p><pre>from llama_index.core import VectorStoreIndex, SimpleDirectoryReader<br>from llama_index.llms import OpenAI<br>from llama_index.embeddings import HuggingFaceEmbedding<br><br># Load docs and build vector index<br>documents = SimpleDirectoryReader(&quot;docs/&quot;).load_data()<br>embed_model = HuggingFaceEmbedding(model_name=&quot;BAAI/bge-base-en&quot;)<br>index = VectorStoreIndex.from_documents(documents, embed_model=embed_model)<br><br># Create query engine<br>query_engine = index.as_query_engine()<br>response = query_engine.query(&quot;How can I reset my account password?&quot;)<br>print(response)</pre><p><strong><em>Key Difference in the code: </em></strong><em>No fine-tuning — frozen model, context-driven behavior.</em></p><h3>Hybrid Approaches</h3><p>You can apply a combination of these methods:</p><ul><li>RAG + LoRA: Retrieve latest data + domain-specific tone</li><li>Fine-Tuning + RAG: Deep behavior shaping + retrieval-based augmentation</li></ul><h3>Conclusion</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9gX8nY1_QL-GMBCI8pnmsw.jpeg" /></figure><p>Choosing the right LLM adaptation method — whether you go with fine-tuning, LoRA, or RAG depends on your specific use case, the size and domain of your dataset, and the computing power at hand. This cheat sheet will help you navigate your options and remember combining methods can often lead to stronger, more flexible AI systems.</p><p><em>Thanks for reading! If you found this helpful, </em><a href="https://medium.com/@ramyaravi19"><em>follow my profile</em></a><em> for more technical deep dives on AI, LLMs, and beyond.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc43aa713b34" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Mixture of Experts (MoE)?The Key to Smarter, Faster AI Models]]></title>
            <link>https://medium.com/@ramyaravi19/what-is-mixture-of-experts-moe-the-key-to-smarter-faster-ai-models-7fc2b0d331c4?source=rss-c0364f3bd739------2</link>
            <guid isPermaLink="false">https://medium.com/p/7fc2b0d331c4</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Ramya Ravi]]></dc:creator>
            <pubDate>Fri, 13 Jun 2025 02:00:15 GMT</pubDate>
            <atom:updated>2025-06-13T02:00:15.765Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0qAWpEWpCdyjqa1m-v3mfw.png" /></figure><p>As LLMs continue to grow in size and complexity, there’s a pressing need for more efficient, modular architectures. That’s where MoE models come in — they introduce sparsity at the architectural level, enabling significant performance improvements with a reduced computational footprint.</p><h3><strong>Mixture of Experts</strong></h3><p>Traditional dense networks process every input through all layers, even when it’s not always necessary, resulting in high computational costs. MoE models, on the other hand, use multiple specialized subnetworks (or experts) that are selectively activated based on the input data. This modular design allows the model to allocate computational resources more efficiently, achieving better performance without a proportional increase in computation.</p><h4>Core Components of MoE Architectures</h4><p>· <strong>Experts:</strong> These are smaller neural networks, each trained to specialize in a specific type of input or data pattern.</p><p>· <strong>Gating Mechanism:</strong> A separate, trainable component that selects which experts to use for each input, helping the model stay efficient.</p><p>· <strong>Load Balancing:</strong> Ensures no single expert gets overwhelmed by evenly distributing workload — usually with techniques like Top-k routing.</p><h4>Why MoE is Important for Building Big AI Models</h4><ol><li><strong>More Power, Less Effort</strong>: These models can be huge, but only use a small part of themselves for each task — so they’re fast and efficient.</li><li><strong>Smarter Learning</strong>: Expert layers learn data-specific features, improving performance in multilingual, multi-domain, or multimodal contexts.</li><li><strong>Works Across Machines</strong>: You can run on different GPUs or machines, making it easy to parallelize.</li><li><strong>Easy to Customize</strong>: Fine-tune specific experts, control routing paths, and experiment with modular components to shape model behavior precisely.</li></ol><h4>How to Implement MoE: Step-by-Step</h4><p><strong>Step 1: Select an Appropriate Framework</strong><br>Choose from deep learning platforms that support MoE architectures, such as TensorFlow, PyTorch, or JAX. Pick one that best fits your project requirements and your familiarity.</p><p><strong>Step 2: Set Up your Experts</strong><br>Figure out how many experts you need and what each should specialize in — like different languages or tasks. This setup will shape your model’s strength.</p><p><strong>Step 3: Design the Routing Mechanism</strong> <br>The routing mechanism decides how inputs are allocated to the experts. Common strategies include: <br> 1. Gating Networks: A neural network that learns to route inputs based on their features. <br> 2. Random Routing: A simpler method where inputs are assigned to experts randomly.</p><p><strong>Step 4: Train your MoE Model</strong><br>Use your dataset to train the MoE and pay attention to the balance between the experts to avoid overfitting on a single expert. Regularization techniques can be helpful here.</p><p><strong>Step 5: Evaluate and Fine-Tune<br></strong>Validate the model’s performance, then fine-tune parameters and routing strategies to enhance accuracy and efficiency.</p><h4>Challenges and Considerations</h4><p>While MoE offers significant advantages, there are challenges to consider:</p><ul><li><strong>Increased Complexity</strong>: More components can complicate model training and maintenance.</li><li><strong>Computational Overhead</strong>: Managing and optimizing the routing mechanism can add extra processing costs.</li><li><strong>Data Imbalance</strong>: If not managed properly, some experts may become more heavily utilized than others, leading to inefficiencies.</li></ul><h4>Summary</h4><p>In conclusion, Modular Language Models mark a significant breakthrough in AI technology. By efficiently managing resources without sacrificing performance, they unlock new possibilities for both research and practical applications. As AI continues to advance, MoE architectures are poised to become foundational in the evolution of natural language processing, offering promising opportunities for developers and researchers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7fc2b0d331c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>