RAG, explained

October 4, 2026 · ai · llms

Verdict: RAG — retrieval-augmented generation — is the open-book exam for AI. Instead of relying on whatever the model memorized during training, you give it a searchable library of your documents at query time: fetch the relevant passages, paste them into the prompt, and let the model answer from those. It's how nearly every "chat with your docs" product works. And its quality ceiling is decided almost entirely by the retrieval step, not by how smart the model is.

The idea in one paragraph

A language model is a student who took the exam prep course months ago and can't bring notes. RAG lets the student bring the textbook. When a question arrives, the system looks up the most relevant pages, photocopies them into the exam booklet, and the student answers with the material right in front of them. The model's job shifts from remembering facts to reading comprehension — which, it turns out, models are much better at.

How it actually works

The recipe, from the 2020 paper by Lewis et al. at Meta, has barely changed — only the components got better:

1. Chunk. Your documents are sliced into passages, typically a few hundred tokens each. A 200-page manual becomes a few thousand chunks.

2. Embed. Each chunk is converted into a vector — a long list of numbers capturing its meaning — by an embedding model. Similar meanings land near each other in vector space.

3. Index. The vectors go into a vector database with an approximate nearest-neighbor index (usually HNSW), so "find the 5 chunks closest to this query" takes milliseconds even across millions of chunks.

4. Retrieve. At query time, the user's question is embedded the same way, the index returns the top-k most similar chunks, and those chunks are pasted into the prompt alongside the question.

5. Generate. The model writes its answer grounded in the retrieved passages — and can cite them, so you can check its work.

flowchart TD D["Your documents
PDFs, wikis, tickets"] --> CH["Chunking
a few hundred tokens each"] CH --> EM["Embedding model
text becomes vectors"] EM --> VDB[("Vector database
HNSW index")] Q["User question"] --> QE["Embed the question"] QE --> RET["Nearest-neighbor search
top-k passages"] VDB --> RET RET --> PROMPT["Prompt = question
+ retrieved passages"] PROMPT --> LLM["LLM answers
from the passages"]

Why it took over

Three problems, one fix. Frozen knowledge: a model's training has a cutoff date, and retraining costs millions — but a document index can be updated in seconds. Hallucinations: a model answering from retrieved text fabricates far less than one answering from memory, and citations make every claim checkable. Private data: your company's docs were never in the training set, so without retrieval the model simply can't know them. RAG turned "the model doesn't know our stuff" from a retraining problem into a search problem.

Where it breaks

RAG's dirty secret is that the generator is rarely the bottleneck. The failure is almost always upstream:

flowchart LR Q2["Question:
who approved the refund?"] --> R2["Retriever returns
5 chunks about
'refund policy'"] R2 --> MISS["The approval email
was chunk 6.
Never retrieved."] MISS --> G2["Generator writes a
confident answer
from the wrong chunks"]

Retrieval is the ceiling. If the key passage isn't in the top-k, the model can't use it — no amount of model intelligence recovers information it never saw. Most RAG quality work is really retrieval work: better chunking, better embeddings, rerankers that re-score the candidates.

Chunking destroys structure. A table split across two chunks, a pronoun whose antecedent is three chunks back, a conclusion separated from its evidence — the index is a bag of passages, and relationships between them are lost unless you deliberately preserve them.

It doesn't fix reasoning. RAG finds the pages; the model still has to do multi-hop reasoning across them. On complex research tasks, naive retrieve-then-read stalls out — the recursive-language-models paper reported 51% for RAG with BM25 retrieval on BrowseComp+ versus 91.3% for the recursive approach, which searches and reasons iteratively instead of in one shot.

The modern upgrades

Nobody serious runs 2020-style RAG anymore. Rerankers take the retriever's rough top-50 and carefully re-score them down to the best 5. Contextual retrieval prepends a summary of each chunk's parent document before embedding, so "the refund was approved" carries its context with it. GraphRAG extracts entities and relationships into a knowledge graph for questions that span many documents. And agentic RAG hands the retriever to the model as a tool: instead of one retrieve-then-read pass, the model searches, reads, and searches again based on what it learned — which is, not coincidentally, halfway to the recursive approach.

The bigger picture

RAG's real legacy isn't the pipeline — it's the pattern: don't memorize, look things up. Parametric memory (weights) is expensive to update and impossible to audit; external memory (your documents) is cheap to update and comes with receipts. Every serious AI system now has some form of this split. The interesting frontier is who controls the lookup: a fixed pipeline that retrieves once, or the model itself, deciding what to fetch next based on what it just read. RAG started as the former. The field is moving toward the latter — and that's a story for the recursive-models post.