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

LeverWhat it changesIt solvesIt does not solve
PromptingThe instructions and examples sent with each requestA behavior that is simple to describe, a task the model already knows how to doA format the model follows poorly, a cost per request that is too high
RAGThe documents provided to the model with each requestKnowledge: documentation, catalog, changing rulesA style, a format, a behavior
Fine-tuningThe model's weightsA behavior: format, style, tone, specialized task, refusals; and the cost and latency per requestFresh 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

  1. Careful prompting, with a few examples: it is the baseline, and often the solution.
  2. RAG, if the task requires knowledge the model does not have.
  3. 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

CriterionRather promptingRather fine-tuning
Quality gap after a good promptSmallLarge and measured
Request volumeLow to mediumHigh (cost per request dominates)
Required latencyTolerantStrict
Example data availableA few dozenSeveral hundred to thousands, clean
How often the task changesOften (a prompt changes in minutes)Rarely (every change = retraining)
ConfidentialityExternal API acceptableSensitive 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:

ApproachExact match (test)Valid JSONPrompt tokensLatencySetup cost
Prompting, instruction only0.000.00150163 msNone
Prompting, 3 examples0.050.26387238 msNone
Prompting, 8 examples0.160.54777544 msNone
LoRA fine-tuning (3 seeds)0.65 to 0.741.00150≈ 150 ms10 min of GPU
LoRA + synthetic data (3 seeds)0.68 to 0.791.00150≈ 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

  1. For a case in your company, fill in the quantified grid and note the recommendation it gives.
  2. Measure the token length of your current prompt (instruction + examples) and the corresponding cost for your monthly volume.
  3. List the knowledge and behaviors expected from your system: which ones belong to RAG, which ones to fine-tuning?

Resources