# Few-Shot Prompting

> The Few-Shot Prompting is a technique of including several examples in the prompt to show the model the expected result.

## What is few-shot prompting and how many examples do I need?

The technique of adding a few input and output examples to the prompt so the model follows the same pattern, style or format. Especially useful for classification and strict formatting tasks.

- Topic: Prompting
- Type: technique

## Example

Wrong:

```text
Review: Great product! -> positive
Review: Love it! -> positive
Review: Works well. -> positive
Review: {{review}} ->
```

Right:

```text
<example>Great product! -> positive</example>
<example>Broke after a day. -> negative</example>
<example>It arrived on Tuesday. -> neutral</example>
<input>{{review}}</input>
```

Varied labels avoid a bias toward one answer, and tags separate the examples from the real input.

## Common mistakes

- The model copies details from the examples into every answer.
- All examples share one label, so the model is biased toward it.

## Key points

- Examples use the exact output format the code expects to parse.
- Examples cover different cases, including edge cases, not several copies of one pattern.
- Examples are clearly separated from the real input, for example with tags.
- Examples contain no real user data or secrets.

## Interview questions

### Does the order of few-shot examples matter?

It can. Models may lean toward the label of the last examples, so mix labels and test different orders.

### One-shot vs few-shot prompting?

One-shot gives a single example; few-shot gives several. Several varied examples usually show the pattern more reliably.

### Can few-shot examples hurt results?

Yes. If they are too similar, the model copies their details or wording. Use varied examples that match the real inputs.

## Related cards

- [Zero-Shot Prompting](https://wonderium.dev/ai/zero-shot-prompting.md)
- [Prompt Template](https://wonderium.dev/ai/prompt-template.md)
- [Prompt Engineering](https://wonderium.dev/ai/prompt-engineering.md)
- [Structured Output](https://wonderium.dev/ai/structured-output.md)

---

- Level: [Artificial Intelligence](https://wonderium.dev/ai.md)
- HTML version: https://wonderium.dev/ai/few-shot-prompting
- Last updated: 2026-11-25
