Home › Claude Ecosystem Guides
RAG with Claude: grounding answers in retrieved text
RAG lets Claude answer from source text you retrieve at query time instead of from memory alone — grounding replies in evidence you can cite, and changing what the model sees rather than its weights.
What RAG actually does
Retrieval-Augmented Generation (RAG) is a pattern that lets Claude answer from source text you supply at query time, rather than only from what it absorbed during training. Instead of trusting the model to recall a fact, you fetch the passages that contain it and place them in the prompt, so the answer is built on evidence you can point to.
This matters most for knowledge the model never saw or should not guess at: your company's internal documents, a contract signed last week, a manual that changes every month. RAG shrinks hallucination because the model is reasoning over text in front of it, not reconstructing something half-remembered. Crucially, RAG changes what the model sees, not the model's weights — nothing is retrained, which is why you update the knowledge by editing a document instead of running a training job.
The chunk, embed, retrieve, augment pipeline
A typical RAG pipeline has four moving parts. First you split each document into chunks small enough to be specific but large enough to stay coherent. Then you embed every chunk into a vector — a numeric representation of its meaning — and store those vectors. At query time you embed the user's question the same way and pull back the chunks whose vectors sit closest to it. Finally you augment the prompt: the retrieved chunks go in as context, and Claude answers from them.
- Chunk — break sources into passages, with a little overlap so a sentence is not cut mid-thought.
- Embed — turn each chunk and the query into vectors in a shared space.
- Retrieve — rank chunks by similarity and keep the top few.
- Augment — assemble the winning chunks into the prompt and ask.
At scale a reranking step is often added after retrieval: a cheap similarity search casts a wide net, then a stronger model reorders the candidates so the most relevant passage lands at the top of the prompt.
When a long context lets you skip retrieval
Retrieval exists to solve a size problem: you cannot fit a million words into a prompt, so you fetch only the relevant slice. But Claude's context window is large, and for a small or medium corpus the whole problem can disappear. If your documents comfortably fit, you can drop them straight into the prompt — an approach often called in-context, or simply "put it all in the prompt" — and let the model read everything.
This is simpler: there is no vector store to maintain, and no classic failure where the right passage was never retrieved so the model had no chance. The trade-off is cost and latency per request, since the documents are reprocessed every time. Retrieval earns its keep once the corpus outgrows the window, or once you answer the same questions over a stable body of text often enough that narrowing down first is clearly cheaper.
Citations make the answer verifiable
A grounded answer is only trustworthy if you can check it, and Claude's document handling supports citations: the model can point back to the specific passage a claim came from. That turns "the model says the deadline is thirty days" into "the model says thirty days, and here is the clause it read." A reviewer opens the source and confirms, and a wrong retrieval becomes visible instead of hidden inside fluent prose.
Citations also change how you debug a RAG system. When an answer is off, the cited passage tells you whether retrieval fetched the wrong text or the model misread the right text — two very different fixes. For anything with consequences — legal, medical, financial — surfacing the source is not a nicety; it is what makes the output usable at all.
Common pitfalls
Most RAG disappointments trace back to retrieval, not the model. If the relevant passage is not in the retrieved set, no amount of prompting recovers it — the answer will be confident and wrong. Chunking is the usual culprit: chunks too large dilute the signal, too small sever the context a sentence needs. Test retrieval on its own before blaming the generation step.
A second trap is confusing RAG with fine-tuning. RAG feeds the model fresh text; fine-tuning adjusts weights. If your goal is up-to-date or private knowledge, RAG is the answer, and it is worth exhausting good prompting and retrieval before reaching for training. Finally, garbage in the store is garbage in the answer — RAG faithfully grounds on whatever you retrieved, including a stale or duplicated document.
Frequently asked
- Does RAG retrain or fine-tune Claude?
- No. RAG changes only what the model sees in the prompt at query time — the retrieved passages. The model's weights are untouched, which is why you update knowledge by editing documents, not by training.
- When can I skip retrieval and just put documents in the prompt?
- When your corpus fits comfortably in the context window. For a small or medium set of documents, in-context prompting is simpler and avoids retrieval misses; retrieval pays off once the corpus outgrows the window.
- How do citations help with a RAG system?
- Citations let a reader trace each claim back to its source passage, so a wrong answer is visible instead of hidden. They also tell you whether a bad answer came from wrong retrieval or a misread — two different fixes.
Work through it interactively
Every area has questions, spaced-repetition cards and a progress record. Those need an account, which is free and takes a moment.
Open the interactive track Create a free account