Why this map comes first
Your feature works in the demo. Then real traffic arrives and about one answer in ten is wrong. Someone on the team says "let's fine-tune," someone else says "just use the bigger model," and a third person wants to "add RAG." All three might be right, or all three might be wasting a month.
There are four levers for improving a model-powered feature:
- Better prompts: clearer instructions, examples, an output schema.
- Retrieval: fetch the right facts at request time and put them in the context.
- Fine-tuning: change the model's weights by training it on your examples.
- A bigger model: swap in a more capable model.
Each lever fixes a different kind of failure. Choose the lever before you know what kind of failure you have and you end up debugging blind. A good comparison is a production incident: you read the stack trace before you scale the cluster.
Step 1: Sort the failure into one of four buckets
Collect 20 to 50 real failures and label each one. Nearly all of them fall into one of four types:
| Problem | What it looks like | Lever that fits |
|---|---|---|
| Knowledge | The model doesn't know a fact: last week's pricing, your internal API, a customer's order | Retrieval. Facts change, and weights are a poor database. |
| Behaviour | It knows enough but acts wrong: wrong tone, ignores a policy, over-apologises | Prompt first. Fine-tune if prompting can't make it consistent. |
| Format | The content is right but the shape is wrong: broken JSON, missing fields, extra chatter | Prompt and schema first (structured output). Fine-tune for stubborn cases or to shrink the prompt. |
| Capability | The task is genuinely too hard: multi-step reasoning, subtle judgement | Bigger model. Later, maybe teach a small model to copy it. |
Here is a tiny triage helper you can actually use:
# triage.py: tally labelled failures so you fix the biggest bucket first
from collections import Counter
LEVER = {
"knowledge": "retrieval",
"behaviour": "prompt -> fine-tune",
"format": "prompt + schema -> fine-tune",
"capability": "bigger model",
}
# Each failure was read by a human and given one label
failures = [
{"id": 101, "label": "knowledge", "note": "quoted old refund window (30d, now 14d)"},
{"id": 102, "label": "format", "note": "JSON missing 'priority' field"},
{"id": 103, "label": "knowledge", "note": "invented SKU that doesn't exist"},
{"id": 104, "label": "behaviour", "note": "promised a refund agent can't approve"},
{"id": 105, "label": "capability", "note": "mis-split a 3-item multi-currency order"},
]
for label, n in Counter(f["label"] for f in failures).most_common():
print(f"{label:<11} {n} -> try: {LEVER[label]}")
knowledge 2 -> try: retrieval
format 1 -> try: prompt + schema -> fine-tune
behaviour 1 -> try: prompt -> fine-tune
capability 1 -> try: bigger model
Gotcha: "It hallucinated" is not a label. Ask why. If the model never had the fact, the problem is knowledge. If the fact was in the context and it ignored it, the problem is behaviour or capability.
Step 2: Why roughly this order
Try the levers from cheapest and easiest to undo, to most expensive and hardest to undo:
- Prompting is a text edit. It takes minutes, rolls back with git, and needs no new infrastructure.
- Retrieval adds a search step and a data pipeline, but your knowledge stays in a database you can update every hour.
- Fine-tuning needs a dataset, training runs, evals, and retraining whenever the base model or your requirements change. You now own a model.
- A bigger model is easy to switch to, but you pay for it on every request in money and latency, forever.
OpenAI's own model-optimisation guide recommends the same loop: write evals first, iterate on prompts, and fine-tune only for the cases that need it.
Trade-off: The order is rough. One cheap trick is to run your failing cases through a bigger model as a diagnostic, early on. If the bigger model also fails, the problem is probably missing knowledge or a bad prompt, not intelligence. If it passes, you have learned that it's a capability problem. You don't have to ship that model to learn this.
Step 3: Who holds the weights, and who runs them?
A model's weights are the big file of learned numbers. Three setups matter:
| Kind | Who holds the weights | Who runs them | Examples |
|---|---|---|---|
| API-only | The vendor | The vendor | Claude, the GPT models behind OpenAI's API, Gemini |
| Open-weight | Anyone can download them | You, or any host you pick | OpenAI's gpt-oss (Apache 2.0, Aug 2025), Google's Gemma 4 (Apache 2.0, Apr 2026), Qwen |
| Tuned | Whoever trained it: you (from open weights) or the vendor (hosted fine-tuning) | Same as above | Your Gemma fine-tuned on support tickets |
With the OpenAI SDK, switching between setups can be a one-line change, because Ollama offers an OpenAI-compatible endpoint:
import OpenAI from "openai";
// API-only: the vendor holds and runs the weights
const hosted = new OpenAI(); // reads OPENAI_API_KEY
// Open-weight: the weights are on YOUR machine; Ollama runs them
const local = new OpenAI({
baseURL: "http://localhost:11434/v1",
apiKey: "ollama", // required by the SDK, ignored by Ollama
});
const res = await local.chat.completions.create({
model: "gpt-oss:20b", // ~16 GB of memory is enough for this one
messages: [{ role: "user", content: "Classify: 'card charged twice'" }],
});
console.log(res.choices[0].message.content);
Pitfall: If a vendor tunes the model for you, the vendor holds the result. Platforms change: OpenAI is winding down its fine-tuning platform and no longer accepts new users. Weights you hold can't be switched off by someone else. In return, you take on the job of running them.
Step 4: The one-page decision brief
Before anyone trains anything, write this down:
# Decision brief: Support-ticket triage
Failure today: 12% of tickets mis-routed (eval set: 200 labelled tickets)
Breakdown: 60% knowledge, 25% format, 15% capability
| Option | Fixes | Risks | Evidence that rules it OUT |
|--------------|--------------|---------------------------|---------------------------------------------|
| Better prompt| format | prompt bloat | schema + 5 examples still <95% valid JSON |
| Retrieval | knowledge | bad search = bad answers | right doc retrieved but answer still wrong |
| Fine-tune | behav/format | data cost, retraining | prompt+retrieval already hit target |
| Bigger model | capability | per-call cost, latency | bigger model fails the same cases |
Decision: retrieval + schema first; re-run eval; revisit in 2 weeks.
The last column matters most. Every option needs a test that could prove it wrong. Otherwise the loudest person in the room makes the decision.
Hands-on exercise
Pick a real LLM feature (yours, or a coding-agent task you use every day):
- Collect 20 failures and label each one knowledge / behaviour / format / capability using
triage.py. - Run the five worst failures through a larger model as a diagnostic and note what changes.
- Fill in the decision brief, including a concrete "rules it out" test for every option.
Key takeaways
- Find out what kind of failure you have before you choose a lever: knowledge → retrieval, behaviour/format → prompt then tune, capability → bigger model.
- Try the levers from cheapest and most reversible (prompt) to most costly to own (tuning) or run (bigger model).
- A bigger model makes a cheap diagnostic even if you never ship it.
- API-only: the vendor holds and runs the weights. Open-weight: anyone can download and run them. Tuned: whoever trained it holds the result.
- A decision brief without "evidence that rules it out" is just an opinion.