Retrieval-Augmented Generation: Designing for Evidence, Not Just Context
A retrieval system is a context-selection system. The model has a limited desk, and every irrelevant chunk takes space away from the evidence it actually…

Research updated Sep 10, 2026
Key topics
A retrieval system is a context-selection system. The model has a limited desk, and every irrelevant chunk takes space away from the evidence it actually needs.
The demo works. You load a handful of documents, ask a question that echoes their wording, and the model answers cleanly with a citation. Then a real user asks the same thing in different words, or asks something that requires two documents, or asks about a policy that changed last week. The system answers anyway — confidently, fluently, and wrong.
The usual diagnosis is "the model hallucinated." That diagnosis is lazy, and it sends you to the wrong layer of the stack. Many production failures are introduced before generation ever runs: the right evidence never reached the model, or it reached the model buried under near-duplicates. A smaller but real second class of failures happens after retrieval succeeds — the model misreads adequate evidence, ignores it, or over-trusts one passage over another. Retrieval-augmented generation is not a trick for adding documents to a prompt. It is a system for choosing which evidence deserves the model's attention, and most production failures live in the choosing.
The Desk, Not the Library

Retrieval-augmented generation couples a pretrained language model with a non-parametric retrieval module that fetches external evidence at inference time. The weights hold general patterns — how language, code, and arguments tend to be structured. Retrieval supplies the specific: the current price, the private policy, the internal runbook, the fact that changed after training. The model conditions its output on what retrieval hands it.
That framing is standard, and it is also where the mental model usually goes wrong. Teams treat the corpus as the problem and the context window as the solution. Build a bigger index. Embed everything. Stuff more chunks into the prompt. But the context window is a finite desk, not a warehouse. The warehouse can be arbitrarily large; the desk cannot. Retrieval quality is therefore a ranking-and-filtering problem, not a storage problem. You are not asking "do we have the document?" You are asking "did the right passage land on the desk, near the top, before the model started writing?"
Grant the narrow case where the naive approach works. If your corpus is small, stable, and homogeneous — a few dozen pages of documentation that never change, questions that share vocabulary with the source — then keyword search plus a decent prompt will carry you a long way. The failure modes stay hidden because the desk is never crowded and the right answer is never far from the query's wording.
The naive model breaks the moment any of those conditions shift. Ambiguous queries retrieve plausible-but-wrong neighbors. Multi-hop questions need evidence from two documents that no single query surfaces. Near-duplicate documents crowd the desk with variations of the same passage while the decisive clause sits at rank eleven. A corpus that changes weekly invalidates whatever the index learned last month. These are selection failures, and they arrive on a schedule.
The three-stage flow — retrieve, augment, generate — is the skeleton worth keeping in view. Retrieve candidates from an index. Augment the prompt with the selected evidence. Generate a grounded response. The value of the skeleton is diagnostic: when an answer is wrong, the first question is not "what's wrong with the model?" It is "which stage produced this?" Most teams blame generation for problems that retrieval created.
Where the Pipeline Actually Breaks
Each stage introduces its own failure mode. Naming them separately is what turns debugging from archaeology into engineering.
Ingestion and chunking. Before anything can be retrieved, documents must be split into retrievable units. Fixed-size splits are the default and the most common source of quiet damage. A chunk boundary that lands mid-table severs a row from its header. A split inside a code block produces a fragment that compiles in no language. A clause cut in half changes its meaning. Chunk size and overlap are design decisions with consequences on both sides: chunks too small lose the context that makes a passage interpretable, chunks too large dilute the embedding and waste desk space. There is no universal correct size. There is only the size that keeps your document's real units — sections, procedures, records — intact.
Indexing and representation. The index determines what kinds of queries can find what kinds of content. Lexical search matches tokens; it finds exact identifiers, part numbers, error codes, and rare strings, but it misses paraphrase entirely. Dense retrieval, which compares vector representations of meaning, handles paraphrase well and fails on the same rare strings — a part number embedded in a sentence becomes a blur of general meaning, not a precise token. Hybrid search runs both and merges the results, which is why it has become a common default for corpora that mix natural language with codes and exact terms. The point is not that one method wins. The point is that each fails differently, and the failure you get depends on the representation you chose.
The query side. User questions are not retrieval queries. A question phrased conversationally, with pronouns pointing at earlier turns, retrieves poorly against a corpus written in declarative prose. Query rewriting — restating the question as a search-shaped query — and decomposition — splitting a multi-hop question into subqueries — often move recall more than swapping embedding models does. In multi-turn conversations, context-aware query planning uses the conversation history to resolve what "it" refers to before retrieval runs. This is unglamorous work, and it is frequently the highest-leverage change available.
Ranking. Similarity search returns the top-k candidates by vector distance or keyword score. That ordering is a lottery ticket, not a judgment. A reranker — a model that scores each candidate against the actual question — reorders the list so the most relevant evidence reaches the top. Without reranking, the passage the model needs may be present in the candidate set and still lose to a superficially similar neighbor. Retrieval success and retrieval usefulness are different things, and the gap between them is where rerankers earn their cost.
Generation. Even with perfect evidence on the desk, the model can ignore it, misread it, or over-trust a passage that contradicts another. Retrieval success does not guarantee grounding success. This is the stage where teams most often look for the bug and least often find it, because by the time generation runs, the damage is usually already in the context.
Retrieval Quality Is Not Answer Quality
Two metrics get conflated constantly, and the conflation makes debugging impossible. Retrieval metrics ask whether the right evidence appeared in the candidate set and at what rank. Grounding metrics ask whether the answer followed from the retrieved evidence, with citations that point where they claim to point.
The diagnostic fork is simple and worth internalizing. If the correct passage never made it into the retrieved set, no prompt engineering will save the answer — the model cannot ground itself in evidence it never received. If the correct passage is present and the answer is still wrong, the problem is generation, instruction-following, or context ordering. These two failures look identical from the outside and require opposite fixes. Teams that skip the fork spend weeks tuning prompts to fix a retrieval bug.
The evaluation vocabulary that matters here has three working parts. Context relevance asks whether the retrieved passages actually address the question. Groundedness, sometimes called faithfulness, asks whether the answer's claims are supported by the retrieved context. Answer relevance asks whether the response addresses what was asked. Vendor platforms expose overlapping but not identical versions of these metrics, so the names travel less reliably than the concepts. Pick a definition, write it down, and measure against it consistently.
One trap deserves explicit warning. Standard accuracy scores tell you whether a model produced the right answer under one phrasing. They do not tell you whether the model knows a fact or merely happened to surface it that time. A model can hold a fact parametrically and fail to recall it under a different phrasing, a different context, or a reversed question. Evaluation sets should probe the same underlying fact across phrasings, contexts, and directions. Otherwise you are measuring luck.
And the honest limit: public encyclopedic benchmarks do not automatically generalize to proprietary or highly specialized corpora. A model's handling of a niche internal metric may behave nothing like its handling of public facts. Your evaluation set has to come from your users' actual questions, with known correct evidence attached.
Grounding, Citations, and the Right to Say I Don't Know
Grounding is not a hope. It is a contract you enforce in the system message and the prompt: answer only from the supplied context, and refuse when the context is insufficient. The refusal path is a feature. A system that says "I don't know" when the evidence is absent is more trustworthy than one that always produces an answer, because the second system has no way to signal uncertainty — every response looks equally confident, including the wrong ones.
Citations make the contract checkable. They must trace to specific chunks, not to a document title or a vague source. Structured outputs that return grounding data, citations, and execution metadata alongside the answer turn citation accuracy from a decorative claim into something you can verify programmatically. If the model cites chunk four, you can check whether chunk four supports the sentence. If it cites "the documentation," you cannot check anything.
Context ordering and truncation matter more than most teams expect. Evidence placed late in a long prompt, buried among near-duplicates, or truncated mid-passage degrades grounding even when retrieval succeeded. The model's attention is not uniform across the context, and a decisive clause cut in half is worse than a shorter, cleaner passage. Selection includes arrangement.
There is one more distinction worth holding. Some factual misses are access problems, not knowledge problems. A 2025 study from Google Research and Technion, reported in secondary coverage, found that models can recover a substantial share of facts they fail to recall directly when given more inference-time effort — reasoning through the question rather than answering immediately. That finding reframes the default response to hallucination. The reflex is to add retrieval, scale the vector database, ingest more documents. Sometimes the model already holds the fact and simply failed to surface it under that phrasing. Changing how you ask can be cheaper than building a retrieval pipeline. The boundary: that research used public encyclopedic facts, and it should not be assumed to hold for niche internal metrics or specialized domains. Test it on your own corpus before you redesign around it.
Cost, Latency, and the Data-Movement Tax
Every stage of the pipeline costs money and time. Embedding the query, looking up the index, reranking candidates, and feeding a longer prompt all add latency and spend. The longest prompt is rarely the best one. More context raises per-call cost and can dilute attention across irrelevant material, which means the expensive version of the system is sometimes the less accurate one.
In some workloads, data movement becomes the quiet bottleneck. When retrieval has to scan large, frequently changing corpora, or when storage proximity and cache behavior dominate, the constraint stops being compute in the abstract and becomes how fast relevant data can be found, moved, and delivered. That is a workload-dependent infrastructure problem, not a universal law of RAG. The way to know whether it applies to you is to measure it: retrieval latency, bytes moved per query, cache hit rate, reranker time, and prompt-token cost. If those numbers are flat while answer quality is bad, your bottleneck is selection, not infrastructure.
Longer context windows do not repeal this. A bigger desk holds more paper, but it does not tell you which paper matters. Long-context models shift the constraint from "can we fit the evidence" toward "can we prove we chose the right evidence" — a selection and accountability problem, not a capacity problem.
The practical pattern is routing. Run a fast, cheap first pass. When confidence is low — ambiguous query, rare entity, no strong candidate — retry with higher-effort retrieval or reasoning rather than paying maximum cost on every query. The decision rule that keeps this honest: measure cost per correct answer, not cost per call. A cheap call that produces a wrong answer is the most expensive thing in the system.
Choosing Your Architecture Without Overbuilding
Start from the workload, not the technology. What changes, and how often? How ambiguous are the queries? How costly is a wrong answer? A stable internal wiki and a live pricing feed demand different architectures, and the difference is not which vector database you pick.
Match the retriever to the corpus. When the corpus mixes natural language with identifiers, codes, and exact strings, hybrid search is a sane default because it covers both failure modes. When the corpus is pure prose and queries are paraphrases, dense retrieval may be enough. When queries are exact lookups, lexical search may beat both.
Fine-tuning and retrieval-augmented fine-tuning have real places, but they are usually premature. Measure retrieval first. If the right evidence is not reaching the desk, fine-tuning the generator will not fix it. Retrieval-augmented fine-tuning — training the model to use retrieved context well — addresses a different problem: generation quality given good evidence. Diagnose which problem you have before spending on either.
Agentic and multi-step retrieval patterns — query planning, parallel subqueries, structured responses — solve real coverage problems. They also add moving parts, latency, and failure surface. Adopt them when single-shot retrieval demonstrably fails, not because they sound more capable. The overkill boundary is real: for a small, stable, well-structured corpus, a keyword index plus a good prompt may outperform a full vector stack, and it will be easier to debug.
What to Build and Measure Next
The first build is smaller than most teams expect, and the order matters more than the components. Run the loop in this sequence:
- Write the evaluation set. Take real user questions and attach the known correct evidence to each one. Without this, every later measurement is a guess.
- Inspect candidate recall. For each question, check whether the correct passage appears anywhere in the retrieved candidate set. If it does not, the problem is ingestion, representation, or the query — not the model.
- Inspect rank and selected context. If the passage is present but ranked low or dropped before the prompt, the problem is ranking or truncation. Add or tune a reranker, adjust top-k, and check context ordering.
- Test grounding and refusal. If the passage is present, ranked well, and the answer is still wrong, the problem is generation. Tighten the grounding instruction, enforce the refusal path, and verify citations trace to specific chunks.
- Measure latency and cost. Only after the quality loop is stable, look at retrieval latency, reranker time, prompt-token cost, and cost per correct answer. Route expensive paths only where the quality data justifies them.
That is enough to expose which stage fails. Instrument the stages separately. Log the retrieval trace: the original query, the rewritten query, the candidate chunks with their ranks, and the final cited chunks. This trace is the artifact that makes debugging cheap. When an answer is wrong, you read the trace and see whether the evidence was missing, present but buried, or present and ignored. Without the trace, every failure looks like "the AI messed up," and every fix is a guess.
The skills worth building next are unglamorous and compounding: constructing evaluation sets from real questions, parsing and chunking messy documents without severing their meaning, tuning hybrid retrieval, and routing queries by cost and confidence. None of these are model upgrades. All of them change outcomes.
The watchpoint is this. If long-context inference keeps getting cheaper, the selection problem does not disappear — it moves. The question stops being "can we fit the evidence" and becomes "can we prove we chose the right evidence." That is an accountability problem, and it is not solved by a larger window. It is solved by a visible retrieval trace and a small evaluation set that tells you which stage failed. Build those first. The index can wait.
References
- Retrieval augmented generation (RAG) and indexes - Microsoft Learn
- Retrieval-Augmented Generation: A Comprehensive Survey of Architectures, Enhancements, and Robustness Frontiers
- What is Retrieval-Augmented Generation (RAG)? - Google Cloud
- Architecting memory and storage in the AI era
- Frontier models can recover up to 65% of facts they can't directly recall


