Skip to the workspace
Pebellslearn by building
Core Prompting Techniques  ›  Lesson

One-Shot and Few-Shot Prompting

One-Shot / Few-Shot Prompting 14 minShowing a few worked input-output examples teaches the model the pattern, format and edge cases faster than describing them.

prompt engineering / One-Shot and Few-Shot Prompting

Explore each scene at your own pace.

01 · The rule

The rule

One-Shot and Few-Shot Prompting

Spoke & Chain now wants more than a label: for each email, a small record with the category, the bike part mentioned and how urgent it is. Describing the exact layout in words took a paragraph and still produced three different formats. Showing two finished examples fixed it in minutes.

The rule

Show, don't tell: the model copies the examples you give.

A one-shot prompt includes one worked example of input and output; a few-shot prompt includes several, often two to five. The model spots the pattern and continues it for the new input. Examples teach things that are hard to describe:

  • the exact format, down to spacing and punctuation;
  • the judgement on borderline cases;
  • the tone and length of a written answer.
Extract a record from each email.

Email: My rear brake squeals and I ride to work tomorrow.
Record: category=repair; part=brake; urgency=high

Email: Could you tell me when the blue bottle cage is back in stock?
Record: category=order; part=bottle cage; urgency=low

Email: The chain I bought last week snapped. I'd like my money back.
Record:

The model answers in exactly the layout it was shown, for example category=refund; part=chain; urgency=medium. No paragraph of format rules was needed.

That power cuts both ways. The model copies everything about the examples, including accidents: if all your examples are short, answers get short; if most are labelled repair, it leans toward repair; if the last example is order, that label gets a small extra pull.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.