RAG vs Fine-Tuning vs Long Context
There are three main ways to make a model use your knowledge. RAG retrieves the relevant passages for each question. Fine-tuning trains the model further on your examples, changing its weights. Long context simply sends whole documents with every request, which modern models with very large context windows make possible. Each fits a different problem, and many real systems combine them.
Three Approaches
| Long context | RAG | Fine-tuning | |
|---|---|---|---|
| How it works | Send all documents with every question | Retrieve the few relevant passages | Train the model on your examples |
| Best for | A few short documents | Many documents, facts that change | Style, format and behavior |
| Updating knowledge | Edit the document | Re-index the changed document | Retrain the model |
| Cites sources | Possible | Yes, naturally | No |
| Cost per question | High: every page, every call | Low: a few passages | Low per call; training costs up front |
| Effort to build | Lowest | Medium | Highest |
Choosing an Approach
| Situation | Choose |
|---|---|
| Three short policy documents, a few hundred questions a day | Long context first: simplest, and prompt caching lowers the cost of resending them |
| Thousands of help articles that change weekly | RAG: send only what each question needs, and update instantly |
| Replies must always follow a strict house format | Prompting and structured output first; fine-tuning only if they can't achieve it |
| New facts the model must "know" without being told | RAG, not fine-tuning: training doesn't reliably store facts, and they go stale |
Combining Them
Real systems often mix approaches: RAG retrieves the passages, a long context window holds many of them at once, and fine-tuning (or careful prompting) keeps the tone and format consistent. Start with the simplest approach that works and add complexity only when tests show you need it.
Common Mistakes
Fine-tuning to add facts. Use RAG or long context; fine-tuning is for behavior.
Building RAG for a handful of short documents. Long context may be simpler and just as good.
Sending everything every time at scale. Long context grows expensive and slow with large collections.
Interview Corner
When would you choose RAG over fine-tuning?
When the model needs facts from documents, especially facts that change or need citations. Fine-tuning suits consistent behavior, style or format, not changing knowledge.
Why not always use long context?
Every request pays for every page and takes longer to process, which becomes costly with large or growing collections. It works well when the documents are few and short.
Practice
Exercise: choose for three cases. A city library's 20,000 FAQ pages; a law firm that wants replies in its exact letter format; a club with a two-page rulebook. Choose an approach for each and write one sentence explaining why.
Check your understanding:
- What does fine-tuning change?
- Why is RAG easier to update than fine-tuning?
- When is long context the simplest good choice?
Key Takeaways
Quick reference
| Need | Approach |
|---|---|
| A few short documents | Long context |
| Many or changing documents | RAG |
| Fixed style or format | Prompting, then fine-tuning |
| Citations | RAG |
Was this tutorial helpful?