Level 300: Building with gen AI · Module 300.1

A coworker pulls a folder from a wooden card-catalogue drawer while a colleague holding a coffee cup watches.
Find it, then answer

How retrieval works · Standard gear

Reviewed and published, version 1.0.0. As of 19 Nov 2026. It is not a credential. This module teaches research findings, not product facts; findings are dated by their papers.

You will be able to:

Big idea: retrieval does not teach a model your documents. The assistant looks some up, adds them to the question, and writes. Each of those steps can fail on its own, and with the trace you can usually tell which one did.

In Level 100 (module 100.6) you met the open-book tool: it finds company documents first, then answers. This module opens the box. In 300.2 you build one.

1. Two steps: find, then write

Step 1, FIND [s1]: Search the chosen collection. The retriever returns passages relevant to this question. Step 2, WRITE [s1]: Write from the input. The model receives the question and retrieved passages, then writes an answer.
The retriever and generator are distinct parts (s1). Retrieval supplies passages for this question; it does not train the model on the collection.
Figure data as text

Find, then write

  1. FIND [s1] · Search the chosen collection — the retriever returns passages relevant to this question.
  2. WRITE [s1] · Write from the input — the model receives the question and retrieved passages, then writes an answer.

Objective: 300.1-a. Text equivalent of figures/find-then-write.svg.

Retrieval-augmented generation (RAG) joins two parts. The 2020 paper that named it describes a retriever, which looks up passages in a document index, and a generator, a language model that writes its output from the input together with the passages the retriever returned.1 In that paper the index was Wikipedia, held outside the model as what the authors call a "non-parametric" memory, next to the "parametric" memory stored in the model's weights.1

So a RAG system answers in two steps:

  1. Find. The retriever searches a chosen collection (the documents someone decided to put in the index) and returns the few passages that score as most relevant to the question.
  2. Write. The model receives the question and those passages, and writes an answer.

The misconception this corrects: "The model has read our documents and remembers them." Retrieval does not work that way. The collection sits in the index, outside the model's weights, and retrieving a passage does not train the model on it. When it writes, the model draws on three things: your input (the question and any instructions or text you supplied), what it learned in training, and the passages retrieved for this question. A document the model did not learn in training, and that you did not supply, reaches it only if the find step returns it.

The RAG authors showed how much the index matters. When they swapped the Wikipedia index for one from a different year, the system's answers about world leaders changed to match the index, with no retraining of the model.1 That shows answers can be updated by changing the collection. It does not show that every answer always follows the index, or that the model knows nothing else.

Each step can be measured on its own. The RAG paper's retriever is based on Dense Passage Retrieval,1 and the Dense Passage Retrieval paper studies the find step by itself. It scores a retriever by whether a passage holding the answer is among the top passages it returns, before any model writes anything.2 That separation is the basis of section 3.

At Big Widget Company: the missing policy page. Big Widget is a made-up company. Its service assistant answers dealer questions from a collection of service policies. The service team replaces the warranty-labour policy. The new policy was written after the model was trained, and nobody pastes it into a question. Nobody adds it to the collection either.

In our scenario, this is what the trace and the screen show:

The root failure is in the first step, and specifically in the collection. Rewording the prompt cannot retrieve a page that is not in the collection. An instruction to say "I could not find a current policy" might stop the confident wrong answer; that limits the damage but does not fix coverage.

The fix has two parts. First, add the new page and retire the old one, and name who keeps the collection current (300.2 covers who that is). Second, test it: re-ask the failing question, check that the new page is retrieved, and check that the answer matches it. Adding the page fixes coverage; only the retest shows the answer is fixed.

2. What the passages change, and what they cannot guarantee

They become more text in the input

Retrieval does not change the model. It changes the model's input. In the RAG paper, the generator combines the input and a retrieved passage by simply joining them into one sequence.1 This course uses that picture for every retrieval assistant: the passages become more text in the model's context window, alongside the question and any instructions, and the model writes from all of it. Whether a particular product does exactly this is something to check in its documentation, not assume.

"Does not change the model" is about the model's weights. It is not a promise about storage. The application around the model may keep the question, the retrieved passages and the answer in logs or conversation history, and a provider may have its own rules about later use. Check the tool's retention policy, or ask its owner; do not assume either way.

They are used unevenly by position

Text in the context window is not all used equally. In Lost in the Middle, researchers gave models a question and a set of documents, only one of which held the answer, and moved that document to different positions. Performance was often highest when the relevant information was at the beginning or end of the input, and it dropped significantly when the model had to use information in the middle of a long input. This held even for models built for long contexts.4

So a retrieval assistant that returns twenty passages has not "given the model the answer" just because the right passage is somewhere among them. Where it sits matters. The study measured specific models in 2023 on research tasks; it shows the effect exists and is worth testing for, not how large it is in any given product.4

What they cannot guarantee

Adding the right passage to the input raises the chance of a right answer. It does not guarantee three things:

  1. That the model reads it correctly. The model can still misread, mix up or go beyond the passage. Confabulation is a risk of generative AI in general, not only when nothing was retrieved.3
  2. That the model uses a passage in the middle of a long input. See Lost in the Middle, above.4
  3. That the model treats an instruction inside a passage as data. Researchers who studied indirect prompt injection argue that applications built on language models "blur the line between data and instructions". They showed that attackers can plant instructions in content an application is likely to retrieve, such as web pages, without ever talking to the system directly, and that this worked against real applications.5 A retrieved passage is text in the same context window as the system's own instructions. To take an illustration of our own: a line in a supplier document that says "ignore the other passages" may be followed. So an instruction in the system prompt is not a security boundary. The course's rule: no direct path from the model to a consequential action, such as sending or changing something; a gate outside the model stands between them. Module 300.6 covers the attack and the defences.

