RAG, end to end
Ingest, chunk, embed, retrieve, re-rank — and how to know it's actually finding the right thing.
☰
RAG is two jobs: file your documents ahead of time, then fetch the few passages that matter for each question. When an answer is wrong, check the second job first: it is the cheapest to inspect.
+ The whole system in one paragraph− Hide
The model only knows your data if it's in the prompt. RAG (retrieval-augmented generation) is the machinery that puts the right pieces there. It runs in two phases: ingestion, done ahead of time (parse, chunk, embed, index), and query time (rewrite, search, re-rank, build the prompt). This page builds it up one piece at a time, shows where each one fails, and ends with how to measure retrieval separately from the answer.
In this lesson
4 chapters · ~7 min · a quick check in eachEverything is on this page — just scroll down ↓
New to this? Warm up first+ optional
Words you'll meet
Skim these now and come back whenever a word shows up.
ⓘ Details & sources− Hide details
The terms, in plain words.
Do you even need RAG?
Anthropic's 2024 guidance: under ~200K tokens (~500 pages), just put it all in the prompt. Windows are bigger today, but cost and quality still favor retrieval as data grows.
ⓘ Details & sources− Hide details
Decide this first: it decides whether the rest of this page applies to you.[2]
What it must do — and how well
Yellow notes are what RAG must do; blue ones are how well. A demo only needs the yellow notes. Production needs the blue ones, and most of the engineering goes into them.
The whole system
5 steps. Follow the flow one step at a time — what happens first, and what comes next.
RAG, on one page
A document arrives and is parsed into clean text, keeping its tables and headings.
Curious? Go deeper+ 1 optional
How a search by meaning works
Each chunk becomes a point on a map where similar meanings sit close together. A question becomes a point too, and the nearest chunks are the ones retrieved.
Why build RAG one piece at a time instead of all twelve boxes at once?
Pick one — or just keep scrolling, it's not graded.
Keep going — it's free
Create your free account to unlock the rest of this lesson, keep your progress and pick up right where you left off.
- 2Ingestion
- 3Query time
- 4Measuring