School/Prompt Engineering/Prompt Fundamentals
3/3
Wave 210 minintermediate

Zero-Shot vs Few-Shot Prompting

How examples transform AI output quality.

Zero-Shot vs Few-Shot Prompting

This is one of the most powerful techniques in prompt engineering -- and it is surprisingly simple. The core idea: instead of just telling the AI what to do, you show it what you want by providing examples. The difference in output quality can be dramatic.

Key Concept

Few-shot prompting is the technique of giving the AI examples of the input-output pattern you want before asking it to process your actual request. It is one of the highest-impact skills you can develop.

Zero-Shot Prompting

You give the AI a task with no examples. You are relying entirely on the AI's training to figure out what you want.

"Classify this customer review as positive, negative, or neutral: 'The product works fine but shipping was slow.'"

The AI uses its general training to interpret the task. For simple, unambiguous requests, this works well enough. But the AI is guessing at your exact criteria, your preferred format, and how you want edge cases handled.

One-Shot Prompting

You give one example before your actual request. This single example does a surprising amount of heavy lifting -- it shows the AI your expected format, your classification criteria, and the level of detail you want.

"Classify customer reviews as positive, negative, or neutral.

Example:

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

Classification: Positive

Now classify this:

Review: 'The product works fine but shipping was slow.'

Classification:"

Few-Shot Prompting

You give multiple examples (typically 2-5). This is where things get really powerful, because your examples can cover different scenarios, edge cases, and nuances.

"Classify customer reviews. Here are examples:

Review: 'Absolutely love it! Best purchase ever.' --> Positive

Review: 'Completely broken on arrival. Want a refund.' --> Negative

Review: 'It's okay. Does what it says.' --> Neutral

Review: 'Great quality but overpriced.' --> Mixed

Now classify: 'The product works fine but shipping was slow.' -->"

Notice the fourth example introduces a "Mixed" category. Without that example, the AI might force every review into just three buckets. Your examples define the rules.

Why Few-Shot Is So Powerful

  1. 1Pattern matching: The AI learns exactly what format you want
  2. 2Edge cases: Your examples can show how to handle tricky situations
  3. 3Consistency: Output format stays consistent across many items
  4. 4Accuracy: Studies show few-shot prompting can improve accuracy by 20-40%
Example

Few-shot is not just for classification. Here is a prompt that teaches the AI a custom writing style:

"Rewrite product descriptions in our brand voice. Examples:

Original: 'This backpack has a 30L capacity and water-resistant fabric.'

Our voice: 'Thirty liters of adventure-ready storage, wrapped in fabric that laughs at rain.'

Original: 'These headphones feature 40-hour battery life and noise cancellation.'

Our voice: 'Forty hours of your favorite sounds, minus everything you do not want to hear.'

Now rewrite: 'This water bottle holds 24oz and keeps drinks cold for 12 hours.'"

The AI picks up the playful, punchy style from your examples -- something nearly impossible to achieve with a zero-shot description of "make it sound fun."

When to Use Each

TechniqueBest For
Zero-shotSimple, unambiguous tasks
One-shotTasks where format matters
Few-shotClassification, formatting, complex patterns, batch processing
Pro Tip

Few-shot prompting is especially valuable when you need to process many items the same way. Write your examples once, then feed in dozens or hundreds of items. The AI will handle them all consistently -- like a template that actually understands context.

Pro Tips

  • Use diverse examples that cover different cases
  • Include edge cases in your examples -- the tricky ones that define your criteria
  • Keep examples concise but representative
  • 3-5 examples is usually the sweet spot (more is not always better -- after about 5, you get diminishing returns and start eating into the context window)
Watch Out

Choose your examples carefully. If all your few-shot examples are straightforward cases, the AI will struggle with edge cases. If you know certain inputs are tricky (mixed sentiment, ambiguous phrasing, unusual formatting), include at least one example that covers that scenario.

Exercises

0/3
Quiz+5 XP

Few-shot prompting can improve accuracy by approximately:

Prompt Challenge+20 XP

Create a few-shot prompt (3 examples) that teaches AI to convert informal meeting notes into professional action items. Test it with a real or made-up meeting note.

Hint: Example format: "Meeting note: John said he'd finish the report → Action: John to complete quarterly report by [date]"

Quiz+5 XP

What is the recommended sweet spot for number of examples in few-shot prompting?