Describing the output you want works up to a point. Showing it works better, and it makes the answer easier to read by a program. This guide covers when to add an example and how many.

Zero-shot: no examples

A zero-shot prompt only describes the task. It is the right place to start, because it is the shortest and often enough.

Extract the keywords from the text below.

Text: {{text}}
Keywords:

Few-shot: a couple of examples

If the answer comes back in the wrong shape, add one or two examples. OpenAI’s order is: try zero-shot, then few-shot, and consider fine-tuning only if neither works. Each example shows an input and the output you want.

Extract keywords from each text.

Text 1: Stripe provides APIs that developers use to take payments.
Keywords 1: Stripe, payments, APIs, developers
##
Text 2: {{text}}
Keywords 2:

Show the format, not just describe it

OpenAI’s example is entity extraction. Instead of listing four entity types in a sentence, it lays out the exact format.

Desired format:
Company names: <comma separated list>
People names: <comma separated list>
Topics: <comma separated list>

Anthropic and Atlassian give the same advice: examples guide the model, and Atlassian suggests giving a sample of the tone and style you want for open-ended writing.

Keep examples honest

  • Make them match the real task. An example for a different job teaches the wrong pattern.
  • Keep them short, and show the range if inputs vary.
  • Do not put real names, keys or customer data in them. Use placeholders.
  • Mark them off from the instructions, with a heading or a tag.

Let Promptor remind you

When you ask for structured output (JSON, a table, extracted fields) and show no example, Promptor suggests adding one. It leaves the choice to you: if the answer is already right, you do not need one.