RAG vs fine-tuning vs long context
Decide whether retrieval is the right tool before you build a pipeline around it.
There are three ways to get knowledge in front of a model. Put it in the prompt every time, retrieve the relevant part per question, or change the model's weights with fine-tuning. They solve different problems and are often confused.
Retrieval is the right default when knowledge is large, changes often, must be cited, or must respect who is allowed to see what. Long context is simpler when the whole corpus fits and questions are rare, but you pay for every token on every call and quality can fall as the window fills. Fine-tuning teaches style, format and behaviour. It is a poor way to add facts, because facts baked into weights go stale and cannot be cited or deleted on request.
Many real systems combine them: retrieval for facts, a light fine-tune or a good prompt for tone and output format. Decide on the questions you must answer, how often the data changes, and whether answers need sources.
Key points
- Use retrieval for large, changing, citable or permissioned knowledge.
- Use long context when the corpus is small and queries are infrequent.
- Use fine-tuning for behaviour and format, not for adding facts.
- Combining retrieval with a tuned or well-prompted model is common.
Trade-offs
| Choice | You gain | You pay |
|---|---|---|
| RAG | Fresh data, citations, access control | More moving parts; retrieval quality caps answers |
| Long context | No pipeline to build | Cost and latency per call; attention can degrade on long inputs |
| Fine-tuning | Consistent style and format, shorter prompts | Stale facts, no citations, training and eval effort |
Answer these out loud
- 1A legal team wants answers with page citations over 40,000 documents that change weekly. Which approach, and why not the other two?
- 2Your whole knowledge base is 30 pages and used twice a day. What is the simplest thing that works?
Use this from an agent
Any MCP client, including Grok, can read this lesson. See how to connect.
curl https://engineeros-delta.vercel.app/api/v1/topics/rag-when-and-why