Prompt Engineering

Zero-Shot vs Few-Shot Prompting: When to Use Each

Understand the difference between zero-shot and few-shot prompting, when each approach works best, and how to combine them for better AI output.

Zero-shot and few-shot prompting are two fundamental approaches to getting output from AI models. Understanding when to use each — and when to combine them — is one of the highest-leverage prompt engineering skills.

What's the Difference?

Zero-shot prompting means giving the AI a task with no examples. You describe what you want and the model figures out how to do it based on its training.

"Classify this customer review as positive, negative, or neutral: 'The product arrived on time but the packaging was damaged. The item itself works fine.'"

Few-shot prompting means giving the AI one or more examples of the input-output pattern you want before asking it to handle a new case.

"Classify these customer reviews:

Review: 'Absolutely love this product! Best purchase I've made all year.' Classification: Positive

Review: 'Broke after two days. Complete waste of money.' Classification: Negative

Review: 'The product arrived on time but the packaging was damaged. The item itself works fine.' Classification: ?"

Both prompts ask for the same thing. The few-shot version is more likely to produce the exact format and classification approach you want.

When Zero-Shot Works Best

Zero-shot prompting is the right choice when:

The Task Is Well-Defined

For tasks that are clear and unambiguous, examples add length without adding value.

"Summarize this article in 3 bullet points, each under 20 words: [paste article]"

The instruction is specific enough that examples wouldn't change the output quality.

You Want Creative Output

For brainstorming, ideation, and creative writing, zero-shot often produces more diverse output. Examples can constrain the AI's creativity by anchoring it to the patterns you showed.

"Generate 10 tagline options for a fitness app targeting busy professionals. Mix serious and playful tones."

Adding examples here would bias the output toward similar styles and structures.

Speed Matters

Zero-shot prompts are shorter, which means faster responses. When you're iterating quickly — testing different prompts, generating variations, exploring approaches — zero-shot keeps the cycle time short.

The Model Already Knows the Pattern

Modern AI models are trained on vast amounts of text. For common tasks (summarization, translation, sentiment analysis, Q&A), the model already knows the pattern. Examples are redundant.

When Few-Shot Works Best

Few-shot prompting shines when:

You Need a Specific Format

This is the #1 use case for few-shot prompting. When your output needs to follow a precise format, examples communicate that format more effectively than descriptions.

Zero-shot (often inconsistent format): "Extract the company name, role, and years of experience from this resume text."

Few-shot (consistent format): "Extract structured data from resume text.

Input: 'Senior Software Engineer at Google (2019-2023). Previously at Stripe (2016-2019).' Output: {company: 'Google', role: 'Senior Software Engineer', years: 4}, {company: 'Stripe', role: 'Software Engineer', years: 3}

Input: 'Led product team at Figma for 5 years. Before that, 2 years at Facebook.' Output: {company: 'Figma', role: 'Product Lead', years: 5}, {company: 'Facebook', role: 'Unknown', years: 2}

Input: [your resume text] Output: ?"

You Need a Specific Tone or Style

Describing tone is hard. Showing it is easy.

"Write product descriptions in our brand voice.

Example: 'The Nomad Backpack — 30L of organized chaos for people who work from everywhere. Padded laptop sleeve, hidden passport pocket, and a water bottle holder that actually holds water bottles. TSA-friendly. Coffee-stain resistant (tested extensively).'

Example: 'The Desk Pad — Your desk deserves better than sticky notes and coffee rings. Full-grain leather, 30" x 15", with a non-slip base that stays put during your most aggressive typing sessions.'

Now write a description for: [product with specs]"

Two examples establish the voice pattern more effectively than describing it as "casual, specific, with a touch of humor and practical details."

You're Doing Classification or Categorization

Classification tasks benefit enormously from examples because they establish the boundaries between categories.

"Categorize these support tickets.

'I can't log in to my account' → Account Access 'Your pricing page shows different prices than what I was quoted' → Billing 'How do I export my data to CSV?' → Feature Question 'The app crashes when I upload files larger than 10MB' → Bug Report

Now categorize: 'I was charged twice for my subscription this month' → ?"

Without examples, the model might create its own category names or classify inconsistently.

You Want Consistent Quality

Few-shot examples set a quality bar. If your examples are detailed and high-quality, the AI matches that level. If you only provide zero-shot instructions, quality varies more between responses.

How Many Examples Do You Need?

1 example is better than none when you need format consistency. One example shows the pattern; zero leaves it to interpretation.

2-3 examples is the sweet spot for most tasks. This establishes the pattern while showing variation (so the AI doesn't just copy one example).

5+ examples is rarely necessary with modern models. More examples consume tokens (increasing cost and response time) with diminishing returns. Use 5+ only when:

  • The task has many edge cases to demonstrate
  • The classification has many categories
  • The pattern is genuinely unusual

Combining Zero-Shot and Few-Shot

The most effective approach often combines both techniques.

Instruction + Examples

"Rewrite these sentences to be more concise. Remove filler words, combine redundant phrases, and keep the original meaning. Target: 50% fewer words.

Original: 'In order to effectively utilize the full potential of our platform, it is important to first gain a comprehensive understanding of the key features and functionality.' Rewritten: 'To get the most from our platform, learn the key features first.'

Original: 'We wanted to reach out and let you know that we have recently made some significant improvements to our product.' Rewritten: 'We've made major product improvements.'

Now rewrite: [your sentence]"

The instruction (zero-shot) establishes the rules. The examples (few-shot) demonstrate how to apply them. Together they produce more consistent results than either approach alone.

Progressive Complexity

Start simple with zero-shot, then add examples only where the model struggles.

  1. Try zero-shot first
  2. If the format is wrong, add 1-2 format examples
  3. If the quality or style is off, add examples that demonstrate the right level
  4. If edge cases are handled incorrectly, add examples covering those edges

This approach keeps your prompts as short as possible while being as effective as needed.

Common Mistakes

Too Many Examples, Not Enough Instruction

Examples show the "what" but not the "why." If you want the AI to handle novel cases well, combine examples with explicit rules.

Bad: 5 examples with no explanation of the underlying pattern. Good: 2 examples plus "The rule is: categorize based on [criteria]. When ambiguous, default to [category]."

Examples That Are Too Similar

If all your examples follow the same pattern, the AI may not handle edge cases well. Include at least one example that's different from the rest — an edge case, a tricky classification, or an unusual format.

Examples That Contradict the Instructions

If your instructions say "keep it under 50 words" but your examples are 100 words each, the AI follows the examples. Make sure your examples match your stated requirements.

Quick Decision Guide

| Situation | Use | |---|---| | Simple, well-defined task | Zero-shot | | Specific output format needed | Few-shot (2-3 examples) | | Creative/brainstorming | Zero-shot | | Classification or categorization | Few-shot | | Matching a specific tone/style | Few-shot | | Speed and iteration | Zero-shot | | High consistency required | Few-shot | | Novel or unusual task | Few-shot |

Further Reading