DevKits
Concept

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