Skip to main content

Few-shot prompting

Prompting

Including a small number of input–output examples in the prompt so the model infers format, tone, or task structure without explicit rules for every edge case.

Few-shot (or n-shot) prompting is high leverage when the desired behavior is easier to show than to specify. Examples must be minimal but representative—long example blocks burn context window budget.

Pitfalls

Stale examples teach the wrong API version; contradictory examples confuse; too many shots add noise. Treat examples like test fixtures: curated and versioned.

See also

Metacognition: after practice, check whether you can reproduce the pattern without the examples in front of you.