Few-Shot Prompting: Teach AI with Examples That Work
Telling AI what you want in words is often less effective than showing it. Few-shot prompting means giving the model two or three examples of the input and the output you expect, then asking it to continue the pattern. Done well, it produces consistent results with far less instruction. Done badly, it teaches the model the wrong pattern with great confidence, which is worse than no examples at all.
1. Why examples beat instructions
Instructions describe a rule; examples demonstrate it. A rule like write in a friendly professional tone leaves room for interpretation, while two examples of friendly professional emails show exactly what you mean: sentence length, greeting style, sign-off, and level of formality. The model copies the pattern it sees, including details you would never think to specify.
Examples also solve the vocabulary problem. Different people mean different things by concise, detailed, or formal. An example removes the ambiguity, because the model matches the example rather than guessing your definition. When instructions keep failing, examples usually fix the problem faster than longer instructions.
2. Pick examples that differ in content, not in form
The examples you choose teach two things at once: the form to copy and the content to vary. If all three examples are about the same topic, the model may conclude the topic is part of the pattern and repeat it. If the examples cover different topics but share the same form, the model learns the form and varies the topic correctly.
Choose examples that are typical of what you want, not exceptional. One brilliant example and two average ones teach a mixed pattern. Three solid, ordinary examples teach a reliable pattern. Save your best examples as a reusable set, because a good few-shot set is an asset you will use repeatedly.
3. Use two to four examples, in the right order
Two examples are usually enough for simple patterns, and four cover most complex ones. Beyond five, returns diminish and the prompt gets long enough to confuse the model or waste context. Start with three and add a fourth only when the output still misses a specific aspect of the pattern.
Order matters more than people expect. Models weigh recent examples more heavily, so put your strongest example last, closest to the new task. Also keep the format of each example identical: same labels, same order, same punctuation. Inconsistent formatting teaches the model that formatting does not matter, and then it varies the format randomly.
4. Label the parts the model must notice
Clear labels help the model see the structure. Use consistent markers such as Input and Output, or Question and Answer, and keep them identical across examples. Labels act as signposts: they tell the model where the example ends and the new task begins, which prevents it from continuing an example instead of answering your request.
Label the tricky parts explicitly when they matter. If the output must include a specific field, or must avoid a specific phrase, make that visible in the examples rather than hiding it in a separate instruction. The model learns from what the examples consistently do, so consistency in the examples is the instruction.
5. Test the set before you trust it
Test a few-shot set with three new inputs before using it for real work. Check whether the outputs follow the pattern, whether the form stays stable, and whether any example detail leaked into the answers. Leaked details, such as a name or a figure from an example appearing in a new answer, signal that the examples are too similar or too few.
When a test fails, change one thing at a time: swap one example, adjust the order, or clarify a label. Changing everything at once hides the cause. Our guide to prompt basics covers testing discipline, and our guide to consistent results explains how few-shot sets fit into a broader reliability routine.
6. Combine few-shot with a short instruction
Few-shot works best with a brief instruction, not instead of one. One sentence stating the task, followed by the examples, gives the model both the goal and the pattern. The instruction sets direction; the examples set the standard. Either alone is weaker than both together.
Keep the instruction short. A long instruction plus long examples creates a prompt where the model must weigh two competing sources of guidance. One clear sentence is enough. For more advanced combinations, persona and role prompts pair well with few-shot sets when you need a consistent voice as well as a consistent form.
Bottom line: Bottom line: Show two to four varied examples in identical format, strongest last, test on new inputs, and add one short instruction. Examples teach patterns that words alone cannot.