Zero-Shot vs. Few-Shot Prompting Explained
There are fundamentally two ways to ask an AI to do something: tell it what you want and hope it figures it out, or show it exactly what you want by example. These two approaches — zero-shot and few-shot prompting — are the most important structural decisions you make when designing any prompt.
Understanding when to use each one, and how to mix them, is the difference between prompts that work sometimes and prompts that work reliably.
What Is Zero-Shot Prompting?
Zero-shot prompting means asking the AI to perform a task without providing any examples. You describe the task, define the format, set constraints, and hope the model's training has prepared it to understand what you mean.
Classify the sentiment of this product review as positive, negative, or neutral.
Review: "The battery life is incredible but the camera is disappointing for the price."
Zero-shot works best when:
- The task is common and well-represented in the model's training data (sentiment analysis, summarization, translation)
- You need speed and do not have examples ready
- The output format is simple and standard
- You are exploring a task to understand what the model can do before investing in example curation
What Is Few-Shot Prompting?
Few-shot prompting provides 2-5 examples of the exact input → output pattern you want before asking the model to process the actual input. The examples serve as a template.
Classify the sentiment of product reviews.
Examples:
Review: "Best purchase I have made this year. Highly recommend!"
Sentiment: positive
Review: "Arrived broken and customer service never responded."
Sentiment: negative
Review: "It works as described. Nothing special but not bad either."
Sentiment: neutral
Review: "The battery life is incredible but the camera is disappointing for the price."
Sentiment:
Few-shot works best when:
- The task is domain-specific or unusual
- You need a very specific output format
- The model's default behavior is not quite right
- You are classifying into custom categories the model might not recognize
- Consistency across many inputs matters
What Is One-Shot Prompting?
One-shot is a middle ground: a single example. It is useful when the task is straightforward but the format is non-obvious.
Summarize technical articles in exactly 3 bullet points.
Example:
Article: [EXAMPLE ARTICLE TEXT]
Summary:
- [Bullet 1]
- [Bullet 2]
- [Bullet 3]
Article: [NEW ARTICLE TEXT]
Summary:
Comparing the Three Approaches
Imagine you need to extract named entities from job descriptions:
Zero-shot:
Extract all company names, job titles, and locations from this job description.
Result: May work, but the format is unpredictable. Might list entities as a paragraph, might use JSON, might miss implicit locations.
One-shot:
Extract entities from job descriptions.
Format:
Company: [name]
Title: [title]
Location: [city, state or "Remote"]
Example:
"Stripe is hiring a Senior Backend Engineer in San Francisco or remote."
→ Company: Stripe
→ Title: Senior Backend Engineer
→ Location: San Francisco, CA or Remote
Result: Better format consistency, but might still make errors on edge cases.
Few-shot (3 examples):
Extract entities from job descriptions.
[3 EXAMPLES WITH DIFFERENT FORMATS: REMOTE, HYBRID, MULTIPLE LOCATIONS]
Now extract from:
"[NEW JOB DESCRIPTION]"
Result: Highest accuracy and format consistency. The model has seen enough variation to handle edge cases correctly.
How Many Examples Should You Provide?
Research and practical experience suggest a diminishing returns curve:
- 0 examples: Fast, unpredictable. Good for exploration.
- 1 example: Dramatic improvement in format consistency. The single biggest gain.
- 2-3 examples: Further improvement in accuracy, especially for edge cases.
- 4-5 examples: Minor additional gains. Usually sufficient for production.
- 6+ examples: Diminishing returns. If you need this many, consider fine-tuning instead.
Few-Shot Design Best Practices
The quality of your examples matters more than the quantity:
- Cover edge cases: Include examples that test the boundaries of the task (missing data, ambiguous inputs, negative examples)
- Distribute evenly: If classifying, include examples from every class. Do not over-represent the common case.
- Match your real data: Examples should look like the actual inputs the model will see, not simplified textbook cases.
- Be explicit about the reasoning: For difficult tasks, include the reasoning chain, not just the final answer.
When Zero-Shot Is Actually Better
There are scenarios where adding examples hurts performance:
- Creative tasks: Examples can anchor the model to a specific style, limiting creativity.
- Very common tasks: For tasks like "summarize this," the model already knows what to do. Adding an example is redundant and increases token cost.
- When examples are biased: If your examples contain errors or biases, the model will replicate them.
Higher-Order Techniques
Once you have mastered zero-shot and few-shot, two advanced techniques build on them:
Chain-of-Thought (CoT): Ask the model to show its reasoning. This is especially effective for reasoning-heavy tasks like math, logic, and analysis.
Solve this problem step by step before giving the final answer.
[PROBLEM]
Self-Consistency: Generate multiple answers and pick the most consistent one. This reduces the impact of random noise in a single generation.
The Prompt Engineer's Decision Tree
Use this simple framework when deciding which approach to use:
- Start with zero-shot. Is the output acceptable? If yes, stop.
- If the format is wrong, add 1 example for format guidance.
- If accuracy is wrong, add 2-3 examples covering edge cases.
- If the task requires reasoning, add chain-of-thought instructions.
- If you need 5+ examples consistently, consider whether fine-tuning is more efficient than prompting.
Next Steps
Apply these techniques with 50+ ready-to-use examples in our Prompt Library.