RAG — Retrieval-Augmented Generation
A model's knowledge is frozen at training time. RAG gives it access to any document, database, or knowledge source at query time — by embedding documents into a vector store, retrieving the most relevant chunks when a question arrives, and injecting them into the prompt before generation.
It doesn’t know you
It can’t answer. Your policy was never in anything it read.
And policies change. Retraining a model every time a document changes isn’t practical.
Paste it in
Last lesson: the AI can use anything in its window. So paste the policy in.
That works for one page. It doesn’t work for a help centre with thousands of pages.
Cut into chunks
So first, cut every document into short pieces, a paragraph or so each.
These pieces are called chunks. You do this once, ahead of time, not for every question.
Chunks on a map
Each chunk gets a spot on a meaning map, the way words did in lesson 3.
These spots are embeddings of whole chunks, kept in a searchable store often called a vector database.
Where it lands
Your question gets a spot on the same map. Where would each one land?
Tap the area you think it lands in.
Closest chunk wins
The search returns the chunks nearest the question. For “Refund on an ebook?”, which comes first?
Paste, then answer
The closest chunks go into the window with your question. The AI answers from them.
That’s the whole idea: look it up, paste it in, then answer.
Wrong chunk, wrong answer
If the search picks the wrong chunk, the AI answers confidently from the wrong text.
So finding the right chunks matters as much as the model. Lesson 20 shows how to get that right.
Look it up first
Look it up, paste it in, then answer. The model answers from your documents without retraining.
This is retrieval-augmented generation, usually shortened to RAG.