AI CompendiumA public chart of the language
Prompting & Structure

Few-shot

also called In-context examples

Show a handful of examples and let the model pattern-match.

Definition

Including several input/output examples in the prompt so the model infers the intended mapping — especially useful for output formats, edge cases and label conventions.

Examples are the most reliable way to pin down a format. Include the awkward cases deliberately: the empty input, the one with two categories, the one that should be refused.

Examples are the most reliable way to pin down a format, because the model copies structure it can see far more faithfully than structure it is told about. The strategic point is what you choose to show: the borderline cases teach the boundaries, and the common cases mostly waste tokens.

How people use it
Fixing inconsistent categorisation.
"Three examples that disagree with the naive reading are worth more than a paragraph of rules."
Worked example

Examples as an edge-case specification

Extraction returns a value for fields that are genuinely absent.

Two examples fix it: one where a field is present, one where the correct answer is null and why. Showing the hard case is worth more than ten examples of the easy path, because the hard case is where the instruction was ambiguous.

Sources
  • paperLanguage models are few-shot learners ↗OpenAI (arXiv) · 2020

    Introduces GPT-3 at 175B parameters and shows that scale alone produced in-context learning: performance from examples in the prompt, with no gradient updates.

  • docsPrompting best practices ↗Claude platform docs · 2026

    The current house guidance on explicit instructions, output constraints, examples, XML structure and role prompting.

Related terms