← Back to glossary
+Suggest a term
Concept·Patterns & Practices·Added 1 month ago

Few-shot prompting

Also known as: few-shot learning, in-context learning, ICL, n-shot prompting

Giving the model a handful of worked examples inside the prompt so it can pattern-match to your expected format or style. The model doesn't retrain; it just picks up the pattern from the examples you've included.

Few-shot prompting puts two or more examples directly in the prompt before your actual request. The model reads them, infers the pattern you want, and applies it to the new input. It's the difference between describing what you need and just showing it. One example is 'one-shot'; no examples at all is 'zero-shot'.

It's especially useful when the output format matters a lot, such as structured JSON, a specific tone, or a classification schema where the categories aren't self-evident. Showing the model what good looks like is often faster than trying to describe it in words.

There's a nuance worth knowing: research on newer, stronger models suggests that for complex reasoning tasks, few-shot examples may do more to enforce output format than to actually improve the reasoning itself. Zero-shot prompting with a clear instruction sometimes matches or beats it. Still, for format-sensitive tasks and custom workflows, few-shot remains one of the most reliable tools a builder has.

This definition is AI-generated and refreshed weekly. It may contain inaccuracies. Use your own judgment, especially for production decisions.
Related terms
Prompt engineeringZero-shot promptingChain-of-thoughtSystem prompt