ailiteracynepal 🇳🇵
Text size

Chapter 01 · Section IV · 10 min read

1.4 Zero-shot vs few-shot: when examples earn their keep

Sometimes a description of the task is enough. Sometimes you need to show the model two or three worked examples. How to tell which situation you are in.

Zero-shot means you describe the task and let the model do it cold. Few-shot means you show the model two or three worked examples of input → output before giving it the real input. Both work. Knowing which to reach for saves a lot of iteration.

The two modes side by side

Zero-shot:

Classify the sentiment of the following review as positive, negative, or neutral.

Review: "The momo was cold but the daal-bhaat was excellent."

Few-shot:

Classify the sentiment of restaurant reviews.

Review: "The service was slow and the food arrived cold."
Sentiment: negative

Review: "Best sekuwa in Thamel. I will be back."
Sentiment: positive

Review: "It was fine. Nothing special, nothing bad."
Sentiment: neutral

Review: "The momo was cold but the daal-bhaat was excellent."
Sentiment:

The few-shot version is longer but far more predictable — the model has three concrete examples of the exact input format, the exact label vocabulary, and the exact output shape.

When zero-shot is enough

Reach for zero-shot when:

  • The task is common (translate, summarize, correct grammar). The model has seen a million examples in training.
  • The output format is a single word or a short sentence.
  • You’re exploring — you want to see what the model does before you invest in examples.

When few-shot pays off

Reach for few-shot when:

  • Your labels are non-standard. “Categorize this ticket as payment_failure, kyc_or_verification, login_or_auth, or other” — the model doesn’t know your slugs. Two examples per category and it does.
  • The output shape is unusual. “Return a Markdown table with these five columns in this exact order” — one example is worth a paragraph of description.
  • The task requires a specific tone. “Rewrite this in the voice of Setopati headlines” is easier to demonstrate than to describe.
  • Edge cases matter. Include an example that covers the tricky case — the model tends to generalise from what you show it.

How many examples

  • One example (one-shot) is often enough to pin down format.
  • Two to five examples is the sweet spot for classification with a small label set.
  • More than five rarely helps in the prompt itself. Beyond that you’re probably running into diminishing returns and paying tokens for repetition. If you genuinely need dozens, you’re closer to fine-tuning territory.

The cost you pay

Few-shot examples take tokens. On a busy production prompt, three examples can double the length. Weigh that against how much iteration you’d otherwise spend fixing zero-shot output.

The cold-start trap

Beginners often reach for few-shot immediately, assuming more instruction is always better. It isn’t. Bad examples actively mislead the model — one typo in your example output and the model will faithfully reproduce that typo. Always sanity-check the examples themselves before shipping the prompt.

Check your understanding

Quick check

You need to classify customer support tickets into four project-specific categories the model has never seen. You have twenty minutes to ship a first version. What is the best default choice?