RAG vs Fine-Tuning vs Long Context

Updated · 5 min read
mediumPython 3.13airagfine-tuninglong-contextarchitecture

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

The binder, the index, and the practice
Long contextRAGFine-tuning
How it worksSend all documents with every questionRetrieve the few relevant passagesTrain the model on your examples
Best forA few short documentsMany documents, facts that changeStyle, format and behavior
Updating knowledgeEdit the documentRe-index the changed documentRetrain the model
Cites sourcesPossibleYes, naturallyNo
Cost per questionHigh: every page, every callLow: a few passagesLow per call; training costs up front
Effort to buildLowestMediumHighest

Choosing an Approach

SituationChoose
Three short policy documents, a few hundred questions a dayLong context first: simplest, and prompt caching lowers the cost of resending them
Thousands of help articles that change weeklyRAG: send only what each question needs, and update instantly
Replies must always follow a strict house formatPrompting and structured output first; fine-tuning only if they can't achieve it
New facts the model must "know" without being toldRAG, 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:

  1. What does fine-tuning change?
  2. Why is RAG easier to update than fine-tuning?
  3. When is long context the simplest good choice?

Quick check: RAG vs fine-tuning vs long context

4 questions
1What is fine-tuning best for?
2A help center has 20,000 articles that change weekly. Which fits best?
3How do you update knowledge in a RAG system?
4When is long context the simplest good choice?

Key Takeaways

Quick reference

NeedApproach
A few short documentsLong context
Many or changing documentsRAG
Fixed style or formatPrompting, then fine-tuning
CitationsRAG

Was this tutorial helpful?

Lesson 100 of 186