Few-Shot vs Zero-Shot Prompting — When Examples Help an LLM
Zero-shot prompting asks an LLM to do a task with no examples; few-shot prompting includes a handful of input→output examples to show the pattern. This guide explains the difference, when examples are worth the extra tokens, and how to choose and format them.
Last updated:
Core Concepts
- Zero-shot prompting
- Zero-shot means you describe the task and let the model do it with no worked examples — 'Classify this review as positive or negative: …'. Modern instruction-tuned models are surprisingly good zero-shot, so for common, well-understood tasks (summarize, translate, simple classification) zero-shot is often enough and cheapest, since you spend no tokens on examples.
- Few-shot prompting
- Few-shot means you include a few input→output examples before the real input, so the model infers the exact pattern, format, and edge-case handling you want. 'Here are 3 examples of the label format… now label this one'. It shines when the task is unusual, the output format is strict, or zero-shot keeps getting the format subtly wrong. The cost is tokens: every example is paid for on every call.
- When to use which
- Start zero-shot. If the model misunderstands the task or the output format drifts, add 1–5 well-chosen examples (few-shot). Examples are especially powerful for enforcing a precise output shape, teaching domain-specific labels, or handling tricky edge cases. If you'd need dozens of examples to get it right, that's a signal to consider fine-tuning instead.
- Choosing good examples
- Quality beats quantity. Pick examples that are representative, cover the edge cases you care about, and match the exact output format you want (the model copies the format precisely). Keep them diverse so the model doesn't overfit to one pattern, and order can matter — the most relevant example often works best placed last, closest to the real input.
Frequently Asked Questions
Is few-shot always better than zero-shot?
No. Few-shot costs extra tokens on every call and isn't needed for tasks modern models already do well zero-shot. Use zero-shot first; add examples only when the model misunderstands the task or the output format isn't reliable. For common tasks, zero-shot is cheaper and often just as good.
How many examples should a few-shot prompt have?
Usually 1 to 5. Start with one or two representative, correctly-formatted examples and add more only if accuracy improves. Beyond a handful you hit diminishing returns and rising token cost — if you need many, consider fine-tuning instead.
What's 'one-shot' prompting?
One-shot is few-shot with exactly one example. It's a middle ground: cheaper than many examples but enough to demonstrate the output format when zero-shot gets the format wrong.
Try these related tools
Prompt Generator →
Build a clear, structured prompt by filling in role, task, context, constraints, and output format. Generates a ready-to-paste prompt for ChatGPT, Claude, or Gemini. 100% local, no signup.
Prompt Template Tester →
Write a prompt with {{variable}} placeholders, fill in values, and preview the final prompt. Detects every variable and flags any you left unfilled. 100% local.
Token Counter →
Count tokens in your prompt for GPT-4, GPT-3.5, Claude, and Gemini and predict API cost before you spend. Free, no signup — all counting runs locally, your prompt stays in your browser.
Prompt Token Breakdown →
Break a prompt into segments and see how many tokens — and how much cost — each part uses. Find the heaviest section (system, few-shot examples, or user input) so you know exactly what to trim. 100% local.
Prompt Diff →
Compare two versions of a prompt line by line and see the token delta between them — so you know exactly what changed and whether an edit made the prompt cheaper or more expensive. 100% local.