B3.2Bloom · ANot started

Few-shots as alternating turns

Reading depth

What you'll learn

Show the model examples as actual conversation turns (user / assistant / user / assistant), not as a list inside one message. It pattern-matches better.

  • Few-shots as alternating user/assistant turns, not as inline bullet lists.
  • Final turn = actual user input, with no example marker.
  • Matches the conversational pattern the model was trained on.

Few-shot prompting works best when the examples are formatted the way the model was trained on — as actual conversation turns, alternating `user` and `assistant`, not as a bulleted list inside a single user message. Claude was trained on `user → assistant → user → assistant` patterns; matching that distribution gets cleaner imitation, more consistent format adherence, and better generalisation to the new input.

The structural shape: instead of a single user message that says 'Here are some examples: 1. … 2. … 3. … Now do this: …', construct a message list where each example is its own user/assistant pair, then the actual question is the final user message. The model sees several rounds of 'this is the input shape, this is the output shape' before being asked to produce the next output.

Why it works: the model is doing pattern continuation. Inline-text examples force the model to first parse the example list, infer the pattern, and then apply it. Conversational-turn examples *are* the pattern, demonstrated in the same shape the model is being asked to extend. The cognitive distance between 'examples' and 'production' shrinks to zero.

Two practical notes. First, the assistant turns in your few-shot pairs are constructed by you (you're putting words in the assistant's mouth) — that's how you show it the desired output. Second, this matters more for tasks with non-trivial output structure (classification with rationale, structured extraction, formatted summaries) than for short open-ended generation. The smaller the output structure, the smaller the win.

Key points

  • Few-shots as alternating user/assistant turns, not as inline bullet lists.
  • Final turn = actual user input, with no example marker.
  • Matches the conversational pattern the model was trained on.
  • Win is biggest for tasks with non-trivial output structure.
  • Author the assistant turns yourself — that's how you demonstrate the desired output.

Examples

Bad: inline bullet list

system: 'Classify the sentiment.' user: 'Examples:\n1. "Loved it." → POS\n2. "Hated it." → NEG\n3. "It was okay." → NEU\n\nNow classify: "Pretty good."' → output is variable; sometimes the model echoes the example format, sometimes not.

Good: alternating turns

system: 'Classify the sentiment.' user: 'Loved it.' / assistant: 'POS' user: 'Hated it.' / assistant: 'NEG' user: 'It was okay.' / assistant: 'NEU' user: 'Pretty good.' → consistent output, model pattern-matches the input→output shape directly.

Pitfalls

  • Sticking examples into the system prompt as bullets. Works, but loses the conversational-pattern advantage.
  • Forgetting that you author the assistant turns in few-shots — they're not real model outputs, they're demonstrations.
  • Using few-shots when the task is very short and structureless ('write a tagline'). Returns are small; not worth the API plumbing.

Source notes: 00-academy-basics/notes/04-claude-api.md

Ask Claude

Build a prompt with this lesson + your question, copy it, and open the Claude Project in a new tab.