Few-shot prompting means showing the model a handful of input–output examples before the real input, so it infers the pattern you want. It is one of the most reliable ways to lift quality on a fiddly task — and one of the easiest to overuse, because every example is tokens you pay for on every call.
When few-shot earns its tokens
Reach for examples when the task is hard to describe but easy to demonstrate: a specific output format, a labelling scheme with subtle boundaries, a tone that is easier to show than to specify. If a clear instruction and a schema already get you there, stay zero-shot — modern models follow instructions well, and needless examples just add cost and latency.
Choosing the examples
Example quality dominates example quantity. Three well-chosen examples usually beat ten sloppy ones.
- Cover the boundaries — include the tricky and ambiguous cases, not just the obvious ones, because those are where the model needs the demonstration most.
- Be diverse — near-duplicate examples waste tokens teaching the same thing twice.
- Be correct — a single wrong example is worse than none; the model will faithfully imitate the mistake.
- Match the real distribution — examples should look like the inputs you actually get.
Consistency and ordering
Every example must use the exact format you expect back — same field names, same structure, same style. Inconsistency in the examples produces inconsistency in the output. Ordering has a smaller but real effect; a common, safe default is to put the most representative example last, closest to the real input.
Retrieve examples dynamically
The advanced move is to stop hardcoding examples and select them per request. Keep a bank of labelled examples, embed the incoming input, and retrieve the few most similar ones to include in the prompt. This dynamic few-shot approach adapts the demonstration to each input and often beats any fixed set — it is retrieval-augmented prompting applied to examples rather than documents.
Few-shot examples are prepended to every single call, so five long examples can dwarf the actual user input in tokens. Provider prompt caching helps when the example block is stable, but the discipline still holds: use the fewest examples that reach your quality bar, and measure whether each one is earning its place.
Treat few-shot as a dial, not a default. Start zero-shot, add examples only where they measurably help on your eval set, keep them correct and consistent, and graduate to dynamic retrieval when a fixed set can no longer cover the range of inputs you see.
Independent software engineer in Nairobi specialising in Acumatica customisations, Laravel backends, and tax fiscalisation integrations across East and Southern Africa.