Few-shot Prompting: Teaching AI by Example, Done Properly

Plants.work · · upskilling
Few-shot Prompting: Teaching AI by Example, Done Properly

How to choose examples that teach AI the pattern you want: how many, how to format them, and the traps that make AI copy the wrong thing.

A marketing team wants AI to write post captions in the brand's style. They describe the tone in three paragraphs: "friendly but not silly", "professional but not stiff". The results still miss. Then someone pastes in three old captions that customers loved, and the output is suddenly close. That is the power of few-shot prompting, and also where it goes wrong if you choose poor examples.

What is few-shot prompting?

Few-shot prompting (some documentation calls it multishot) means placing "input and desired answer" example pairs in the prompt so the model picks up the pattern and follows it, without retraining the model. Anthropic's prompting guide says a few well-crafted examples improve both accuracy and consistency. Our basic Prompt Engineering article introduced the technique briefly. This one goes deeper into choosing and arranging examples.

How to choose examples that work

Quantity: start with 3 to 5

Anthropic recommends 3 to 5 examples for best results. Too few and the model cannot see the pattern. Too many and you spend context for nothing.

Match the real task

Examples should look like the inputs you will really receive. If the real task is customer reviews in mixed Thai and English, your examples should be too.

Diverse enough

Anthropic advises covering edge cases and varying examples enough that the model does not pick up "unintended patterns". If every example is two lines long and starts with an emoji, the model will do that every time, even if you never wanted it.

Canonical, not a pile of rules

Anthropic's context engineering article recommends a set of diverse, canonical examples instead of writing a rule for every edge case, because examples show the desired behaviour more clearly.

Format examples so the model is not confused

Example: categorising skills from a resume

Categorise the following skill as Hard skill, Soft skill or Tool <examples> <example>Skill: data analysis with SQL / Category: Hard skill</example> <example>Skill: Figma / Category: Tool</example> <example>Skill: negotiating with suppliers / Category: Soft skill</example> </examples> Skill: building Pivot Tables in Excel

Notice the examples mix short tool names with longer phrases (and, in the Thai version, Thai with English), so the model does not latch on to input length or language.

Few-shot and reasoning models

OpenAI's reasoning best practices guide recommends trying zero-shot first with models that reason internally, and adding examples only if needed, keeping them closely aligned with your instructions. Anthropic's documentation notes that examples still work well with extended thinking when they show the problem, the method and the answer.

Three well-chosen examples teach AI more than three pages of rules nobody reads to the end.

Things to watch out for

How to start

  1. Collect 5 to 10 outputs you are genuinely happy with from a task you repeat often.
  2. Pick the 3 to 5 that differ most while still representing the real task.
  3. Format them identically and wrap them in tags.
  4. Test with new inputs. If the model copies the wrong thing, swap or replace the example that causes that pattern.

To see how good example answers help with career tasks, try Resume Lab to improve your resume, or practise interview answers with Interview Lab.