Zero-Shot, Few-Shot & Chain-of-Thought Selection
CoreApply prompt engineering techniques matched to the task · Difficulty 2/5
Explanation
Matching Technique to Task
| Technique | What it is | Best for |
|---|---|---|
| Zero-shot | Instruction only, no examples | Simple, unambiguous tasks |
| Few-shot | A handful of input/output examples | Locking in a specific format or edge-case behavior |
| Chain-of-thought | Prompt the model to reason step by step (or use extended thinking) | Multi-step reasoning, math, complex judgment |
The technique choice is a design decision tied to the task's difficulty and ambiguity -- not a default setting applied uniformly.
- Zero-shot is the right default for simple, well-specified tasks; adding examples or reasoning scaffolding to a trivial task adds cost without benefit.
- Few-shot earns its token cost when prose instructions alone cannot pin down a specific, hard-to-describe format or edge-case behavior -- the examples show, rather than tell.
- Chain-of-thought (explicit step-by-step prompting, or the model's Extended Thinking capability) earns its added latency when the task genuinely requires multi-step reasoning, math, or complex judgment.
Common exam traps
- Adding few-shot examples or chain-of-thought reflexively, as if they were always an improvement. Examples cost tokens and can over-anchor the model to the example pattern; chain-of-thought/Extended Thinking adds latency. Use each technique only when the task's difficulty actually warrants it.
Key Takeaways
- Zero-shot suits simple, unambiguous tasks; few-shot locks in format/edge-case behavior; chain-of-thought suits multi-step reasoning
- Few-shot examples show the desired behavior rather than describing it in prose
- Chain-of-thought and extended thinking are the same lever: reasoning depth traded for tokens/latency
- Reflexively adding examples or CoT to a simple task adds cost without benefit
Glossary Terms
A Claude capability that allows the model to reason through complex problems step-by-step in a dedicated thinking block before producing its final response. Controlled via the 'thinking' parameter with a 'budget_tokens' limit. Thinking tokens are billed but improve accuracy on hard reasoning tasks.
A prompting technique that supplies concrete (input, output) example pairs to guide Claude’s behavior. With the Claude API the idiomatic approach is to encode examples as alternating `user`/`assistant` turns in the `messages` array rather than cramming them into the system prompt — this mirrors the conversation format Claude is trained on and keeps cached system-prompt content stable.
A prompting strategy that instructs Claude to reason step-by-step before providing a final answer. Improves accuracy on complex reasoning tasks by making intermediate steps explicit. Can be triggered by instructions like 'think step by step' or via extended thinking.
Related Concepts