---
title: Few-Shot Prompting — Prompt Engineering Technique
description: Few-shot prompting includes a handful of solved input–output examples in the prompt so the model infers the pattern and applies it to a new input. It steers format and behavior without any fine-tuning.
canonical: https://prompeteer.ai/techniques/few-shot-prompting
category: Foundational patterns
---

# Few-Shot Prompting

Few-shot prompting includes a handful of solved input–output examples in the prompt so the model infers the pattern and applies it to a new input. It steers format and behavior without any fine-tuning.

## What it is

Few-shot prompting (also called in-context learning) demonstrates the task by embedding a small number of examples — typically one to a few — directly in the prompt. The model generalizes from the demonstrated mapping to the new input, learning "on the fly" from context rather than from updated weights.

This was a headline finding of the GPT-3 paper: sufficiently large models can perform many tasks from examples alone. Few-shot is especially effective for enforcing a specific output format, an unusual label set, or a house style that is hard to describe but easy to show.

## When to use

- The output format is specific and easier to show than to describe.
- Zero-shot output is close but inconsistent in structure or style.
- The task uses a custom label set or domain conventions the model may not assume.
- You need behavior steering without the cost of fine-tuning.

## How it works

1. Choose a few representative, correct input–output pairs that cover the range of cases.
2. Format every example identically so the pattern is unmistakable.
3. Order and delimit examples consistently, then append the new input in the same shape.
4. Let the model complete the pattern; add or swap examples if edge cases fail.

## Illustrative structure

The structure is a repeated block: "Input: <example input> / Output: <example output>" two or three times, followed by "Input: <new input> / Output:" left for the model to complete. Every block uses identical formatting so the mapping is explicit.

## Pitfalls

- Examples consume tokens and add latency; too many can crowd out the actual input.
- Biased or unrepresentative examples skew predictions (e.g. a majority-label bias).
- Inconsistent formatting across examples confuses the pattern the model should copy.
- Example order can affect results; test rather than assume.

## Sources

- [Brown et al. (2020), Language Models are Few-Shot Learners](https://arxiv.org/abs/2005.14165)
- [Anthropic — Multishot prompting with examples](https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/multishot-prompting)

## Related techniques

- [zero-shot-prompting](https://prompeteer.ai/techniques/zero-shot-prompting)
- [few-shot-example-selection](https://prompeteer.ai/techniques/few-shot-example-selection)
- [chain-of-thought](https://prompeteer.ai/techniques/chain-of-thought)
