Sistava

What is Few-shot Prompting?

Also called in-context learning, few-shot learning.

Few-shot prompting supplies several worked examples of a task inside the prompt so the model can infer the pattern before handling the real input. No parameters change and nothing persists after the request finishes. The technique is also called in-context learning, because the model appears to learn the task from the surrounding context alone.

Examples communicate what instructions describe poorly: exact formatting, edge case handling, level of detail, and tone of voice. Three consistent examples often outperform a paragraph of careful description, because the model matches a demonstrated pattern rather than interpreting prose about one. Consistency across the examples matters considerably more than how many of them you provide.

Selection has measurable effects on results. Examples should cover the real variety of inputs, including the awkward and borderline cases, and should not accidentally encode a bias such as always answering yes or always producing a long answer. Ordering influences outcomes too, and models tend to weight the final example most heavily, so it should be representative.

The learning is temporary and confined to the single request. Nothing is stored anywhere, so the same examples must be re-sent every time, consuming context window space and metered tokens on every call. When the example set grows large, or stops fitting comfortably alongside real input, fine-tuning on the same material is usually the better long-run choice.

Few-shot prompting sits between zero-shot prompting, which supplies instructions only, and fine-tuning, which changes weights permanently. Newer instruction-tuned models handle many tasks zero-shot that once required examples, so the technique is now most valuable for unusual output formats, domain-specific conventions, and anything that must match a rigid template exactly.

Key points

In practice

You want product reviews sorted into 'shipping', 'quality', or 'price'. Instructions alone produce invented categories such as 'customer service'. Add three examples, each a short review followed by exactly one of the three allowed labels, including one borderline case. The model then returns only permitted labels, and the borderline example teaches it how you want ambiguity resolved.

Related terms

Back to the AI Glossary