Few-shot examples: showing instead of telling
Why two or three worked examples in a prompt often beat a page of written rules, and how to choose examples that teach the right pattern and not an accidental one.
Describing a format in words makes the model infer your intent from a description. Show two or three examples of the input and the exact output you want, and it copies the pattern directly.
Why it beats more instructions
A rule such as format dates as ISO 8601, keep names in their original script, and omit empty fields asks the model to remember and apply three things every time. One example that already does all three teaches the same lesson in a form it pattern-matches against.
How many
Two or three is usually enough. A single example risks the model copying incidental details of that one case, a specific number or a particular phrasing, as if they belonged to the rule. Past three or four, extra examples mostly cost tokens, unless the task has that many distinct cases.
Picking examples that teach the right thing
Choose examples that differ in the parts that should vary and match in the parts that should not. If every example happens to be a short input, the model may decide that short inputs belong to the pattern. Vary the length, vary the edge cases, and keep the format identical across all of them.
Where to put them
Place them after the instruction and before the real input, clearly separated: a heading such as Examples, then the real task under Now do this. Mixed together with the instructions, they are harder to tell apart.
When not to bother
If the task has an obvious standard shape, such as translate this to French, examples add tokens and no clarity. Save them for a specific, non-obvious format: an unusual output structure, a house style, a classification full of edge cases.
Notes from the author
When output comes back close but formatted wrong, swap the format description for one worked example before you add a fourth paragraph of rules.
For information only, not professional advice. You use it at your own risk and we are not liable for any loss or damage. See the disclaimer.
Tagged