Module 1 · When and why to fine-tune
Prompting vs RAG vs fine-tuning: decision grid
6 min read
Fine-tuning is the most powerful tool for specializing a model… and the one most often misused. Many projects fine-tune to "teach knowledge" to the model, where a document search (RAG) would have been enough, or to fix a behavior that a better prompt would have solved in an hour. This lesson gives a quantified decision grid, then applies it to the course's running case: triaging customer support messages for the Nimbus store.
Three levers, three problems
| Lever | What it changes | It solves | It does not solve |
|---|---|---|---|
| Prompting | The instructions and examples sent with each request | A behavior that is simple to describe, a task the model already knows how to do | A format the model follows poorly, a cost per request that is too high |
| RAG | The documents provided to the model with each request | Knowledge: documentation, catalog, changing rules | A style, a format, a behavior |
| Fine-tuning | The model's weights | A behavior: format, style, tone, specialized task, refusals; and the cost and latency per request | Fresh or traceable knowledge (the model does not cite its sources and does not update itself) |
The most important rule: fine-tune a behavior, use RAG for knowledge. Facts learned through fine-tuning are blended into the weights, without a source, and become wrong as soon as reality changes; an indexed document updates in a minute.
The order of attempts
- Careful prompting, with a few examples: it is the baseline, and often the solution.
- RAG, if the task requires knowledge the model does not have.
- Fine-tuning, if the expected behavior remains out of reach of prompting, or if the cost and latency of prompting do not scale.
The three combine: a model fine-tuned for format and tone can perfectly well receive documents through RAG.
A quantified grid
| Criterion | Rather prompting | Rather fine-tuning |
|---|---|---|
| Quality gap after a good prompt | Small | Large and measured |
| Request volume | Low to medium | High (cost per request dominates) |
| Required latency | Tolerant | Strict |
| Example data available | A few dozen | Several hundred to thousands, clean |
| How often the task changes | Often (a prompt changes in minutes) | Rarely (every change = retraining) |
| Confidentiality | External API acceptable | Sensitive data: open-weights model hosted in-house |
No criterion decides alone. A large quality gap, a high volume and sensitive data point clearly towards fine-tuning a small open-weights model; a task that changes every week, towards prompting.
The Nimbus case
The task: read a customer's message and produce a JSON with the category, the product, the urgency and the refund request. Target volume: tens of thousands of messages per day; constraint: the messages contain personal data and must stay on the store's servers. Hence the choice of a small open-weights model hosted in-house, Qwen2.5-0.5B-Instruct. It remained to be seen whether prompting was enough.
The course's measurements, on 300 test messages with phrasings never seen during training:
| Approach | Exact match (test) | Valid JSON | Prompt tokens | Latency | Setup cost |
|---|---|---|---|---|---|
| Prompting, instruction only | 0.00 | 0.00 | 150 | 163 ms | None |
| Prompting, 3 examples | 0.05 | 0.26 | 387 | 238 ms | None |
| Prompting, 8 examples | 0.16 | 0.54 | 777 | 544 ms | None |
| LoRA fine-tuning (3 seeds) | 0.65 to 0.74 | 1.00 | 150 | ≈ 150 ms | 10 min of GPU |
| LoRA + synthetic data (3 seeds) | 0.68 to 0.79 | 1.00 | 150 | ≈ 150 ms | + 1 h of generation |
(Latencies measured in batches of 16 messages on a GTX 1060; exact match = all four fields right.)
The decision
Prompting fails here on format as much as on substance — the small model cannot follow a strict JSON instruction — and every example added to the prompt increases latency. Fine-tuning fixes the format in a few minutes of training and divides the prompt length by five. But it does not fix everything: generalization to new phrasings depends on data diversity (module 2), and even with synthetic data, the best run remains just below the success criterion set in advance (0.80, lesson 1.4). Fine-tuning is therefore the right lever — but the project is not finished: it needs better data, which is what module 2 is all about.
An alternative to keep in mind: a large general-purpose model through an API, with a good prompt, would probably do much better than the small model with prompting — but at the cost of a per-request price and a data transfer that Nimbus's specification ruled out. Fine-tuning a small model is often the answer to that equation: the quality of a large model on a narrow task, at the cost and under the conditions of a small one.
Key takeaways
- Fine-tune a behavior (format, style, task), bring knowledge through RAG.
- Order of attempts: prompting, then RAG if knowledge is needed, then fine-tuning.
- Decide with quantified criteria: quality gap, volume, latency, data, frequency of change, confidentiality.
- On Nimbus, prompting a small model fails on format; fine-tuning fixes it and divides the prompt by five.
- Fine-tuning a small model aims at a large model's quality on a narrow task, at a small one's cost.
Practice
- For a case in your company, fill in the quantified grid and note the recommendation it gives.
- Measure the token length of your current prompt (instruction + examples) and the corresponding cost for your monthly volume.
- List the knowledge and behaviors expected from your system: which ones belong to RAG, which ones to fine-tuning?