Sub topic 14
When to Choose Instructions, Fine-Tuning, or Other Methods
This chapter assumes you can read short Python, know how chat roles (system, user, assistant) work, and have already built and tested a few-shot prompt. Few-shot prompting is one tool among several. Here you will learn how to tell when another approach fits better.
Decide by what is failing
Start from the failure you see, not from a favorite technique. Run your held-out accuracy check first, then look at the errors.
| Symptom | Likely cause | Try first |
|---|---|---|
| Output is correct but in the wrong format | Format is not specified | Clearer instructions, or one or two examples |
| Model misreads what the task is | Task is ambiguous | Rewrite the instruction, add a definition |
| Labels follow a house style the model cannot guess | Style is implicit | Few-shot examples |
| Multi-step answers are often wrong | Model skips reasoning | Examples with reasoning steps |
| Prompt is too long or too costly | Many examples on every call | Fewer examples, dynamic selection, or fine-tuning |
| Answers need facts the model lacks | Missing knowledge | Retrieval, not examples |
When instructions alone are enough
If the task is common and you can describe it in a few sentences, a zero-shot prompt is cheaper and easier to maintain. A model already knows what "summarize in two sentences" means. Examples add tokens and can cause copying, so add them only when measurement shows a gain.
A quick test is to compare the two on your held-out data.
def accuracy(predict, labeled):
correct = 0
for text, label in labeled:
if predict(text).strip().lower() == label:
correct += 1
return correct / len(labeled)
def compare(zero_shot_predict, few_shot_predict, labeled):
zero = accuracy(zero_shot_predict, labeled)
few = accuracy(few_shot_predict, labeled)
print(f"zero-shot: {zero:.2%} few-shot: {few:.2%}")
return few - zeroIf the gap is small, keep the simpler prompt.
When few-shot is the right tool
Few-shot prompting fits when the pattern is easier to show than to explain. Examples are good for output format, tone, label conventions, and borderline cases. They also let you change behavior in minutes, with no training run and no new model version.
When to consider other methods
Each alternative solves a different problem.
- Fine-tuning trains the model on many labeled examples, often hundreds or thousands. Consider it when the prompt needs many examples on every call, when you run a very high volume of requests, or when you need consistent style at low latency. The costs are data preparation, training time, and re-training when requirements change.
- Retrieval fetches relevant documents and places them in the prompt. Use it when the model lacks facts. Examples teach a pattern. They do not reliably supply knowledge.
- Reasoning prompts ask the model to work through steps. Use them for arithmetic, logic, and multi-step decisions, where the format of the answer is not the main problem.
- Structured output or validation code enforces a schema. If you need valid JSON every time, check it in code and retry. Do not rely on examples alone.
- A rules-based or classic model may be best when labels follow fixed rules or you have large labeled data and need predictable cost.
Common mistakes in this decision
- Jumping to fine-tuning before testing a better prompt. A prompt change takes minutes. A training run takes much longer.
- Adding examples to fix a knowledge gap.
- Judging by a handful of hand-picked inputs instead of held-out data.
- Ignoring cost. Examples are billed as input tokens on every request.
Exercise
Your few-shot classifier scores well on format, but it often gets product-specific questions wrong because it does not know the company's return policy. Which approach should you add, and why not more examples?
Show answer
Add retrieval, so the relevant policy text is placed in the prompt for each query. The errors come from missing facts, and examples teach a pattern or format. They do not reliably supply knowledge.
Exercise
A few-shot prompt with 12 examples reaches 94% held-out accuracy but costs too much at millions of calls per day. Name two options and one trade-off for each.
Show answer
Dynamic selection with fewer examples per call lowers tokens, but you must re-test accuracy because retrieval of examples can add errors. Fine-tuning removes the examples from the prompt, but it needs labeled data, training time, and re-training when requirements change.