Lesson 04: Understand RAG through a library question
Set frameworks and code aside. You have one question—whether the library opens on 18 October 2026—and a few rule cards. Answering it lets you follow the main RAG workflow.
Which card should we find?
A’s opening-hours title is an obvious match. D contains the requested date in a closure notice. Find D; include A if comparing with normal hours. Borrowing limits in B do not help here.
Retrieval finds candidates within a collection. Read their contents afterward: a matching title or high score does not establish answerability.
Give the evidence to the model
Supply the question, A, and D, asking for an answer based on these sources, with IDs beside claims and no guessing. The model can now see the exception rather than rely on learned generalities.
Augmentation supplies evidence in the response context, usually without retraining. When the collection is too large to provide whole, retrieval selects what is needed.
Generation organizes the answer: all-day maintenance closure on the 18th [D], versus ordinary Sunday hours of 09:00–17:00 [A]. Review whether each source supports its corresponding statement.
Evidence preparation comes before answering
A and D are ready because the pack is already organized. Real PDFs, webpages, and handbooks need collection, checking, chunking, and indexing. Much of this preparation happens before queries rather than being repeated for every question.
Keep two sequences: documents → chunks → index for preparation, and question → relevant chunks → evidence-bearing input → answer for querying. Vector search is one retrieval method; keyword search can also work. No specific tool is required to begin.
Try it with paper cards
Copy A–E and ask the current borrowing limit. Select cards, record why, and write an answer. Locate every claim on a card. Missing support can indicate omitted evidence or an invented addition.
Which card applies?
B establishes the current three-book limit. E’s two-book rule is superseded historical evidence. Selecting cards manually simulates retrieval and is enough to understand this flow without installing a vector database.
Further reading: LlamaIndex: Introduction to RAG
← Previous · Learning plan · Fictional library practice sources · Next →