All articles
April 12, 2025 5 min read

Zero-, one-, and few-shot prompting: teaching by example, in the prompt

One of the most reliable ways to steer a model is to show it examples. Here's the difference between zero-, one-, and few-shot prompting, and when each earns its tokens.

Written forEngineeringProduct
PromptingFundamentalsLLM

Before you reach for fine-tuning, reach for examples. Large models can learn a task from a handful of demonstrations placed right in the prompt — a trick called in-context learning. How many examples you show gives the technique its name: zero-shot, one-shot, or few-shot.

The three, briefly

  • Zero-shot — just an instruction, no examples. 'Classify the sentiment of this review.' Modern models are strong at this for common tasks.
  • One-shot — a single worked example before the real input, to pin down the format or style you want.
  • Few-shot — several examples (typically two to five) covering the variations and edge cases, so the model infers the pattern precisely.

Why examples work so well

An example communicates what an instruction struggles to: the exact output shape, the tone, how to handle the tricky case. Showing 'input → output' three times is often faster and more reliable than a paragraph describing the same thing — especially for nuanced formatting or classification with fuzzy boundaries.

A few-shot classifier, in the messages
const messages = [
  { role: 'system', content: 'Label each review: positive, negative, or neutral.' },
  { role: 'user', content: 'Absolutely loved it.' },
  { role: 'assistant', content: 'positive' },
  { role: 'user', content: 'It broke on day two.' },
  { role: 'assistant', content: 'negative' },
  { role: 'user', content: 'It arrived on time.' },   // the real input
];

When to use which

Start zero-shot — if the model nails it, you've spent no extra tokens. Add one example when the format drifts. Go few-shot when the task is nuanced or the edge cases matter. Past a handful you hit diminishing returns and rising cost; that's usually the signal to consider fine-tuning instead.

Don't describe the task twice when you can show it once. Examples are the cheapest fine-tuning you'll ever do.
Building something with LLMs?
I help teams ship GenAI that’s reliable and cost-efficient.
Let’s talk