Lesson 2 of 16 · Foundations
RAG vs Fine-Tuning
RAG vs fine-tuning: what each changes, cost, freshness, sources and effort, a rule of thumb (RAG for knowledge, fine-tuning for behaviour) and when to combine.
- 6 min read
- Intermediate
- Reviewed
- Explain what RAG changes and what fine-tuning changes
- Compare them on freshness, sources, cost and effort
- Choose the right approach for a given need
- Estimate the extra token cost that RAG adds
Two ways to make a model fit your needs
RAG leaves the model untouched and changes what it reads for each question. Fine-tuning changes the model itself. That one difference explains most of the trade-offs.
| RAG | Fine-tuning | |
|---|---|---|
| What changes | The prompt: relevant passages are added | The model's weights |
| Best for | Knowledge: facts, documents, data | Behaviour: tone, format, style, narrow skills |
| Updating facts | Edit a document; works immediately | Retrain the model |
| Showing sources | Yes, you know which passages were used | No; knowledge is blended into the weights |
| Upfront effort | An ingestion pipeline and a search index | A training dataset (often hundreds to thousands of good examples), training runs |
| Cost per question | Extra input tokens for the passages | Often lower (shorter prompts), but training costs extra |
| Access control | Filter what each user's search can see | Hard: everything trained in is available to everyone |
A useful rule of thumb: RAG for knowledge, fine-tuning for behaviour. Fine-tuning is a poor way to teach facts: the model may blend or half-remember them, it can't show where an answer came from, and every change needs new training.
The cost of RAG, in tokens
Every retrieved passage becomes input tokens that you pay for and that take time to process. A quick estimate helps you choose how many chunks to send:
# What does RAG add to each request? Retrieved text = extra input tokens.
# The prices below are made-up round numbers: look up your provider's real prices.
price_per_million_input = 1.00 # dollars per 1 million input tokens (example)
chunks_per_question = 5
tokens_per_chunk = 300
questions_per_month = 100_000
extra_tokens = chunks_per_question * tokens_per_chunk * questions_per_month
extra_cost = extra_tokens / 1_000_000 * price_per_million_input
print(f"Extra input tokens per question: {chunks_per_question * tokens_per_chunk:,}")
print(f"Extra input tokens per month: {extra_tokens:,}")
print(f"Extra cost per month: ${extra_cost:,.2f}")Change chunks_per_question to 3 or tokens_per_chunk to 500 and watch the cost move. Retrieving well (fewer, better chunks) saves money as well as improving answers.
Choosing, with examples
Before either, always try better prompting: clear instructions and a few examples solve many “the model doesn't do what we want” problems at no extra cost.
Common mistakes
Decide which approach fits each need. Fresh facts and citations point one way; tone and style point the other.
needs = {
"answers must use documents that change every week": "RAG",
"replies must always follow our brand's tone and format": "?",
"answers must cite the policy they came from": "?",
"a small, cheap model must write in our house style without long instructions": "?",
}
# Replace each "?" with "RAG" or "fine-tuning":
# RAG adds knowledge (and sources); fine-tuning changes behaviour and style.
for need, choice in needs.items():
print(f"{choice}: {need}")
Your product prices change every week and answers must show where each price came from. Which approach fits best?
Summary
- RAG changes what the model reads; fine-tuning changes the model's weights.
- Rule of thumb: RAG for knowledge, fine-tuning for behaviour (style, format, narrow skills).
- RAG gives fresh facts, sources and per-user access control; it costs extra input tokens per question.
- Try better prompting first, and combine approaches when a project needs both.
Next: the parts of a RAG system and how they connect.
Finished reading? Tick it off to track your progress.