Loading pattern...

What is Few-Shot Learning?

Few-Shot Learning means giving the AI 2-5 examples before asking it to do a task. "Here are 3 examples of how to classify emails as spam/not spam. Now classify this one." AI learns the pattern from examples and applies it. Much more accurate than zero-shot (no examples) for complex or specific tasks. Works via "in-context learning"—AI infers the pattern without changing model weights. Sweet spot: 2-5 examples, more doesn't help much.

When Should You Use This?

Use few-shot when zero-shot quality isn't good enough: domain-specific tasks, exact output format, consistent style, or when accuracy matters. Start with 2-3 examples, test, add more if needed. Diminishing returns after 5 examples. For 100+ examples or long-term use, consider fine-tuning instead. Few-shot works great for: classification, extraction, formatting, style matching.

Common Mistakes to Avoid

  • Too many examples—2-5 is enough, 20 wastes tokens and confuses AI
  • Bad examples—garbage in, garbage out. Use diverse, high-quality examples
  • Not representative—examples should cover edge cases, not just easy ones
  • Ignoring cost—examples use tokens, more expensive than zero-shot
  • When to fine-tune—if you need 100+ examples or permanent behavior, fine-tune instead

Real-World Examples

  • Email classification: Show 3 spam/not spam examples, AI classifies new emails accurately
  • Custom JSON format: Show 2-3 examples of exact structure, AI matches format perfectly
  • Writing style: Show examples of your tone, AI mimics it
  • Data extraction: Show how to extract names/emails from 3 texts, AI does it for new ones

Category

Ai Vocabulary

Tags

few-shotpromptingin-context-learningexamplesprompt-engineering

Permalink