Prompt types

Zero-shot, one-shot, and few-shot prompting

Zero-shot, one-shot, and few-shot prompting explained. When examples help, how many to use, how to choose them, and the mistakes that make them backfire.

The “shot” in these terms is an example. A zero-shot prompt has none, a one-shot prompt has one, and a few-shot prompt has several. Choosing between them is a trade between prompt length and how precisely you can pin down the output.

Zero-shot prompting

A zero-shot prompt gives instructions and the input, nothing else.

Classify the support ticket as billing, bug, or feature request.
Return only the label.

<ticket>
{{ticket}}
</ticket>

Modern models handle a wide range of tasks this way. Zero-shot is the right default because it is the shortest, the cheapest, and the easiest to maintain. Reach for examples only after clear instructions have failed to produce what you want.

One-shot prompting

A one-shot prompt adds a single example. One example is very good at fixing the format of the answer and weak at teaching a judgment.

Write a changelog entry for the commit below.

Example:
Commit: "fix: retry webhook delivery on 5xx"
Entry: "Fixed: webhooks are now retried when your server returns a 5xx error."

Commit: "{{commit_message}}"
Entry:

The risk is over-imitation. With one example, the model may copy its length, its opening word, or its topic.

Few-shot prompting

A few-shot prompt provides several examples, typically two to five, so the model can infer the pattern from what they have in common.

Rate the urgency of each message as low, medium, or high.

Message: "The export button is slightly misaligned." -> low
Message: "Checkout fails for all customers since 09:00." -> high
Message: "Can you add dark mode at some point?" -> low
Message: "Invoices for March show the wrong tax rate." -> medium
Message: "{{message}}" ->

Few-shot prompting is most useful when:

  • The categories have fuzzy edges that are hard to describe in rules.
  • You need a specific voice, style, or level of detail.
  • The output has a custom format the model has not seen often.

How to choose good examples

Cover the range. Include each label or case at least once. If every example is “high”, the model leans toward “high”.

Include the hard cases. An example of an obvious case teaches little. The borderline ones, such as the tax-rate message above, define where the line is.

Vary the surface. Use different lengths, topics, and phrasings, so the only thing the examples share is the pattern you care about.

Keep the format identical. Same delimiters, same order, same spacing in every example. Inconsistent formatting is itself a pattern, and the model will pick it up.

Use real data. Examples drawn from actual inputs match the distribution the prompt will face.

How many examples

Start with two or three. Add more only if a test shows the output improving. Each example costs tokens on every call, so a ten-example prompt that runs a million times is a real line on the bill. For long example sets that never change, provider prompt caching reduces that cost. See token optimization.

When examples backfire

  • Order effects. Models can weight later examples more. If results skew toward the last label, shuffle the examples.
  • Label imbalance. Three positive examples and one negative bias the output toward positive.
  • Leaking content. The model reuses names or facts from the examples in its answer. Tell it the examples are for format only, or use obviously placeholder content.
  • Examples that contradict the instructions. If the rules say “one sentence” and an example has two, the example usually wins.

Zero-shot or few-shot: a decision rule

Situation Start with
Common task, clear rules Zero-shot
Output format keeps drifting One-shot, or a schema
Labels depend on judgment Few-shot
Need a particular writing style Few-shot
Reasoning-heavy problem Zero-shot with a reasoning technique

For strict formats, a schema is more reliable than examples. See structured output prompting. For reasoning tasks, examples of the answer alone help less than showing the reasoning, which is the idea behind chain-of-thought prompting.

Separating examples from input

Wrap examples and the real input in distinct delimiters so the model cannot confuse them, and so user text cannot pose as an example.

<examples>
...
</examples>

<input>
{{message}}
</input>

The PromptFlowEngine prompt analyzer flags template variables that are not delimited, which is the most common mistake in few-shot templates.