Few-shot prompting
Few-shot prompting supplies 2–10 input–output examples inside the prompt so the model imitates the pattern on a new input.
Few-shot prompting (a form of in-context learning) gives the model a handful of demonstrations directly inside the prompt. It is the highest-leverage technique for steering tone, format, and edge-case handling without fine-tuning. Effective few-shot prompts use examples that mirror the real input distribution, cover failure modes, and follow a consistent format. The number of shots that helps plateaus quickly — for most tasks 3–5 well-chosen examples beat 20 mediocre ones. Newer long-context models also support "many-shot" prompts (hundreds of examples) which approach fine-tuning quality for narrow tasks.
When to use few-shot prompting
- Strict output format (JSON, CSV, custom DSL).
- Domain-specific tone (legal, medical, brand voice).
- Edge cases that zero-shot keeps getting wrong.
Common mistakes
- Using examples that don't match the real input distribution.
- Inconsistent formatting across examples — the model copies the inconsistency.
- Padding with redundant easy examples instead of edge cases.
FAQ
What is few-shot prompting?
Few-shot prompting supplies 2–10 input–output examples inside the prompt so the model imitates the pattern on a new input.
When should I use few-shot prompting?
Strict output format (JSON, CSV, custom DSL). Domain-specific tone (legal, medical, brand voice). Edge cases that zero-shot keeps getting wrong.
What are the most common mistakes with few-shot prompting?
Using examples that don't match the real input distribution. Inconsistent formatting across examples — the model copies the inconsistency. Padding with redundant easy examples instead of edge cases.
Related terms
- Chain-of-thought prompting — Chain-of-thought (CoT) prompting tells a language model to write its reasoning steps before its final answer, increasing accuracy on multi-step problems.
- Zero-shot prompting — Zero-shot prompting asks the model to perform a task with no examples — only the instruction and the input.
- System prompt — A system prompt is the high-priority instruction block that defines a model's role, constraints, and default behaviors for an entire conversation.
- In-context learning — In-context learning is when a language model adapts its behaviour from examples shown in the prompt — no weights change, no fine-tuning.
Last updated: 2026-06-01. Raw markdown: https://promtable.com/glossary/few-shot-prompting.md.