Skip to content

Few-shot prompting

A method of configuring model behavior through several examples shown directly in the prompt.

What is it

Usually, models can be given a task without examples — this is zero-shot. If the format is complex, it's better to show examples.

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

Approach Examples
Zero-shot 0
One-shot 1
Few-shot 2–5

Example

Determine the sentiment. Respond only with 'positive' or 'negative'.

Review: 'Delivery was fast, everything was great'
Sentiment: positive

Review: 'Product arrived broken'
Sentiment: negative

Review: 'Overall okay, but the box was dented'
Sentiment:

How to compose examples

  • 2–5 examples;
  • uniform format;
  • show typical and complex cases;
  • examples should resemble real queries.

Limitations

  • examples take up space in context;
  • too many examples can be confusing;
  • the model may copy errors from the examples.

See also

← All terms