Sub topic 12
A decision framework
This chapter turns the earlier material into a repeatable process for choosing between prompting, retrieval-augmented generation (RAG), and fine-tuning. It assumes you can call a chat-style LLM API, read Python, and know what an embedding and a context window are. It also assumes you have seen how each of the three approaches works. Here the focus is on deciding between them.
Why you need a process
Teams often pick an approach by habit. Someone read about fine-tuning, so the team fine-tunes. Someone built a vector database last quarter, so every problem becomes a retrieval problem. These choices are expensive to reverse, and they often fix the wrong thing.
A decision framework replaces preference with evidence. It has four parts:
- Diagnose the failure: is it missing knowledge or wrong behavior?
- Measure it with an evaluation set and a baseline.
- Climb the ladder from the cheapest approach to the most expensive, and stop when the evaluation passes.
- Check your constraints (cost, latency, freshness, control), because they can change the order.
Step 1: Diagnose the failure
Read 20 to 50 failing outputs and sort each one into a bucket. The question for each is: if a careful human had the same text in front of them as the model, would they get it right?
- Knowledge gap. The model lacks a fact. It invents a refund policy, quotes last year's price, or knows nothing about your internal tools. A human given the right document would succeed.
- Behavior gap. The model has the information but delivers it wrongly. The format is inconsistent, the tone is off, it ignores a labeling convention, or it misclassifies edge cases in a stable, repeatable way.
- Instruction gap. The prompt is vague, so the model guesses. This looks like a behavior gap but is cheaper to fix.
- Capability gap. The task needs reasoning or skill the base model does not have. None of the three levers reliably fixes this. Consider a stronger model or splitting the task into steps.
Most real systems show a mix. Count the buckets so you know which one dominates.
| Symptom | Likely gap | First lever |
|---|---|---|
| Confident wrong facts about your product | Knowledge | RAG |
| Answers go stale when documents change | Knowledge (freshness) | RAG |
| Output format varies between calls | Instruction or behavior | Prompting, then few-shot examples |
| Tone differs from house style after careful prompting | Behavior | Fine-tuning |
| Correct but too verbose, and the prompt is already huge | Behavior (cost) | Fine-tuning |
| Fails on multi-step reasoning even with context | Capability | Stronger model, task decomposition |
Step 2: Fix a baseline before changing anything
You cannot tell whether a change helped without a fixed test. Build an evaluation set of 50 to 200 representative inputs. Include the failures you found in step 1 and some easy cases, so you notice regressions. Define a pass criterion for each: an exact label match, a required field in the JSON, or a rubric graded by a person or a second model.
Run the current system, with its plain prompt, and record the score. That number is your baseline. Every later decision is "did this lever move the score enough to justify its cost?"
Split the evaluation set by bucket. A RAG system might raise knowledge-gap cases from 40% to 85% and leave behavior-gap cases untouched. A single overall number would hide that.
Step 3: Climb the ladder
The usual order is prompting, then RAG, then fine-tuning. The order follows cost and reversibility. A prompt change takes minutes and can be undone with one edit. RAG needs an indexing pipeline but leaves the model unchanged. Fine-tuning needs curated training data, a training run, and a new model version to maintain.
Each rung also targets a different gap:
- Prompting fixes instruction gaps and cheap behavior gaps (format, tone, simple rules).
- RAG fixes knowledge gaps (private, fresh, or very large bodies of facts).
- Fine-tuning fixes behavior gaps that a prompt cannot hold reliably, such as a strict style across thousands of calls.
Note the loop in the diagram. After adding any lever you re-run the same evaluation. If RAG fixes the facts but behavior failures remain, you continue to fine-tuning and keep RAG in place.
The rule in code
The decision rule below encodes the ladder. It is deliberately simple. It takes the outcome of your diagnosis and baseline and returns the approaches to use.
def suggest_approach(needs_private_or_fresh_facts,
needs_consistent_style_or_format,
prompt_baseline_passes):
if prompt_baseline_passes:
return ["prompting"]
approaches = ["prompting"]
if needs_private_or_fresh_facts:
approaches.append("rag")
if needs_consistent_style_or_format:
approaches.append("fine-tuning")
return approaches
print(suggest_approach(False, False, True)) # ['prompting']
print(suggest_approach(True, False, False)) # ['prompting', 'rag']
print(suggest_approach(True, True, False)) # ['prompting', 'rag', 'fine-tuning']Two details matter. First, prompting is always in the result. RAG and fine-tuned models are still driven by a prompt, so you never stop writing one. Second, the booleans are not guesses. They come from the bucket counts in step 1 and the per-bucket scores in step 2. If you are filling them in from intuition, you have skipped the measurement.
Constraints that change the order
The ladder is a default. Four constraints can override it.
| Constraint | Effect on the choice |
|---|---|
| Cost per request | Long prompts with many examples or large retrieved context cost tokens on every call. At high volume, a fine-tuned model with a short prompt can be cheaper per request. |
| Latency | Retrieval adds a search step and more input tokens. A fine-tuned model with a short prompt responds faster. Few-shot prompting adds input but no extra service. |
| Freshness | Fine-tuning bakes knowledge in at training time. Facts that change weekly belong in a retrieval index, which you update without retraining. |
| Control and auditability | RAG can show which passages supported an answer. Fine-tuned behavior cannot be traced to a source. Access control is easier with RAG, since you can filter documents per user. A fine-tuned model has seen its training data for every user. |
Volume also shifts the economics. Fine-tuning has a fixed cost (data curation and training) and a lower per-call cost. At 500 calls a day, the fixed cost rarely pays back. At 5 million, it often does. Estimate both before committing.
Some situations skip a rung. If the model must answer from a 2 GB private corpus, prompting alone cannot pass, so start designing retrieval right away. If you must run on a small model with a tight latency budget and a fixed output format, fine-tuning may be the first serious option. Even then, run the prompt baseline first, because it tells you how large the gap is.
A worked example
A company wants an assistant that answers customer questions about its subscription plans and replies in a fixed JSON schema with a friendly tone.
- Diagnose. Of 40 failures, 22 give wrong plan prices or invent features (knowledge). 12 break the JSON schema (instruction or behavior). 6 have an off-brand tone (behavior).
- Baseline. The plain prompt passes 52 of 100 evaluation cases.
- Prompting. The team adds the schema, a clear tone instruction, and three few-shot examples. Schema failures drop to nearly zero. The score rises to 64.
- RAG. They index the pricing pages and plan documentation, retrieve the top three chunks, and instruct the model to say "I don't know" when the context lacks the answer. Price and feature errors fall sharply. The score rises to 91.
- Check the remainder. The nine remaining failures are mostly tone drift on long answers. The tone is acceptable to reviewers, so the team does not fine-tune. It records the decision and the score, and sets a threshold to revisit if tone complaints grow.
The team stopped at prompting plus RAG because the evaluation passed. Fine-tuning would have added cost without a measured benefit.
Common mistakes
- Fine-tuning to teach facts. The model may reproduce some of them, but unreliably, and it cannot update them without retraining. Use retrieval for facts.
- Using RAG to fix style. Retrieved context does not make the model write in your voice. If behavior is the problem, more context will not help.
- Skipping the prompt baseline. Without it, you cannot tell whether the expensive approach was needed.
- Judging by a few examples. A demo that works on five inputs says little. Use the evaluation set.
- Changing several things at once. If you add RAG, rewrite the prompt, and swap the model together, you cannot tell which change moved the score.
- Ignoring retrieval quality. When RAG fails, check first whether the right passage was retrieved. If it was not, the fault lies in chunking or ranking, not the model.
Exercise
A legal team's assistant gives answers in the right tone and format, but it cites outdated contract clauses. The clause library changes monthly. Using the framework, which approach should come first after the prompt baseline, and why would fine-tuning be a poor first choice?
Show answer
Add RAG. The failures are knowledge gaps with a freshness requirement, because the clause library changes monthly. A retrieval index can be updated without retraining, and retrieved passages can be shown as sources. Fine-tuning would freeze the clauses at training time, so the model would be stale again after the next change. It would also address behavior, which is already acceptable here.
Exercise
Your evaluation set has 100 cases. The baseline prompt passes 70. Of the 30 failures, 25 are inconsistent output formatting and 5 are wrong facts. What do you try next, and what do you do about the 5 factual failures?
Show answer
Try prompting improvements first: an explicit schema, structured instructions, and a few few-shot examples. Formatting is an instruction or behavior gap that prompting often fixes cheaply. Re-run the evaluation afterward. Hold off on RAG until you see how many factual failures remain, since 5 cases may not justify a retrieval pipeline. If they persist or grow, add RAG. Consider fine-tuning only if formatting failures remain after good prompting and the volume makes the cost worthwhile.