Last updated
How RAG Works: The Pipeline
Definition: RAG has two phases. First you index your documents (done once, in advance). Then, for each question, you retrieve, augment, and generate.
Phase 1 — Indexing (prepare your knowledge)
- Load your documents (PDFs, web pages, notes).
- Chunk them into small passages.
- Embed each chunk into a vector (a list of numbers capturing its meaning).
- Store the vectors in a vector database.
Phase 2 — Answering (for every question)
- Retrieve — embed the question and find the most similar chunks.
- Augment — paste those chunks into the prompt alongside the question.
- Generate — the language model answers using the provided context.
The whole flow in one line
Question → find relevant chunks → "here is the context, now answer the question" → grounded answer.
💡 Coming up: the next lessons build each piece — embeddings, similarity, chunking, and retrieval — with code you can actually run.
Ad · responsive