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

Few-shot

Also known as: few shot, few-shot prompting, few-shot learning, prompt with examples

Including a small number of examples in your prompt to show the model exactly what kind of output you want. Usually 2-10 examples. One of the most reliable techniques for getting consistent, well-formatted responses on structured tasks.

Few-shot prompting works by giving the model a pattern to follow: here are three examples of the thing I want, now do it for this new input. The model infers the task structure from the examples rather than from an abstract description alone. It's particularly useful when you need a specific output format (JSON, markdown tables, a particular writing style), when the task is uncommon enough that zero-shot is unreliable, or when you're building a repeatable pipeline.

The examples you choose matter significantly. Good few-shot examples are representative of the range of inputs you expect, include cases the model might otherwise get wrong, and show the exact output format you want. Poorly chosen examples can mislead the model just as much as a bad instruction.

As models have improved, the necessity of few-shot prompting has decreased for common tasks: frontier models are often good enough zero-shot. But few-shot remains highly effective for specialized domains, unusual output formats, and cases where you want very tight output control. In production pipelines, it's often baked into the system prompt as a set of examples the model always sees.

This definition is AI-generated and refreshed weekly. It may contain inaccuracies. Use your own judgment, especially for production decisions.
Related terms
Zero-shotOne-shotICLFew-shot promptingPrompt engineering