Hypothetical scenario. Northwind’s triage exercise worked with supplied passages. Maya now asks about a policy that was not in the request. Dev finds a convincing answer in an older handbook, while Priya asks which revision the employee is allowed to use.
Maya: “The answer sounds familiar, but is that still our rule?”
Dev: “We need a path from the current source to the answer, not just a longer prompt.”
Priya: “Trace the permitted revision through selection and generation before we optimize search.”
You will follow retrieval-augmented generation from source ingestion to checked answer, using the representation and acceptance boundaries from the previous exercise. Locate where evidence is lost or distorted before choosing a more elaborate retrieval component.
How will an answer stay connected to its evidence?
Hypothetical scenario. An equipment library wants an assistant to answer borrowing questions. The collection contains a current public handbook, an older handbook, staff-only purchase notes, and maintenance records. A reader asks whether a particular camera can be borrowed for a weekend. An answer that sounds reasonable is insufficient: the assistant needs the applicable rule, the right document version, and permission to disclose the evidence.
Retrieval-augmented generation connects a request to selected external material before producing an answer. It can make changing information available without requiring that information to be stored in model parameters. It also creates additional ways to fail: the source may be absent, search may miss it, an outdated passage may rank highly, or the answer may distort a passage that was correctly retrieved.
The outcome for this chapter is practical: trace those boundaries, calculate a small retrieval evaluation, and choose the next investigation from an observed failure. Understanding token budgets and prompt contracts helps; knowing a particular vector database is unnecessary.
Why the nearest passage can be the wrong evidence
A similarity score measures the relationship defined by a retrieval method. It does not independently establish that a statement is current, complete, authoritative, or visible to the requester. The old handbook may repeat the question's exact wording more closely than its replacement. A staff note may discuss the camera in detail without being a borrowing policy.
Keyword retrieval and learned representations provide different matching signals. Exact identifiers can matter, while differently worded descriptions can refer to the same concept. Neither signal removes the need to judge relevance for the actual task. Introduction to Information Retrieval, chapter 1 provides the underlying distinction between an information need and the machinery used to find documents.
Giving the generator every document is also a choice with limits. The request has a context allowance, processing work grows with the material supplied, and extra passages can include contradictions or irrelevant instructions. Retrieval is a selection problem; generation does not erase poor selection.
Make RAG a pair of versioned publication and serving paths
Hypothetical scenario. An ingestion path publishes searchable children of a specific source revision. A serving path retrieves candidates, checks eligibility, ranks them, constructs context and validates the answer. A vector-store write is one step inside the publication path, not proof that the whole system is current.
| Artifact | Concrete evidence | Decision boundary |
|---|---|---|
| Source revision | document, authority, applicability | Truth boundary |
| Index generation | compatible chunks and watermark | Candidate coverage |
| Answer evidence | selected source spans and versions | Support / reuse review |
Record document, chunk, index and permission versions in the answer evidence. Naive and advanced retrieval choices change candidate or context quality; the application still owns disclosure and supported-answer behavior. An answer failure should be localized to missing source, omitted candidate, poor ranking, lost context or unsupported generation before selecting an intervention. This makes the next architecture change address an observed mechanism rather than adding components speculatively.
Follow the evidence through each boundary
Ingestion prepares searchable records from source documents. Preserve document identity, revision, location within the source, and access metadata alongside the text. A chunk is a chosen retrieval unit, such as a section or passage. An index helps find candidate units; it is a derived representation whose update process must follow source changes.
At request time, resolve the caller's allowed scope before exposing content. Search and ranking can be separate stages: a first stage finds candidates; a later stage compares a smaller set more carefully. The design must enforce access rules wherever content could cross a boundary, including reranking services, logs, caches, and source expansion. A label attached to a passage is useful metadata, not enforcement by itself.
The context builder selects evidence that fits the request and retains source references. The generator then attempts the task under the answer contract. Check whether each substantive answer claim is supported by the cited passage; a citation's existence alone does not show that relationship. If evidence is missing or inconsistent, the contract needs an abstention or conflict response.
Lewis and colleagues' RAG paper describes a particular learned retriever-and-generator formulation using an external document index. The broader application flow here is an engineering decomposition; it does not imply that every system called RAG implements that paper's training objective.
Count retrieved evidence before scoring answers
Hypothetical scenario. A labeled test collection has four questions. Each question has a set of relevant, current, permitted evidence units. For this simplified exercise, any one relevant unit fully supports its question. The retriever returns three distinct units per question. Relevance judgments are fixed before comparing systems.
| Question | Relevant set | Retrieved three | Relevant retrieved |
|---|---|---|---|
| Q1 | A, B | A, X, Y | 1 |
| Q2 | C | X, Y, Z | 0 |
| Q3 | D, E | D, E, X | 2 |
| Q4 | F | F, X, Z | 1 |
There are 4 × 3 = 12 retrieved question-unit pairs. Four are relevant, so pooled precision at this depth is 4/12 = 1/3, approximately 33.3%. The relevance sets contain 2 + 1 + 2 + 1 = 6 pairs; pooled recall is 4/6 = 2/3, approximately 66.7%. Averaging per-question recall instead gives (1/2 + 0/1 + 2/2 + 1/1)/4 = 2.5/4 = 62.5%. Those are different aggregations, not contradictory results.
Three questions have at least one supporting unit: coverage is 3/4 = 75%. Under the exercise's explicit assumption that one such unit is sufficient, Q2 lacks the selected evidence required for a grounded answer. This does not predict the generator's accuracy. It may still mishandle Q1, Q3, or Q4, and it may guess Q2 from elsewhere.
Suppose final review finds two supported answers, one unsupported answer, and one abstention. These categories total four. The supported-answer fraction is 2/4 = 50%; among the three answered questions, support is 2/3, approximately 66.7%. Report abstentions separately and inspect whether they were appropriate. Four cases illustrate denominators; they do not establish a production success rate. The retrieval evaluation chapter supplies the broader evaluation framework.
In the wild: Retrieval-Augmented Generation: Getting the Right Paragraph to the Model
Lewis and colleagues' RAG paper: The original RAG paper combines a learned retriever/index with a generator in specific model formulations.
The useful trade-offs depend on the collection
Increasing retrieval depth may recover missing evidence, but can also supply more irrelevant passages and consume the context allowance. Reranking may improve selection while adding processing work. Combining lexical and dense candidates can help expose complementary matches, but requires a defined merge policy and evaluation. There is no collection-independent winning setting.
Freshness has several meanings: the source revision, when the index incorporated it, and when a cached result was created. A fast search over stale records remains stale. Keep enough provenance to ask which revision supported a particular answer. Where permissions or policies change during a request, decide what consistency the application requires and recheck before disclosure or action.
Relevant evidence can also contain hostile instructions. Treat retrieved text as source material, not as authority to change tool permissions or reveal other records. The OWASP prompt-injection guidance explains this risk; retrieval is not a security boundary that makes arbitrary text safe.
A changed document can leave an unchanged answer
Hypothetical scenario. The library replaces a handbook but its ingestion job appends the new revision without retiring the old one. Both versions remain searchable. For a weekend question, the old wording ranks first; the answer cites it accurately and still gives an obsolete rule.
This is not necessarily a generation failure. Inspect source revision handling, index deletion or replacement, and cached evidence before rewriting the prompt. Define how superseded records remain available for historical questions without competing as current policy. Historical retrieval and current-policy retrieval can use different explicit scopes.
After a repair, repeat both a current-policy question and a historical question. Also test a removed document and changed permissions. A successful fresh answer alone does not show that the earlier revision stopped leaking through another access path.
Claims that hide the failure boundary
“The model has learned the uploaded files.” Supplying retrieved text to a request is different from changing model parameters. Describe which information is available for this request.
“A citation makes the answer grounded.” Check whether the cited source actually supports the claim, applies to the requested situation, and is current within the task's scope.
“Recall improved, so the answer must improve.” The generator still has to use the evidence correctly. Diagnose retrieval and answer behavior separately.
“The vector store handles permissions automatically.” A storage feature helps only when the application uses it correctly across search, expansion, caching, and disclosure. Inspect the complete path.
Choose the simplest adequate information path
Retrieval is useful when answers depend on a changing or substantial collection and the application can maintain source identity, permissions, and evaluation cases. It is particularly valuable when readers need inspectable evidence rather than an answer without provenance.
A single small, stable document may fit directly in a request. An exact balance or equipment availability question may be better answered by an authorized structured query. A high-consequence decision may require a person to inspect the source. Generation is optional: returning well-ranked excerpts can already satisfy some information needs.
Start with a measurable baseline. Record missing evidence, irrelevant selection, stale versions, unsupported claims, and unsafe disclosures as distinct failure categories. Each points to a different intervention.
Limits of Retrieval-Augmented Generation: Getting the Right Paragraph to the Model
The worked denominators describe small hypothetical examples. Retrieval and supported synthesis need separate evidence, while permission and source freshness govern every artifact shown to a reader. The original RAG architecture does not by itself establish those application guarantees.
Test the source revision boundary
The correct source exists but never reaches the candidate set. Should the team fine-tune answer style?
Reveal the design reasoning
No. Inspect ingestion, query interpretation and retrieval coverage first. Style training cannot recover evidence absent from the model input.
Decision: Observe each RAG handoff and intervene at the failing boundary.
Check yourself: locate the next investigation
The right passage appears in the supplied context, but the answer reverses its exception. Should retrieval depth be the first change?
No. The evidence reached the generator. Inspect the answer contract, how the exception is represented, conflicting context, and answer support. Increasing depth does not directly repair a misinterpretation and may add distractions. Retain the case as an answer-level regression.
Two questions each return two units. Q1 has one relevant unit in its relevance set and retrieves it; Q2 has three relevant units and retrieves one. What are pooled precision and pooled recall?
Two relevant retrieved pairs out of four retrieved pairs gives precision 2/4 = 50%. Two out of four relevant pairs gives pooled recall 2/4 = 50%. Mean per-question recall is (1 + 1/3)/2 = 2/3, approximately 66.7%. State which aggregation you use.
A requester loses permission after a search result was cached. Is removing the passage from the next search enough?
No. The cached text is another disclosure path. Revalidate current access when serving it, or use an invalidation design that meets the application's consistency requirements. Also inspect source expansion and logs. A search filter alone does not establish the complete permission boundary.
Northwind decision log
Retrieve the current authorized document revision.
Keep chunk identity with the answer.
Inspect retrieval before changing the generator.
Go deeper into search and evidence
- Book chapter: Introduction to Information Retrieval, chapter 1: Boolean retrieval — Christopher Manning, Prabhakar Raghavan, and Hinrich Schütze. Establishes documents, information needs, and an index before adding generation.
- Book chapter: Introduction to Information Retrieval, chapter 8: Evaluation in information retrieval — Manning, Raghavan, and Schütze. Explains relevance judgments and why measures need declared denominators.
- Video lecture: Homework: Few-shot OpenQA with ColBERT retrieval | Stanford CS224U Natural Language Understanding — Chris Potts. Follow the OpenQA retrieval exercise to connect candidate selection to the answer task.
- Primary paper: Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks — Patrick Lewis and colleagues. Read its actual model formulation and distinguish it from the general application pattern described here.
Carry the decision forward
Northwind now has an evidence path to inspect. Page 12 asks what its retrievable units should contain when a policy rule and its exception lie on opposite sides of a document split.