One good example beats a paragraph of description

Add examples to a request so the model follows the pattern you want.

Daniel runs customer service for a small online furniture shop in Singapore (an invented example). Every morning 40 or 50 new messages come in. He wants each one tagged delivery, refund, damaged item, product question or other, so his 2 part-timers know which ones to pick up.

He asked an AI assistant to do the sorting and described each category in one sentence. The tags came back inconsistent. A message about a scratched table was tagged "damaged item" on Monday and "refund" on Tuesday. On Wednesday a tag he never asked for, "complaint", appeared. He then deleted the descriptions and pasted in 3 real messages, each with the tag he would have given it. The next batch came back tagged almost exactly as he would have tagged it himself.

Why examples beat descriptions

A language model continues text in the most likely way, given everything in front of it. AI fundamentals lesson 3.2, "It writes by predicting the next token, again and again", explains how this works. This makes a model a strong pattern matcher. When your prompt contains a few input/output pairs, the most likely continuation of a new input is an output in the same pattern.

A description has to be interpreted, and it leaves edge cases open. Take a message saying a table arrived broken that also asks for a refund. A written rule such as "damaged item if the product arrived broken" doesn't settle which tag that message gets. Suppose one of your examples shows a broken table tagged "damaged item" even though the customer mentions a refund. The model picks up that rule without you writing it down, and usually applies it.

This works for more than tagging. An example meeting summary shows the length, headings and level of detail better than a paragraph describing them. A sample product description shows voice, structure and rough word count all at once.

The names for it, and where the examples go

Putting a few worked examples into the prompt is often called few-shot prompting. A prompt with no examples is sometimes called zero-shot, and a prompt with a single example is one-shot. You don't need these terms to use the technique, but they help when you read about prompting or discuss it with colleagues.

The examples go in the prompt itself, every time. Nothing is trained or saved. The model follows the pattern for this one request, and by the next fresh chat it has forgotten the examples. AI fundamentals lesson 5.1, "The context window is the model's only working memory", explains why.

Stopping the model from copying too closely

The risk with examples is that the model copies them closely, including features you didn't mean to teach, such as length, opening style and sign-off. If your example product description is 40 words long, new ones come out at around 40 words (an invented illustration). If an example customer reply ends "Cheers, Daniel", every reply copies it, including replies to a furious customer.

Three habits prevent most of this. First, pick examples that are typical of the bulk of your work, not your most unusual or most impressive one. Say your best-ever product description was for a handmade teak cabinet and ran to 200 words. It makes a poor example for everyday listings, because the new descriptions will lean towards it.

Second, check that your examples agree with your instructions on length, style and so on. When the two conflict, the example usually wins. An instruction to stay "under 80 words" next to a pasted example of 150 words is a typical clash, and the example usually decides the length.

Third, use more than one example. A single example teaches the pattern but also invites the model to copy that example's content. When Daniel gave a single example of a delivery query about a sofa, the model was more likely for a while to tag anything that mentioned a sofa as delivery. Two or three examples that differ from each other in content, length and mood fix most of this. The model can see what they share, which is the pattern to follow, and what varies, which it should not copy. For Daniel's tagging job, the fix is three varied examples: a short angry message about a late delivery, a long polite question about fabric care, and a message about a cracked mirror that also asks for a refund.

Laying out the prompt and checking the results

Start by replacing any category descriptions with real example inputs, each paired with the output you want. Then lay them out so the model can tell the examples apart from the new work. Label each part of every example, for instance with "Message:" and "Tag:". Keep the input and output visibly separate. Mark where the new input starts with a line such as "Now tag these messages:".

Next, check whether the examples are working. A sorting task makes consistency easy to measure. Run the same batch twice and count how many tags change between the two runs. Then compare that with a run that has no examples. If the examples are doing their job, far fewer tags change with them than without them.

Lesson 2.4, "Build an example set for a task you repeat", goes further, with a reusable example set that is properly tested.

That comparison is next: find ten or so real messages, emails or requests you sort by hand, with anything confidential removed, and decide on the categories before you start.

Write a prompt that sorts customer messages into categories. Run it once with no examples and once with three, then compare how consistent the labels are.

Course

Junxiong-WFG Organisation is an authorised representative of AIA Financial Advisers Private Limited (Reg. No. 201715016G).