All Things AI
Build with AI

Few-Shot, Zero-Shot & Many-Shot

Intermediate

Few-Shot, Zero-Shot & Many-Shot Prompting

One of the most reliable ways to improve model outputs is to show it examples of what you want. Zero-shot prompting asks without examples; few-shot provides 2โ€“10; many-shot leverages the long context windows of modern models to provide dozens or hundreds. Each has a place.

Zero-Shot Prompting

Zero-shot means no examples - just a task description. Modern frontier models handle zero-shot remarkably well for common tasks. It is the right starting point, not a fallback. Add examples only if zero-shot quality is insufficient.

"Classify the sentiment of this customer review as Positive, Negative, or Neutral. Review: [text]"

No examples needed - frontier models know what sentiment classification means.

Few-Shot Prompting

Few-shot adds 2โ€“10 input/output pairs before the actual query. This teaches the model the output format, the level of detail, the tone, and any domain-specific patterns it would not know from training alone.

System: Classify support tickets as BUG, FEATURE_REQUEST, or BILLING.

Examples:
Input: "The app crashes when I click export"
Output: BUG

Input: "Can you add dark mode?"
Output: FEATURE_REQUEST

Input: "I was charged twice this month"
Output: BILLING

Input: "Search results don't show recent files"
Output:

What makes a good example?

Good examples

  • โ€ข Representative of the real distribution of inputs
  • โ€ข Cover edge cases and ambiguous categories
  • โ€ข Consistent format and level of detail
  • โ€ข Correct - wrong examples teach wrong patterns

Bad examples

  • โ€ข All from one category (biases the model)
  • โ€ข Inconsistent formatting across examples
  • โ€ข Too simple vs the real query complexity
  • โ€ข Too many - beyond 10 has diminishing returns

Many-Shot Prompting

Modern models with 128Kโ€“1M token context windows can fit hundreds of examples. Many-shot (50โ€“500+ examples) can match or exceed fine-tuning quality for structured tasks, without any training cost. This is especially powerful for:

  • Classification tasks with 10+ output categories
  • Domain-specific formatting that diverges from training data
  • Tasks where label quality matters - you curate good examples rather than training on noisy data

Cost caution

100 examples ร— 50 tokens each = 5,000 tokens added to every request. At scale this adds up fast. Use prompt caching (where available) to avoid re-encoding examples on every call - this can reduce cost by 90%+ for many-shot prompts.

Selecting Examples Dynamically

Static few-shot examples in a system prompt are simple but may not be optimal for every query. Dynamic example selection retrieves the most similar examples from a curated pool using embedding similarity - this is "example RAG" and can significantly outperform static selection for diverse inputs.

Practical Tips

  • Always start zero-shot - add examples only if quality is insufficient
  • For few-shot: 3โ€“5 examples usually captures most of the benefit
  • Ensure examples cover the full output space, not just common cases
  • For many-shot: enable prompt caching to contain cost
  • Test example ordering - some research shows last example has disproportionate influence
  • For classification, ensure roughly balanced representation across classes