Few-Shot Prompting

Estimated time: 3 minutes

Few-shot examples are the most effective technique when detailed instructions alone still produce inconsistent, unusably-varied results. Four named applications:

  • Ambiguous-case handling — 2 to 4 targeted examples showing the reasoning for why one action was chosen over other plausible alternatives. The reasoning is the actual payload here, not just the final answer shown.
  • Format consistency — demonstrating the exact output shape (location, issue, severity, suggested fix) directly, rather than describing it.
  • False-positive reduction with generalization — examples distinguishing an acceptable pattern from a genuine issue. The critical property: examples let the model generalize to novel variants of the pattern it hasn't seen before, in a way a hardcoded exception list cannot.
  • Varied document structures — showing extraction across differently-structured source documents (inline citations vs. bibliographies, methodology sections vs. embedded details) fixes empty or null extraction on document shapes the model hasn't been shown yet.

The discriminator: examples generalize; enumerated lists only match what was explicitly listed. Whenever a scenario mentions novel, previously-unseen, or continually-evolving patterns, few-shot examples are the fit — a regex filter or a hardcoded exception list only ever catches the specific instances someone thought to enumerate, and new variants slip through by design.

A trap worth naming: reaching for few-shot examples to fix a problem whose actual root cause is a thin tool description (Domain 2, §2.1) adds token overhead without addressing the cause — examples fix inconsistent generation, not poor tool selection.

The four applications at a glance:

Use Case Why Few-Shot Works
Ambiguous cases The reasoning shown generalizes to new ambiguous cases, not just the final answer
Format consistency Examples anchor the exact output shape directly, instead of describing it
False-positive reduction Examples generalize to novel variants; an exception list only matches what's listed
Varied document structures Examples teach pattern recognition across structures the model hasn't seen shown yet