RAG Pipeline Architecture for Production AI Applications
Separating batch indexing from live queries prevents the resource conflicts that kill RAG systems.

By 2026, retrieval-augmented generation has become the default way enterprises build AI products: chatbots, internal knowledge bases, assistants, search tools, most of them sit on some version of this architecture. The concept behind RAG is easy to explain in one sentence: pull relevant documents, hand them to a language model, get an answer grounded in real text instead of the model's memory. The gap between that one sentence and a system that survives contact with real users is where most projects die, and closing that gap is what this piece is actually about.
The numbers back this up. Fewer than half of AI projects, 48%, ever make it to production, and the ones that do take roughly eight months to get there. Eight months is a long time for something that looks, in a demo, like it should take a weekend.
That's because a demo and a production system aren't the same animal wearing different clothes. A demo runs on maybe 50 clean PDF chunks, gets tested by a handful of forgiving users, and has no real latency budget to worry about. Nobody's data is 50 clean PDFs.
So the failure isn't conceptual. Teams understand what RAG is supposed to do. What breaks is architecture, and specifically the assumption that whatever worked at demo scale will just keep working once real load, real mess, and real users show up.
The two-pipeline architecture that production systems require
It seems efficient at first.
Because they compete for the same resources at the worst possible moment. When new documents get ingested and re-embedded while live queries are hitting the same infrastructure, autoscaling doesn't react fast enough, and response times spike right when someone's watching. A system that felt fast in testing suddenly stalls out under a batch reindex job nobody thought to isolate.
The fix is to treat these as genuinely separate pipelines with separate resourcing.
The offline indexing pipeline runs as a batch process, kicked off whenever documents change rather than on every query. It starts by ingesting and parsing raw files, PDFs, HTML, DOCX, whatever APIs return, using parsing tools built for exactly this job, like Apache Tika or Unstructured.io. From there the text gets cleaned and normalized: formatting stripped out, structure standardized, metadata pulled out and kept alongside the content. Then comes chunking (covered in the next section, because it deserves its own treatment), followed by embedding and storage, with vectors written into an index that combines HNSW for approximate nearest-neighbor search with BM25 for keyword lookup.
A query comes in and first gets rewritten or expanded, sometimes through HyDE (generating a hypothetical answer to search against), sometimes through decomposition into sub-questions. Then retrieval runs across both vector and keyword indexes at once. Results get reranked with a cross-encoder model that reads query and document together rather than comparing pre-computed vectors. Only then does generation happen, with the LLM producing an answer grounded in the retrieved context and, ideally, citations pointing back to source documents. A validation step follows, checking that the answer is actually faithful to what was retrieved, that citations point where they claim to, and that the response covers what was asked.
Conflating them is the architectural sin that repeatedly appears once systems move past the prototype stage.
Chunking: the decision that sets the ceiling for everything downstream
If there's one decision in RAG design that gets less attention than it deserves, it's chunking. Everyone obsesses over which embedding model to use or which LLM to call. Whether retrieval can find the right information in the first place depends on chunking, yet it gets treated as an afterthought, a default setting left untouched.
The goal of chunking sounds obvious once stated: each chunk needs to stand on its own, answering a question without requiring the surrounding paragraphs for context. A chunk that starts mid-sentence, or ends right before the clause that would have made it useful, is worse than useless. It's a piece of near-miss information that ranks high in retrieval and then gives the LLM nothing solid to work with.
Fixed-size chunking doesn't know where a paragraph ends or a table begins. It slices straight through ideas because it's counting tokens, not meaning.
The retrieval accuracy numbers make the cost of that indifference concrete. Fixed-size chunking is 52% accuracy. Recursive chunking, which at least tries to split along natural document boundaries like paragraphs and sections before falling back to fixed sizes, gets to 61%. Semantic chunking, which groups text by actual topical coherence rather than length, delivers something like a 70% relative lift over the fixed-size baseline. And a hybrid approach that combines chunking strategy with overlap between chunks (so context doesn't fall into the cracks between them) reaches 93%.
That's not a marginal difference. A system that can find the right paragraph and one that mostly can't are separated by that gap. And no amount of clever prompting or a better LLM downstream fixes a chunk that was cut in the wrong place to begin with. Chunking sets the ceiling; everything after it just decides how close the system gets to that ceiling.
Why pure vector search fails in production and how hybrid retrieval fixes it
Start with the failure, because the failure is what explains why the fix looks the way it does. Pure vector search, embedding a query and comparing it against embedded chunks by cosine similarity, has a mathematical ceiling once a knowledge base gets large and its content gets varied. A single vector is a compressed, lossy summary of everything a chunk means, and it can't hold every overlapping relationship a large corpus contains.
The practical symptom is specific and a little embarrassing. Someone searches "ISO 27001 compliance requirements," expecting the document that names that exact standard. The system understood the topic and missed the term.
Keyword search has the mirror-image weakness: it fails at matching meaning. BM25 is excellent at matching exact terms and hopeless at matching meaning. A query like "how do I handle employee burnout" won't retrieve a document titled "work-life balance strategies," because the words don't overlap even though the concepts are the same thing.
Neither method alone is wrong, exactly. Each is solving one part of the problem correctly and getting the rest wrong.
Hybrid retrieval, running dense vector search and sparse BM25 together, has become the standard approach as of 2026. The mechanics are fairly simple once you see them laid out. Both searches run in parallel against the same corpus. Their results, which come back with incompatible scoring scales (cosine similarity versus BM25's term-frequency scoring), get merged using Reciprocal Rank Fusion. RRF sidesteps the scale mismatch entirely by working off rank position instead of raw scores, so a document that lands near the top of both lists gets pushed up in the combined ranking.
Does the combination actually outperform either method alone, or is this just architectural tidiness for its own sake? The numbers say it's real. Hybrid search achieves 66.4% mean reciprocal rank against 56.7% for semantic-only retrieval, a nine-point improvement that directly translates to better answers. Depending on implementation, hybrid approaches improve recall accuracy somewhere between 1% and 9% over vector search alone, a gap that can separate a system that occasionally misses the obvious document from one that reliably finds it. That's not a rounding error. A system that occasionally misses the obvious document and one that reliably finds it are separated by that gap.
Evaluation infrastructure: why you cannot monitor a RAG system by feel
That's a fast climb, and it raises an uncomfortable question: at that scale, how many of those systems actually know when they're wrong? Eyeballing a handful of outputs and deciding they look fine is a habit rather than evaluation. It's a habit that works at demo scale and quietly stops working the moment query volume and document count both grow past what one person can sanity-check by reading transcripts.
The RAGAS framework offers four metrics spanning the full pipeline, and two of them are the most actionable.
Faithfulness measures whether a generated answer is actually grounded in the context it was given, rather than drifting off into something the model half-remembers from training. Customer-facing deployments generally aim to keep this high, with strong scores considered a reliable signal of grounded output. Context Precision measures something further upstream: what proportion of the retrieved chunks were actually relevant to the query, with production systems expected to maintain a high threshold here.
The diagnostic value gets practical here, and it saves teams from a genuinely common mistake. When Faithfulness drops below 0.9, the instinct is to blame the LLM, assume it's hallucinating, and go tweak the prompt or swap models, but in nearly every production failure, hallucination is caused by retrieving the wrong context, not by the LLM making things up. That's usually the wrong fix. In nearly every production failure, the LLM isn't inventing anything; it's being handed the wrong context and doing a faithful job of describing it. Fix retrieval first. Only look at generation once retrieval is confirmed clean.
None of this works without a baseline to measure against. Skipping that discipline turns every fix into a guess, applied on faith and checked only by whether users complain less.
Agentic and adaptive RAG: when a single retrieval pass is no longer enough
Static, one-shot retrieval, embed the query, fetch the top chunks, generate, is starting to look like the fixed-size chunking of its era: fine as a default, wrong as a ceiling. That's a fast enough shift that it raises the question of why.
Agentic RAG, in practice, means an agent decides how to retrieve based on what the query actually needs, instead of running the identical pipeline for a simple factual lookup and a multi-part comparative question. Microsoft's Azure AI Search team calls this pattern agentic retrieval, and frameworks like LangGraph and CrewAI have become common ways to build it.
Adaptive RAG sits one layer below that: a decision step that routes each query based on its actual complexity rather than forcing everything through the same fixed pipeline. A simple factual question might skip retrieval entirely, since the model already knows the answer and a retrieval pass just adds latency for no benefit. A question that needs current information might trigger a live lookup instead of relying on a static index that's already stale by the time anyone queries it.
Agentic and adaptive approaches connect back to that assumption once it stops holding, once the query traffic is varied enough that no single fixed pass serves all of it well. Agentic and adaptive approaches are what happens once that assumption stops holding, once the query traffic is varied enough that no single fixed pass serves all of it well. It's less a replacement for the architecture described above and more its natural extension: the same discipline, applied one layer up, at the level of deciding how to retrieve rather than just how to search.