# Few-Shot and Zero-Shot Prompting

Few-shot prompting supplies task demonstrations in a model's input, while zero-shot prompting asks for the task without demonstrations.

- Type: method
- Domain: Engineering & architecture
- Level: Intermediate
- Last reviewed: 2026-10-05
- Original: [Soroush’s Product Wiki](<https://wiki.soroush.uk/topic/few-shot-and-zero-shot-prompting/>)

## What it means

These prompting modes differ in whether the request includes examples of the desired task behavior. Zero-shot prompts can still contain detailed instructions and reference material. Few-shot prompts include a small set of demonstrations, often input–output pairs; one-shot uses one. This is in-context adaptation: the examples influence the current response without updating model weights, unlike fine-tuning.

## Why it matters

Examples can communicate subtle label boundaries, formatting, and tone more clearly than additional rules. They also consume context and can teach accidental patterns. Teams need to know whether demonstrations improve representative tasks enough to justify their maintenance and runtime cost.

## When to use it

Use demonstrations when a clear instruction baseline repeatedly misses a convention that examples can illustrate. Start without examples for straightforward tasks. Missing knowledge requires appropriate evidence, and mandatory output structure may require schema enforcement even when examples are provided.

## How it works

1. Define the task, acceptable outputs, and a separate evaluation set covering important user groups.
2. Establish a zero-shot baseline using clear instructions and the same model configuration used for comparisons.
3. Select a few correct demonstrations spanning common cases and meaningful boundaries, with consistent labels and formatting.
4. Compare results on unseen cases and vary example selection or order to reveal sensitivity.
5. Version the demonstration set and retain it only when quality gains justify added context, latency, and upkeep.

## A practical example

A feedback tool must distinguish a bug report from a feature request. Instructions alone misclassify requests that mention a workaround. The team adds contrasting examples and evaluates on unseen feedback, including ambiguous cases routed for review. It retains the examples only if the improvement extends beyond wording similar to the demonstrations.

## Where it breaks

Results depend on the model, task, example choice, and ordering. Demonstrations can encode bias or reveal sensitive data. Success with a few examples does not show that the model learned a durable capability or will generalize to a changed task.

## Common mistakes

- Putting evaluation answers into demonstrations and reporting the resulting score as generalization.
- Calling reference documents few-shot examples when they do not demonstrate the task.
- Adding many repetitive examples without testing their marginal value.
- Treating example-based formatting as a guaranteed output contract.

## Visualization

[View the visualization on the website](<https://wiki.soroush.uk/topic/few-shot-and-zero-shot-prompting/#visualization-few-shot-and-zero-shot-prompting>)

## Sources

1. [Include few-shot examples](<https://cloud.google.com/vertex-ai/generative-ai/docs/learn/prompts/few-shot-examples>) — Google Cloud · Official documentation
2. [Language Models are Few-Shot Learners](<https://arxiv.org/abs/2005.14165>) — NeurIPS · Peer-reviewed research

## Related topics

- [Prompt Engineering](<https://wiki.soroush.uk/topic/prompt-engineering/>)
- [Fine-Tuning](<https://wiki.soroush.uk/topic/fine-tuning/>)
- [Model Evaluation](<https://wiki.soroush.uk/topic/model-evaluation/>)
