Learn

GuideInstructions & contextCompanion to Context and memory

Retrieval and RAG: helping a bot answer from your sources

Retrieval means finding relevant information in a collection. Retrieval-augmented generation, usually shortened to RAG, combines finding information with generating an answer that uses it. [1]

A bot might search project notes, load a few useful passages, and then answer your question. The stored documents and the model’s learned knowledge are separate sources of information.

A question with two possible answers

Imagine a plant-swap organizer asks, “Which entrance should visitors use?” The project folder contains:

DocumentWhat it says
Early planning noteEntrance undecided; possibly the west door
Approved event noteUse the Oak Street entrance
Volunteer instructionsVolunteers enter through the loading area

A search for “entrance” could return all three. The answer needs more than a word match. It needs the intended audience, the document’s status, and enough surrounding text to interpret it.

A useful reply would be: “Visitors should use the Oak Street entrance, according to the approved event note.” Linking that note lets you check the answer.

If the bot finds only the early planning note, it should explain that the entrance is unconfirmed in the source it found. It should not quietly turn a possibility into a final decision.

Three notes mention entrances. The approved visitor note supports Oak Street. The early draft is undecided, and the loading area is for volunteers.

Swipe sideways to see the whole diagram, or open it full size.

Which entrance is for visitors?. Choose a passage for its meaning, audience, and approval status as well as its matching words.

Figure explanation: An early planning note suggests a possible west door. An approved event note says visitors use the Oak Street entrance. Volunteer instructions name a loading area for volunteers only. Checking the audience and approval status selects the approved event note for the visitor question. The resulting answer names Oak Street and identifies its source. These documents are invented teaching examples.

Sources

  1. Patrick Lewis and colleagues, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks, first submitted May 22, 2020; checked September 25, 2026. Supports the historical landmark and retrieval/generation combination.
  2. Anthropic, Introducing Contextual Retrieval, published September 19, 2024; checked September 25, 2026. Supports embeddings, keyword retrieval, and the loss of context when documents are divided into chunks. The entrance example is original.

Cookie preferences