# Few-shot prompting

> Few-shot prompting is a technique in which a prompt includes a small number of worked examples of the task, showing inputs and the desired outputs, so the model can follow the pattern without any retraining.

Also called: few-shot learning, in-context learning, example prompting, one-shot prompting, zero-shot prompting. Category: Models and training. Source: https://aibuildindex.com/glossary/few-shot-prompting

## In the index

- Prompt engineering: median $3,600, middle half $600 to $11,200, 1,367 priced briefs (https://aibuildindex.com/skills/prompt-engineering)

Describing exactly what you want in words is hard. Showing a few examples is often easier and more effective. Few-shot prompting puts a handful of example inputs and ideal outputs into the prompt, and the model infers the pattern for the new input. A prompt with no examples is called zero-shot; one example is one-shot. It is one of the simplest and most reliable tools in [prompt engineering](https://aibuildindex.com/glossary/prompt-engineering), and often the step that makes an AI feature consistent enough to use.

## How it works

The prompt includes a short set of examples before the real input. For a ticket classification build, that might look like:

- An email about a double charge, labelled "billing".
- An email about a broken login link, labelled "technical".
- An email praising a support agent, labelled "feedback".

Then the new email follows, and the model returns a label in the same style.

Choosing examples is the skill:

- **Cover the range.** Include typical cases and the tricky ones, such as ambiguous messages or edge cases where categories overlap.
- **Keep them consistent.** Examples that disagree with each other or with the instructions confuse the model.
- **Show the exact format.** If software reads the output, the examples should show precisely the [structured output](https://aibuildindex.com/glossary/structured-output) expected.
- **Avoid bias.** If most examples carry one label, the model may favour it.

Some builds select examples dynamically, retrieving the most similar past cases for each new input instead of using a fixed set. Examples can also demonstrate reasoning, which combines few-shot prompting with [chain-of-thought](https://aibuildindex.com/glossary/chain-of-thought).

## What it means for cost

Few-shot prompting is cheap to build: it needs a set of good examples, usually drawn from the business's own records, and some testing. It adds running cost, because the examples are sent with every request and count as input tokens. With many long examples and high volume, that adds up.

At that point, [fine-tuning](https://aibuildindex.com/glossary/fine-tuning) on a larger set of examples can become cheaper per request, because the behaviour moves into the model and the prompt shrinks. Ask a builder how examples were chosen, who in the business checked them, and at what volume fine-tuning would start to pay off.

## Common questions

### How many examples does few-shot prompting need?

Often a handful is enough, and more is not always better. The right number depends on how varied the task is, and it is best found by testing different sets on real cases.

### What is the difference between few-shot prompting and fine-tuning?

Few-shot prompting shows examples in each request and leaves the model unchanged. Fine-tuning trains the model on many examples so it behaves that way by default. Few-shot is quicker to start and change; fine-tuning can be cheaper and more consistent at scale.

### Can examples include real customer data?

They can, but personal details should be removed or replaced, since the examples are sent to the model provider with every request.

## Related terms

- [Prompt engineering](https://aibuildindex.com/glossary/prompt-engineering): Prompt engineering is the practice of designing, testing and refining the instructions, context and examples given to an AI model so that it produces accurate, consistent and correctly formatted output for a specific task.
- [Prompt](https://aibuildindex.com/glossary/prompt): A prompt is the input given to an AI model to tell it what to do, typically instructions, context, examples and the user's request, from which the model generates its response.
- [Chain-of-thought](https://aibuildindex.com/glossary/chain-of-thought): Chain-of-thought is a technique in which a language model works through a problem in explicit intermediate steps before giving its final answer, which tends to improve accuracy on tasks that need several stages of reasoning.
- [Fine-tuning](https://aibuildindex.com/glossary/fine-tuning): Fine-tuning is the process of further training an existing AI model on a smaller set of task-specific examples so that it reliably adopts a particular behaviour, format, tone or specialised skill.
- [Structured output](https://aibuildindex.com/glossary/structured-output): Structured output is a way of making an AI model return its answer in a fixed, machine-readable format, typically JSON matching a defined schema, so that other software can use the result without guessing at free text.
