What is few-shot prompting? Few-shot vs zero-shot
Also called few-shot learning, in-context learning, k-shot prompting, multishot prompting
Definition
Few-shot prompting is a technique that puts a few example inputs paired with desired outputs in a prompt, so a language model infers the task, format, and labels without changing its weights.
Few-shot prompting is the practice of placing a few worked examples, each an input paired with the desired output, in a prompt before the real input. The model infers the task, the output format, and the label set from the examples and continues the pattern, with no training or weight updates. It is one of the cheapest ways to make a large language model produce consistent output, and the examples often live in the system prompt.
How few-shot prompting works#
Few-shot prompting works through in-context learning: the model conditions on the demonstrations in its input and applies the same pattern to the new case. The GPT-3 paper (Brown et al., 2020) named the settings by example count: zero-shot gives only an instruction, one-shot adds one demonstration, and few-shot adds several.
For GPT-3, few-shot meant roughly 10 to 100 examples, as many as fit in its 2,048-token context window. The paper found that scale improves this ability. Its 175-billion-parameter model performed many tasks from demonstrations alone, sometimes matching earlier fine-tuned systems.
On classification and multiple-choice tasks, the examples teach format more than correctness. Min et al. (2022) replaced the labels in demonstrations with random ones and found that performance barely dropped, across 12 models including GPT-3. What mattered was that the examples showed the label space, the distribution of input text, and the overall format. Choose examples that resemble real inputs and cover the full range of expected outputs.
Few-shot vs zero-shot prompting#
Zero-shot prompting gives the model only an instruction; few-shot prompting adds worked examples. Examples are the more reliable way to fix an output format, a tone, or a custom label set. They also cost input tokens on every request and can over-steer, since a model may copy surface features of the examples, such as their length or phrasing.
| Zero-shot | Few-shot | Fine-tuning | |
|---|---|---|---|
| What you provide | An instruction | An instruction plus examples | A training dataset |
| Weights change | No | No | Yes |
| Prompt length | Shortest | Grows with each example | Can shrink |
| Good fit | Clear, common tasks | Strict formats, custom labels | Behavior too complex to show in a prompt |
Anthropic's prompting best practices recommend 3 to 5 examples that are relevant and diverse, wrapped in <example> tags so the model can tell them apart from instructions. A fixed block of examples sits at the same position in every request, which makes it a good candidate for prompt caching.
Reasoning models change the default. OpenAI's reasoning best practices advise trying zero-shot first and adding examples only if needed, matched closely to the instructions. Anthropic notes that worked examples still shape how its models approach similar problems in their thinking.
The LLM benchmarks guide lists prompt format, including few-shot examples, among the main reasons published scores disagree.
Related terms
Guides that cover few-shot prompting
- AI engineer roadmap: skills, projects, and resources by stage
- What is context engineering? A practical guide for AI agents
- LLM benchmarks explained: what they measure and how to read them
- LLM inference optimization: a practical guide for engineers
- Reasoning models: how they work and when to use them
- What is the Model Context Protocol (MCP)? How it works
- RAG vs fine-tuning: how to choose for your LLM application
- What are AI agents? How agents work and when to use one
Cite this definition
The AI Engineering Editors. "What is few-shot prompting? Few-shot vs zero-shot." The AI Engineering, updated Nov 06, 2026. https://theaiengineering.com/glossary/few-shot-prompting
- Title
- What is few-shot prompting? Few-shot vs zero-shot
- Author
- The AI Engineering Editors
- Publisher
- The AI Engineering
- Updated