Skip to content

Techniques · Chapter 3 of 11

Teaching with examples

An example shows what words struggle to describe: a tone, a layout, a level of detail. It also carries everything else in it, which is where the trouble starts.

By Updated

Finn showing three picture cards

When examples help

Reach for examples when you care about form: the exact layout of an entry, the voice of a post, which cases belong to which category. Anthropic calls them a reliable way to steer format, tone and structure Anthropic, and Google names showing the response format as one of their main jobs Google.

Weak

Rewrite these product names in our style.

Better

Rewrite the product names in the same style as these: In: blue kettle, 1.7 litres Out: Kettle · Blue · 1.7 L In: steel pan 24 cm Out: Pan · Steel · 24 cm In: [your list]

A good set of examples

Anthropic recommends three to five examples that are relevant and varied, wrapped in <example> tags so the model doesn't mistake them for instructions Anthropic. OpenAI suggests covering a range of inputs and showing the outputs you want OpenAI, and Google advises one identical layout for every example Google.

  • Typical

    “When does the shop open on Saturdays?”

    Label: question

  • Messy

    “love the new packaging!!”

    Label: praise

  • Tricky

    “Great service, but why was I charged twice?”

    Label: complaint

The tricky case teaches a rule: a problem outranks praise.

Examples inside a prompt

Label each message as question, complaint or praise.

<examples>
<example>
Message: When does the shop open on Saturdays?
Label: question
</example>
<example>
Message: love the new packaging!!
Label: praise
</example>
<example>
Message: Great service, but why was I charged twice?
Label: complaint
</example>
<example>
Message: Third time my parcel arrived damaged.
Label: complaint
</example>
</examples>

Message: [paste the message]
Label:

The traps

  • All examples look alike. The model copies what they share: length, topic, opening words. Vary them on purpose.
  • A mistake gets copied faithfully. Proofread examples more carefully than instructions.
  • Examples that disagree with the instructions. OpenAI warns, for its reasoning models, that mismatches between the two may produce poor results OpenAI.
  • Too many of them. Google warns that with too many examples a model may stick too closely to them (overfitting) Google.
  • Real people in the examples. Swap real names and numbers for invented ones.

With or without examples?

A prompt without examples is called zero-shot, one with a few is few-shot. Here the guides disagree, so test it on your model.

  • Google

    Recommends always including a few examples; prompts without them are likely to work less well.

    Google

  • OpenAI

    For reasoning models, try without examples first and add some only if needed, matching the instructions closely.

    OpenAI

  • Anthropic

    Three to five relevant, varied examples are a reliable way to steer format and tone.

    Anthropic

A practical order: write the instruction, run it on a few real inputs, and add examples where the output misses. Then you know what each example is there to fix.

Sources

Official guides by the model providers. They change as models change, so check them for your model.