One-shot prompting

One-shot prompting is giving a language model exactly one worked example of a task in the prompt, alongside the instruction, before asking it to handle a new case.

One-shot prompting sits between giving a model only an instruction, known as zero-shot, and giving it several examples, known as few-shot. Google's machine learning glossary illustrates it with a prompt that asks for a country's official currency, shows a single answered case, France: EUR, and then ends with India: for the model to complete.

The setting was defined in OpenAI's 2020 GPT-3 paper. One-shot there meant a natural-language description of the task plus a single demonstration, with no change to the model's weights. The authors separated it from zero-shot and few-shot because it most closely matches how tasks are often explained to people: workers on crowdsourcing services, for instance, are commonly given one demonstration. They also noted that with no example at all, some requests are hard even for a person to interpret, citing a request to make a table of world records for the 200 metre dash, where the format is unclear.

That is where a single example earns its place. It shows the shape of the answer: the length, the structure, the fields of a JSON object or the house style of a product description. Someone generating catalogue copy might paste one finished description and ask for the next ten products in the same style.

The risk is that one example is easy to over-copy. With nothing to compare it against, the model cannot tell which features are essential and which are incidental, so it may mirror the example's length, wording or even its content. Anthropic's prompting guidance recommends several varied examples for exactly this reason, so the model does not pick up unintended patterns. For reasoning models, OpenAI suggests starting with no examples and adding them only when the output requirements are complex.

Common questions

What is an example of one-shot prompting?

"Translate English to French. Example: cheese becomes fromage. Now translate: bread." The prompt gives one solved case, then a new one. The single example shows the model both the task and the format of the answer.

What is the difference between zero-shot, one-shot and few-shot prompting?

Zero-shot gives only the instruction. One-shot adds a single example, and few-shot adds several. More examples usually make the expected output clearer but lengthen the prompt.

When should I use one-shot prompting?

Use it when a description alone leaves the format unclear, but one example settles it, such as a fixed layout, a data structure or a house style. If the model copies the example too closely, switch to a few varied examples.

Is one-shot prompting the same as one-shot learning?

No. One-shot prompting puts one example in a language model's prompt and changes nothing in the model. One-shot learning is a family of training methods, mainly in computer vision, for recognising new categories from a single example.

Finding more

Search for "one-shot prompting", "zero-shot vs few-shot prompting" or "prompting with examples" to find guidance. Model makers' prompting guides are the best source for how their current models respond to examples, and the GPT-3 paper explains where the zero, one and few-shot distinction came from. Try the same task with zero, one and several examples on your own data, since the best choice varies by model and task.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.