NorthGradient
Start reading
Chapter 4 · Lesson 1 Browse lessons

Prompt Design · Chapter 4 · Lesson 1 · 6 min read

Zero-shot and few-shot prompting

An instruction can only describe what you want so precisely. You can specify the action, audience, format, and constraints, and still find the output slightly off: the vocabulary, the structure, the level of detail wrong in ways hard to put into words.

This is a limitation of description itself. Some things are easier to show than to say, and in prompting, showing means examples.

Providing examples inside the prompt lets the model infer the pattern you want, rather than relying on your ability to describe it.

Zero-shot prompting

A zero-shot prompt gives the model an instruction and no examples. It relies entirely on its training to interpret the task and decide what a good response looks like.

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

Review: "The battery life is excellent but the screen is dim."

Zero-shot works well when the task is common enough that the model saw many examples during training. Sentiment classification, summarisation, translation, and basic question answering all qualify: the model has a strong prior, and a clear instruction activates it.

Zero-shot struggles on tasks that are unusual, highly specific, or that need an output format the model would not produce by default. “Classify reviews using a three-level scale with confidence scores in parentheses” is harder to convey by description than by one example.

Few-shot prompting

A few-shot prompt includes one or more example input-output pairs before the actual input. The model reads them, infers the pattern, and applies it to the new input.

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

Review: "Fantastic sound quality, worth every penny."
Sentiment: positive

Review: "Stopped working after two weeks. Very disappointed."
Sentiment: negative

Review: "The battery life is excellent but the screen is dim."
Sentiment:

The model does not need to be told what “positive” or “negative” means. The examples show the exact format, vocabulary, and granularity you want, and the instruction handles the rest.

What examples communicate that instructions cannot

An example communicates several things at once that are hard to encode in writing:

  • Output format: the exact structure, punctuation, and capitalization of the response
  • Level of detail: how much to say, and what to leave out
  • Tone: formal or informal, confident or hedged
  • Edge case handling: how to respond when the input is ambiguous or atypical

A single well-chosen example can replace several sentences of format description, and does so more precisely because it shows rather than tells.

One-shot versus few-shot

A prompt with a single example is sometimes called one-shot; a prompt with several is few-shot. There is no sharp boundary, and the right number depends on the task.

For simple tasks, one example is usually enough. For tasks with multiple output patterns or edge cases, more examples help the model see the full range of expected behavior. Two or three cover most situations. Beyond five or six, returns diminish and the prompt grows long enough to push useful context out of the window.

A diagram contrasting a zero-shot prompt with a few-shot prompt, showing how examples narrow the model toward a specific output pattern.
A diagram contrasting a zero-shot prompt with a few-shot prompt, showing how examples narrow the model toward a specific output pattern.

What few-shot prompting cannot do

Few-shot prompting does not teach new knowledge. If the model does not know something, an example will not supply it. Examples shape the format and pattern of the output, not what the model knows.

It also does not guarantee consistency across every input. The model generalizes a pattern from your examples; if they do not cover an edge case, it handles that case on its own judgment, which may not match what you intended. The next lesson covers how to choose and format examples to minimize this gap.

In the next lesson, we’ll look at how the format and selection of your examples affects how reliably the model applies the pattern you intend.