# Few-shot prompting

> Including one to five worked examples in the prompt so the model copies their format, tone and level of detail.

Source: Promptea — https://www.promptea.me/en/glossary/few-shot · Language: English · Last updated: 2026-11-09

## What it means

- Definition: you show the model what a good input-and-output pair looks like before giving it the real input. The model infers the pattern from the examples instead of from a description.
- Why it matters: examples fix output structure and style far more reliably than adjectives do, which makes few-shot the usual fix for inconsistent formatting.
- How to apply it: start with one or two small, representative examples, label them clearly (Input / Output) and end the prompt with the real input. Add an example only when the model keeps getting one case wrong.
- Common mistakes: examples that are all alike (the model overfits to them), examples that contradict your written rules, and long examples that burn tokens. Some search-based models latch onto the topic of an example, so describe the structure there instead.

## Example

```text
Convert each input to JSON with the keys name (string) and age (number).

Example 1
Input: "Name: Ana, Age: 31"
Output: {"name":"Ana","age":31}

Example 2
Input: "Luis, 27 years old"
Output: {"name":"Luis","age":27}

Now do this one.
Input:
"""[paste]"""
Output ONLY the JSON.
```

[Open in Promptea](https://www.promptea.me/en/analyzer?prompt=Convert+each+input+to+JSON+with+the+keys+name+%28string%29+and+age+%28number%29.%0A%0AExample+1%0AInput%3A+%22Name%3A+Ana%2C+Age%3A+31%22%0AOutput%3A+%7B%22name%22%3A%22Ana%22%2C%22age%22%3A31%7D%0A%0AExample+2%0AInput%3A+%22Luis%2C+27+years+old%22%0AOutput%3A+%7B%22name%22%3A%22Luis%22%2C%22age%22%3A27%7D%0A%0ANow+do+this+one.%0AInput%3A%0A%22%22%22%5Bpaste%5D%22%22%22%0AOutput+ONLY+the+JSON.&purpose=data&target=gemini)

## Frequently asked questions

### How many examples should I use?

Start with one or two. Add more only if the model is still inconsistent, and make the new ones cover a different case, not a repeat of the first.

### What is the difference between few-shot and zero-shot?

Zero-shot gives only the instruction; few-shot adds worked examples. Use zero-shot for simple, well-defined tasks and few-shot when format or edge cases matter.

## Related

- [Few-shot prompting: how to show examples instead of just explaining](https://www.promptea.me/en/guides/few-shot-prompting)
- [Zero-shot prompting: how to get reliable results without providing examples](https://www.promptea.me/en/guides/zero-shot-prompting)
- [How to force valid JSON output (no markdown)](https://www.promptea.me/en/guides/json-output)
- [Zero-shot prompting](https://www.promptea.me/en/glossary/zero-shot)
- [Structured output](https://www.promptea.me/en/glossary/structured-output)
