AI glossary

Few-shot

In one sentence Few-shot prompting means including a handful of worked examples in the prompt, so the model copies the pattern instead of guessing your intent.

By Updated

Few-shot prompting is showing the model a few worked examples of the task inside the prompt, so it imitates the demonstrated pattern.

Explaining a rangoli pattern in words is clumsy; drawing the first three corners and saying "continue like this" works instantly. Demonstration beats description for anything with a format — and few-shot prompting is demonstration.

Review: "Delivery was late but the biryani was worth it"  →  mixed
Review: "Third time ordering. Never disappoints"          →  positive
Review: "Cold food, rude delivery"                        →  negative
Review: "Packaging could improve, taste was fine"         →

The model completes: mixed. Note what the examples taught without a single instruction: the task (sentiment), the label set (including that "mixed" exists), and the output format (one lowercase word, no explanation). Ambiguities that would each need a sentence of rules are settled by demonstration.

The contrast is zero-shot — instruction only, no examples — which modern instruction-tuned models handle well for common tasks. Reach for few-shot when the output format is strict, the labels are unusual, or zero-shot keeps misreading edge cases; then put your trickiest real cases in the examples, since the model follows them with surprising literalness (three positive examples in a row can bias it toward "positive"). Each example spends context-window on every call. When examples multiply past a dozen, that recurring cost is a hint to consider fine-tuning, which bakes the pattern in once. The ability itself — learning a task from prompt examples with no weight updates — is called in-context learning, and its emergence in GPT-3 was one of the genuine surprises of the LLM era.

Where to go next