Day 03·Show and shape·2 min read

Zero-shot and few-shot prompting

Examples are the strongest way to show a model what good looks like, and the model copies whatever those examples have in common. Choose them as carefully as the instructions.

By the end

Build a few-shot prompt that teaches a behaviour, recognise anchoring from lopsided or repetitive examples, and label examples so they are not copied as templates.

Examples are the strongest way to show a model what good looks like. The model copies whatever the examples have in common, including things you did not mean to teach. Choose them as carefully as you choose the instructions.

Learn

  • Zero-shot is instructions only. One-shot and few-shot add one to five input and output examples. This is in-context learning: no weights change.
  • What transfers. Format, length, tone, structure and reasoning style all carry over. If your examples run 12 words, expect 12-word slogans.
  • Anchoring. Outputs drift toward the examples' wording and themes. Diverse examples, with different tones, angles and lengths inside the limit, widen the output range.
  • Order and balance. The last example pulls hardest, and lopsided labels bias classifiers.
  • Edge cases. Include the hard case you care about, such as an ambiguous query answered with a clarifying question.
  • Label them. Wrap examples in tags and say they illustrate quality, not a template to copy.

Drill

  1. Build a 3-shot prompt for a support bot where each example is a vague query answered with a clarifying question.
  2. Run 10 vague queries through it and through a zero-shot version.
  3. Swap in three examples with the same tone and see how much the outputs converge.

Check yourself

  • When can few-shot examples make output more formulaic, not less?
  • Why should examples obey every constraint the output must obey?

Test yourself

6 multiple-choice questions and 9 flashcards on this lesson, shuffled every time, with the reason behind every answer.