Zero-Shot vs Few-Shot Prompting

Last reviewed Jul 7, 2026Prompt Engineering · intermediate

What you'll learn

  • Define zero-shot and few-shot prompting
  • Know when examples are worth the extra tokens
  • Write a few-shot prompt that locks in a format

Two dials, one idea

Zero-shot prompting gives the model an instruction and nothing else: “Classify this message as billing, bug, or feature request.” Modern models are good enough that zero-shot handles a huge range of everyday tasks.

Few-shot prompting adds a few worked examples before the real input:

"I was charged twice" -> BILLING
"Export button does nothing" -> BUG
"Please add dark mode" -> FEATURE_REQUEST
"My invoice shows the wrong amount" ->

The model reads the pattern and continues it. This is in-context learning — the model isn’t retrained, it just imitates the demonstrated behaviour for this request.

When to spend the extra tokens

Examples cost tokens, so use them where they earn their keep:

  • You need an exact format. A couple of examples lock the output shape far more reliably than describing it.
  • The task is nuanced or ambiguous. Edge cases the model would otherwise guess at get pinned down by showing how you want them handled.
  • You’re seeing drift. If a zero-shot prompt gives inconsistent results, two or three examples usually stabilise it.

For simple, common tasks, skip the examples — they add cost without adding quality.

The golden rule of examples

The model imitates your examples exactly, flaws and all. So they must be:

  • Consistent — same format, same labelling logic throughout.
  • Representative — include a hard or edge case, not just easy ones, or the model won’t generalise.
  • Correct — a wrong example teaches wrong behaviour.

Get those right and few-shot is the highest-leverage move in prompting. Next: system prompts and roles, which set behaviour for an entire conversation instead of a single message.

Try it yourself — Few-shot to lock a format
Prompt
Classify each support message as: BILLING, BUG, or FEATURE_REQUEST.
Examples:
"I was charged twice this month" -> BILLING
"The export button does nothing" -> BUG
"Please add dark mode" -> FEATURE_REQUEST
Now classify:
"My invoice shows the wrong amount" ->
Sample output
BILLING

Sample output — AI responses may vary.

Common mistakes

  • Adding examples that are inconsistent with each other — the model copies the inconsistency. Your examples must model exactly the behaviour you want.
  • Using few-shot for everything. For simple, well-known tasks, examples just waste tokens without improving results.
  • Picking unrepresentative examples. If your examples are all easy cases, the model won't learn the hard ones.

How to check the AI's answer

  • Test the prompt on tricky, edge-case inputs — not just the ones similar to your examples — to see if the pattern really generalised.
  • If output format drifts, add one more example that demonstrates the exact format; consistency usually snaps back.

Key terms

Zero-shot promptingAsking the model to do a task with instructions only, no worked examples.
Few-shot promptingIncluding a handful of input→output examples in the prompt to demonstrate the desired behaviour and format.
In-context learningThe model's ability to pick up a pattern from examples in the prompt, without any retraining.

Test yourself

3 questions · answers reveal after you check.

1. Zero-shot prompting means…

Zero-shot = a direct instruction with no worked examples. Few-shot adds examples.

2. When is few-shot most worth the extra tokens?

Examples pay off when you need a precise output shape or the task has subtle rules the model won't guess.

3. Your few-shot examples contradict each other on format. What happens?

Examples are powerful precisely because the model imitates them — so inconsistent examples produce inconsistent output.