Why a citation does not prove the answer

The misconception this corrects: "If it cites a document, the answer is right." A citation in an answer is a claim, and it can fail in two ways.

The RAG authors listed providing provenance for a model's decisions as an open research problem, and presented retrieval as a way to help with it.1 The course's own conclusion: retrieval makes checking possible; it does not do the checking for you.

In practice, check a citation in this order:

  1. Exists and was retrieved. Is the cited passage in the trace, among the passages actually retrieved for this question?
  2. Supports. Does that passage say what the sentence citing it says?
  3. Current. Is it the current version of the document?

3. Was it retrieval or generation?

The misconception this corrects: "Every wrong answer is a hallucination, and nothing more can be said." Calling every wrong answer a hallucination names the symptom and stops there. In a RAG system you can usually say which step failed, as long as you can see the trace: the question, the passages the find step returned, and the answer.

RAG evaluation research separates these on purpose. RAGAs, for example, scores context relevance (did the retrieved passages fit the question?) apart from faithfulness (does the answer stick to those passages?) and answer relevance (does it address the question?).6 The Dense Passage Retrieval paper measures the find step alone, before any answer is written.2

Ask one question of the trace: were all the passages needed for a right answer among the passages found?

The trace showsWhich step failed firstWhat to fix
A needed passage is not among those found (wrong passages, an old version, none at all, or only some of the passages the answer needs)RetrievalThe collection (is the page in it, and current?) or the search (does it find the page for this wording?)
All the needed passages are among those found, and the answer is wrong, unsupported or ignores themGenerationHow passages are given to the model (how many, in what order), the instructions, or the model; and keep checking answers against passages

Three notes on the table:

At Big Widget Company: two traces. Both are made up for this lesson, and each question needs only one passage.

Trace A. Question: "How many days does a dealer have to file a warranty claim?" Passages found: (1) Travel and expenses policy, section 2; (2) Canteen opening hours. Answer: "Dealers have 30 days to file a warranty claim." Retrieval failure. Neither passage is about warranty claims, so the answer cannot have come from them. The model wrote a plausible number anyway.

Trace B. Question: the same. Passages found: (1) Warranty policy, section 4: "Dealers must file a claim within 60 days of the repair date." Answer: "Dealers have 30 days to file a warranty claim (Warranty policy, section 4)." Generation failure. The right passage was found and even cited, and the answer still contradicts it. This is the citation misconception from section 2 in one line.

If you cannot see the trace, say so. Without the passages found, you cannot tell the two failures apart. "I don't know yet: the tool does not show what it retrieved" is an honest finding. The next step is to ask the tool's owner for the trace.

4. The three yeses for retrieval

These are the retrieval parts of the three yeses: Get to Yes · Stay at Yes · Recover to Yes.

The assistant decides none of them. A named person does, at a gate, with one of four answers: go ahead (allow), only this far (constrain), wait for a person (hold) or no (deny). A yes is conditional: it covers the collection, questions and checks it names, and nothing more.

Trace or receipt? They are different things. The trace holds the question, the retrieved passages and the answer, so it is a private work record: keep it access-controlled, and only where your workplace's policy allows. A receipt, in this course, records the gate's decision (go ahead, only this far, wait for a person, no). It never holds prompts, outputs, payloads or personal data. Do not paste a trace into a receipt you share. A receipt shows what was decided; it does not show that an answer was right.

My checklist:

Words to know: retrieval-augmented generation (RAG), retriever, generator, collection, index, passage, context window, trace, retrieval failure, generation failure, faithfulness, confabulation, indirect prompt injection, gate, receipt.

Further learning (optional, advanced, not part of this lesson):

Sources

  1. s1 Patrick Lewis, Ethan Perez, Aleksandra Piktus, et al. (2020). Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks. Paper. Checked 2026-11-19 by source-checker round-3 re-check (separate Claude session b1741703, Claude Opus 5.5). ↩ ↩ ↩ ↩ ↩ ↩
  2. s2 Vladimir Karpukhin, Barlas Oğuz, Sewon Min, et al. (2020). Dense Passage Retrieval for Open-Domain Question Answering. Paper. Checked 2026-11-19 by source-checker round-3 re-check (separate Claude session b1741703, Claude Opus 5.5). ↩ ↩
  3. s5 National Institute of Standards and Technology (2024). Artificial Intelligence Risk Management Framework: Generative Artificial Intelligence Profile (NIST AI 600-1). Official doc. Checked 2026-11-19 by source-checker round-3 re-check (separate Claude session b1741703, Claude Opus 5.5). ↩ ↩ ↩
  4. s3 Nelson F. Liu, Kevin Lin, John Hewitt, et al. (2024). Lost in the Middle: How Language Models Use Long Contexts. Paper. Checked 2026-11-19 by source-checker round-3 re-check (separate Claude session b1741703, Claude Opus 5.5). ↩ ↩ ↩ ↩
  5. s6 Kai Greshake, Sahar Abdelnabi, Shailesh Mishra, Christoph Endres, Thorsten Holz, Mario Fritz (2023). Not what you've signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection. Paper. Checked 2026-11-19 by source-checker round-3 re-check (separate Claude session b1741703, Claude Opus 5.5). ↩
  6. s4 Shahul Es, Jithin James, Luis Espinosa-Anke, Steven Schockaert (2024). RAGAs: Automated Evaluation of Retrieval Augmented Generation. Paper. Checked 2026-11-19 by source-checker round-3 re-check (separate Claude session b1741703, Claude Opus 5.5). ↩ ↩

Next: the quiz