How it works

One-shot is the ability of a model to perform a task after seeing just one example. Unlike zero-shot (no examples) and few-shot (multiple examples), one-shot provides a single reference case along with the instruction, and the model uses that example to understand the expected format and pattern.

In language models, one-shot prompting is a simple and effective technique: you show an input and output example, and then ask the model to do the same for a new input.

Practical example

You want the model to convert sentences to a specific format. In the prompt you include one example:

"Convert to format 'Verb: object'. Example: 'The cat sleeps on the sofa' -> 'Sleep: cat on the sofa'. Now convert: 'The child plays in the park'."

The model responds "Play: child in the park". With a single example, it understood the pattern.

What it is used for

One-shot is useful when the output format is specific or unusual, and an example makes clear what is expected. It is cheaper than few-shot (fewer tokens in the prompt) and more accurate than zero-shot for tasks with a rigid format. It is a common prompt engineering technique for standardizing model responses.