arrow_backAll articles
Zero-Shot, One-Shot, and Few-Shot Prompting: When to Use Each One With Real Examples
Prompt Engineering

Zero-Shot, One-Shot, and Few-Shot Prompting: When to Use Each One With Real Examples

Prompt Toolbox··4 min read

If you've read anything about prompt engineering you've probably seen these three terms thrown around. Zero-shot, one-shot, few-shot. They sound more complicated than they are, and once you understand what they mean you'll start recognizing which one you're already using naturally and which ones you're missing out on.

The short version is this: these terms describe how many examples you give the model before asking it to do the thing you actually want. Zero examples, one example, or a few examples. That's the whole distinction. But the implications of that choice are significant and worth understanding properly.

Zero-shot prompting: asking without showing

Zero-shot means you give the model a task without any examples of what the output should look like. You just describe what you want and let the model figure out how to do it based on its training.

Most people use zero-shot prompting all the time without knowing it has a name. "Summarize this article." "Translate this paragraph into French." "Write a subject line for this email." All of those are zero-shot prompts because you're not showing the model any examples of what a good summary, translation, or subject line looks like.

Zero-shot works well when the task is common enough that the model has seen many examples of it during training. Summarization, translation, basic writing tasks, answering factual questions, these are all things models are well-trained on and can handle reliably without examples.

Where zero-shot starts to struggle is with tasks that are specific to your context, that have an unusual format, or that require a particular style or tone that isn't obvious from the description alone. If you want summaries that follow a very specific structure, or outputs that match a particular voice, zero-shot prompting often produces results that are close but not quite right.

According to MIT Technology Review's reporting on large language model capabilities, zero-shot performance has improved dramatically with newer model generations, but few-shot prompting still consistently outperforms zero-shot on tasks that require specific formatting or stylistic consistency.

One-shot prompting: showing one example

One-shot means you give the model one example of what you want before asking it to do the task. The example shows the model the format, style, tone, or structure you're looking for, and the model uses that as a reference point when generating its response.

A simple one-shot prompt for writing subject lines might look like this: you show the model an email and the subject line you wrote for it, then you show it a new email and ask it to write the subject line. The model now has a concrete reference for what your preferred subject line style looks like, and it will lean toward that style in its response.

One-shot is most useful when you have a clear preference for how the output should look but it's hard to describe in words. Sometimes it's easier to show than to explain, and one good example communicates a lot of implicit information about format, length, tone, and approach that would take many sentences to spell out explicitly.

The limitation of one-shot is that one example might not capture the full range of variation in what you want. If your one example happens to be a short subject line, the model might assume all subject lines should be short even when the email calls for something longer. That's where few-shot comes in.

Few-shot prompting: showing multiple examples

Few-shot means you give the model several examples before asking it to do the task, typically somewhere between two and ten. Multiple examples let you show the model a range of inputs and outputs, which gives it a much richer picture of what you're looking for and makes the outputs more consistent across different types of input.

Few-shot prompting is particularly powerful for tasks where you want the output to follow a very specific pattern regardless of the input. If you're building a tool that classifies customer feedback into categories, for example, showing the model five or six examples of feedback and the correct category for each one will produce much more reliable classifications than describing the categories in words.

It's also useful when you want to establish a tone or voice that's hard to describe. Showing three or four examples of writing in the style you want communicates that style more effectively than any description could, because the model can pick up on patterns in the examples that you might not even be consciously aware of yourself.

The tradeoff with few-shot prompting is tokens. Every example you include in your prompt uses tokens, and those tokens count toward your costs on every request. If you're using few-shot prompting in a production application, it's worth being deliberate about how many examples you include and making sure each one is actually adding information rather than just repeating what earlier examples already showed.

The Token Counter on Prompt Toolbox is useful here because you can paste your full few-shot prompt and see exactly how many tokens the examples are using, which helps you find the right balance between richness of examples and cost per request.

How to choose which one to use

The practical decision tree is pretty simple. Start with zero-shot. If the outputs are consistently good enough for your purpose, you're done. If they're inconsistent or missing something specific about your preferred format or style, try one-shot with your best example of what you want. If one example isn't enough to get consistent results across different inputs, move to few-shot with three to five carefully chosen examples that cover the range of variation you expect to see.

For most everyday tasks, zero-shot is fine. For anything where consistency and format matter, few-shot is almost always worth the extra tokens.

Try the tools