Skip to content
IndexRequest a UIAboutContact

Few-shot Example Pairs

A text prompt with zero, one or three worked examples, and how the answer format gets steadier with more examples.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI IMAGE OR VIDEO TOOL
Clean diagram of a prompt template split into coloured blocks: an instruction block at the top reading Classify each review as positive, negative or mixed and return JSON, then three small example blocks each with an Input line and an Output line in JSON, then the new Input line and an empty Output slot, an arrow to a model output block showing neat JSON, light theme, flat modern style. Negative: gradients, clutter, text errors. Reduced motion: static diagram.

About this pattern

Definition

Few-shot prompting means showing the model a few input and output pairs before the real input. Examples teach the exact format, tone and edge cases better than a description does. Zero examples works for simple tasks; one fixes the format; two or three also show how to handle variation.

When to use it

  • Use two or three varied examples; include one tricky case.
  • Keep format identical across examples: same labels, same field order.
  • Put examples before the real input, separated clearly.
  • Do not make the examples all the same, or the model will copy them.

What the controls do

  • Choose zero, one or three examples and read the illustrative outputs.

Motion & timing

  • The text updates instantly.
  • Reduced motion: nothing animates.

Tips & variations

  • Examples cost tokens in every request; keep them short.
  • Check that examples do not leak private data.

Code of this live preview

HTML
<div class="bx"><div class="pre" id="pre" role="group" aria-label="Examples"><button data-p="0" aria-pressed="true">0 examples</button><button data-p="1" aria-pressed="false">1 example</button><button data-p="2" aria-pressed="false">3 examples</button></div><pre class="pm" id="pm"></pre><div class="rs"><b>Illustrative model output</b><pre id="rs"></pre></div></div>

Related patterns

Role, Context, Task, Format

↗
Role, Context, Task, FormatPrompt Formulas

Prompt Formula Builder

↗
Prompt Formula BuilderPrompt Formulas

Negative Prompt Cleanup

↗
Negative Prompt CleanupPrompt Formulas