ModelRefs / Few-Shot Prompting — AI Glossary
Few-Shot Prompting — AI Glossary
Providing a small number of example input-output pairs in the prompt to demonstrate the desired behavior to the model.
Overview
Few-shot prompting works because LLMs perform in-context learning. 3–8 examples is typical; more rarely helps and consumes context. Example selection matters — diverse, representative examples outperform random sampling.
Reference details
| Topic | prompting |
|---|---|
| Last reviewed | 2026-06-24 |
Related terms
How it works
- The examples are concatenated into the prompt as ordinary text in a repeated format, so from the model's side they are context rather than a distinct mechanism.
- During the forward pass attention over those examples induces the input-to-output mapping they demonstrate, which is why the behaviour appears without any weight change.
- The format carries a large share of the signal: consistent delimiters and a consistent field order tell the model where its own output begins, independently of what the examples contain.
- The distribution of labels across the examples biases the output distribution, so an unbalanced set shifts predictions toward whichever label appears most.
- Position matters as well, with examples nearest the query typically weighted most heavily, which is why ordering is a parameter rather than an arbitrary choice.
- Selection can be fixed or retrieved per query from a larger pool by similarity to the input, and the retrieved form generally outperforms a static set because the demonstrated edge cases are closer to the case at hand.
Example: Examples teach the edge cases, not the task
For sentiment labelling, the useful examples are not three clear positives. They are the ones that pin down your conventions: sarcasm, mixed sentiment, and a review that is about delivery rather than the product. Examples are where you encode the decisions a definition cannot express.
Commonly confused with
In-context learning does not update the model. The examples influence one response and are gone; nothing is retained between calls. That is the difference from fine-tuning, and the reason few-shot costs tokens on every single request.
When to use it
Reach for it when:
- The desired output form is easier to show than to describe
- There are conventions and edge cases a definition would not capture
- You need behaviour changeable without retraining
Reach for something else when:
- Examples would consume context you need for actual content
- The pattern is stable and high-volume — fine-tuning amortises better
- Your examples are unrepresentative; the model will copy the skew faithfully
Referenced by
This term is used by the following ModelRefs references:
Continue your research
Use these connected ModelRefs sections to compare alternatives, inspect implementation paths, and review the evidence and governance boundaries relevant to Few-Shot Prompting — AI Glossary.
Frequently asked questions
What is Few-Shot Prompting?
Providing a small number of example input-output pairs in the prompt to demonstrate the desired behavior to the model.
What concepts are related to Few-Shot Prompting?
Closely related concepts include zero shot, prompt engineering, chain of thought.