Lesson 29.1 · 1 of 9 · 5 min read · Reviewed 24 Nov 2026
Prompting vs RAG vs fine-tuning
By the end, you can
- Choose between prompting, RAG and fine-tuning.
- Know what fine-tuning can and can't fix.
The order to try
1. Prompt engineering clear instructions, examples, structure (Part 2)
2. Retrieval (RAG) give the model the facts it needs (Part 4)
3. Fine-tuning change the model itself, for what's left
What each fixes
| Problem | Best tool |
|---|---|
| Needs facts it doesn’t have, or facts that change | RAG, or tools |
| Inconsistent format | Prompting, structured outputs (chapter 14) |
| A house style that examples can’t capture | Fine-tuning |
| A narrow skill used millions of times a day | Fine-tune a small model |
| Must run on a small or local model | Fine-tune that model |
| A domain vocabulary the model keeps getting wrong | RAG first, then fine-tuning |
Fine-tuning is not a knowledge store
Fine-tuningFine-tuning: Continuing to train a model on your own examples to change its behaviour or specialise it. on documents doesn’t reliably teach facts, can’t be updated quickly, and doesn’t cite sources. For facts, use retrieval.
The costs
- Data: hundreds to thousands of high-quality examples (29.2).
- EvalsEval: A repeatable test that measures how well an AI system performs on a set of cases with defined success criteria.: you need a test set to prove the tuned model is better (29.5).
- Upkeep: every new base model means re-tuning and re-testing.
- Risk: tuning can erode general ability or safety behaviour if done carelessly.
A test to apply
Before fine-tuning, write down what the best prompt plus retrieval scores on your eval, and what score would justify tuning. If you can’t state those numbers, you’re not ready to tune.
Key points
- Try prompting first, then retrieval (RAG), and fine-tune only when those fall short.
- RAG adds knowledge; fine-tuning changes behaviour: style, format, or a narrow skill.
- Fine-tuning needs good data, evals and upkeep, and must be redone for new base models.
- Fine-tuning a small model can cut cost and latency for a narrow, high-volume task.
Diagnose knowledge or behaviour gaps
Use eval scores from prompting and retrieval to decide, per use case, whether fine-tuning is justified.
You will have: A script that prints a recommended next step and its reason for each of four use cases.
Steps
- Read the eval results: prompt-only score, prompt plus RAG score, the target, and the gap type.
- If prompting already meets the target, stop there.
- If RAG closes the gap, recommend RAG; facts that change never go to tuning.
- Recommend fine-tuning only for a behaviour gap that remains after both, or for a narrow high-volume task.
- Print each decision with the numbers that support it.
Done when
- The weekly prices case is sent to RAG, not tuning.
- The house style case is the only one that recommends fine-tuning on quality grounds.
- Each line shows the baseline and target scores.
Open in the Playground No API key needed.
Starter code (Python)
CASES = [
{"name": "weekly prices", "prompt": 0.41, "rag": 0.93, "target": 0.90, "gap": "knowledge", "high_volume": False},
{"name": "reply format", "prompt": 0.95, "rag": 0.95, "target": 0.90, "gap": "behaviour", "high_volume": False},
{"name": "house style", "prompt": 0.62, "rag": 0.63, "target": 0.80, "gap": "behaviour", "high_volume": False},
{"name": "ticket queues", "prompt": 0.93, "rag": 0.93, "target": 0.90, "gap": "behaviour", "high_volume": True},
]
def decide(c):
# TODO: return (step, reason) using the order: prompt, then RAG, then fine-tune
return "TODO", ""
for c in CASES:
step, why = decide(c)
print(f"{c['name']:14} {step:28} {why}")
Show a solution
CASES = [
{"name": "weekly prices", "prompt": 0.41, "rag": 0.93, "target": 0.90, "gap": "knowledge", "high_volume": False},
{"name": "reply format", "prompt": 0.95, "rag": 0.95, "target": 0.90, "gap": "behaviour", "high_volume": False},
{"name": "house style", "prompt": 0.62, "rag": 0.63, "target": 0.80, "gap": "behaviour", "high_volume": False},
{"name": "ticket queues", "prompt": 0.93, "rag": 0.93, "target": 0.90, "gap": "behaviour", "high_volume": True},
]
def decide(c):
nums = f"(prompt {c['prompt']:.2f}, rag {c['rag']:.2f}, target {c['target']:.2f})"
if c["prompt"] >= c["target"] and not c["high_volume"]:
return "keep prompting", "already meets the target " + nums
if c["prompt"] >= c["target"] and c["high_volume"]:
return "consider a small tuned model", "quality is fine; tune for cost and latency " + nums
if c["rag"] >= c["target"] or c["gap"] == "knowledge":
return "use RAG", "the gap is missing facts " + nums
return "fine-tune", "a behaviour gap remains after prompt and RAG " + nums
for c in CASES:
step, why = decide(c)
print(f"{c['name']:14} {step:28} {why}")