F7.2 F7

Few-Shot: Show, Don't Just Tell

When text instructions produce inconsistent output, examples fix what more instructions can’t. That’s the core of few-shot prompting — demonstrating the expected behavior through concrete input/output pairs.

The distinction

Zero-shot — instructions only, no examples. “Extract the invoice number, total, and date as JSON.” The model figures out the format from the description alone.

Few-shot — instructions plus 2-4 concrete examples. “Here’s how the extraction should look: [input document] → [expected JSON output].” The model sees the pattern and follows it.

“Shots” are the examples. Zero-shot = zero examples. Few-shot = a few examples. They’re not API calls, not system prompt paragraphs, not training iterations. They’re demonstration pairs in the prompt.

When to use each

Zero-shot works for simple, unambiguous tasks where the expected output is obvious: sentiment classification, basic summarization, straightforward Q&A. If the model consistently gets the format right without examples, don’t add them.

Few-shot is needed when:

  • Output format must be highly consistent (the model keeps switching between JSON and markdown)
  • The task has ambiguous edge cases (what counts as “high priority”?)
  • Text instructions alone produce variable results (you’ve tried adding detail, but it still varies)
  • You need to demonstrate a specific judgment pattern (return null when data is absent)

The format consistency weapon

Few-shot examples are the “ultimate weapon” for format consistency. If your zero-shot extraction produces inconsistent formats despite clear instructions, 2-3 examples showing input → expected JSON will enforce the format more effectively than any amount of additional text description.

The reason: examples are concrete. Instructions are abstract. When there’s ambiguity in how to interpret instructions, examples resolve it by showing exactly what the output should look like.

Practical guidelines

  • 2-4 examples is the recommended range. One may be insufficient to establish the pattern. More than four gives diminishing returns while burning tokens.
  • Examples should cover edge cases — include a case where data is missing (showing null return), an ambiguous case (showing the judgment call), and a standard case.
  • Examples are per-request context, not permanent model changes. They apply only to the current request. The next request without examples loses the benefit.
  • Few-shot is especially effective for reducing hallucination in extraction: showing “return null when information is absent” as a concrete example teaches the model to admit when data isn’t there.

One-liner: Zero-shot uses instructions only; few-shot adds 2-4 concrete input/output examples that enforce format consistency and edge case handling more effectively than text instructions alone.