Module 10 · RAG · Lesson 21 of 34
The RAG pipeline
Index your documents, retrieve the relevant pieces, and have the model answer from them with sources.
In this lesson · about 20 minutes
- Describe the indexing and question-time halves of a RAG system
- Explain how chunk size, overlap and top-k change answers
- Write a grounded prompt that cites sources and admits gaps
A model does not know your company's policies, your product catalogue or yesterday's meeting notes. Retrieval-augmented generation (RAG) fixes that without retraining: before the model answers, your system looks up the relevant passages and puts them in the prompt.
Ahead of time (indexing):
- Load documents: web pages, PDFs, help articles, tickets.
- Chunk them into passages of a few hundred tokens.
- Embed each chunk and store it with its text and metadata in a vector database (Module 4).
At question time:
- Retrieve the top-k chunks most similar to the question (often embedding + keyword search together).
- Build the prompt: instructions, the chunks labelled as sources, and the question.
- Generate an answer that uses only those sources, with citations.
Try it · simulator
RAG pipeline simulator
The bakery's policy page is split into chunks. Ask a question, tune the chunking and how many chunks to retrieve, and see the prompt and the answer change.
Chunks in the index
6
Needed facts retrieved
1 / 1
Prompt size
76tokens
Answer
Grounded
The prompt sent to the model
SYSTEM: Answer using only the sources below. Cite them like (source 1). If the answer is not there, say you don't know. Source 1: We deliver Monday to Saturday between 9am and 6pm. There is no delivery on Sundays or public holidays. QUESTION: Do you deliver on Sunday?
Retrieval here scores word overlap, a simple keyword search. Real systems usually combine it with embedding search (Module 4) and may re-rank the results.
A grounded prompt
Answer the customer's question using ONLY the sources below.
Cite the source number after each fact, like (source 2).
If the sources do not contain the answer, say you don't know
and offer to connect them with a person.
Source 1: ...
Source 2: ...
Question: Is the carrot cake safe for a nut allergy?
Three parts do the work: only the sources, cite them, and permission to say "I don't know". Without the last one, the model fills gaps with plausible guesses.
Check your understanding0 of 3 correct
Quiz score: 0 of 3
Written by Noviq Academy in its own words. The simulators are small teaching models that keep the real idea and leave out the scale; their numbers (prices, speeds, scores) are illustrative. Model names, prices and features change quickly, so check your provider's current documentation before you build. Read-aloud uses your device's built-in voices.