Sometimes it is hard to explain what you want and easy to show it. Few-shot promptingFew-shot promptingPutting two to five examples of an input and its output in the prompt, so the model follows the same pattern. Varied, correct examples teach more than long instructions. puts one or more examples of input and desired output in the promptPromptThe text you give a model to work on, from a short question to long instructions with a role, context, examples and a required format. The quality of the output follows the clarity of the prompt more than its length., so the model picks up the pattern and applies it to new input.
Start without examples
Modern models follow instructions well, and many tasks work with a clear prompt alone (zero-shotZero-shot promptingAsking for a task with instructions alone, without any example. It is enough for common, clear tasks and weakens when the format you need is your own.). Start there; add examples when the output is inconsistent or in a style you do not want.
When to add examples
- The output has a specific shape: fixed labels, a table with set columns.
- You want a style that is hard to describe.
- Edge cases matter: a message with both a complaint and praise.
Example: classifying customer messages
Classify the customer's message as one of: complaint, question, request, thanks.
Write the label only.
Message: The order arrived two days late and the box was broken.
Label: complaint
Message: Do you deliver to Tangier?
Label: question
Message: Thanks, great service, but I want to change the address for my next order.
Label: request
Message: {{message}}
Label:The third example teaches a rule you never wrote: when thanks and a request come together, the request wins.
Choosing examples
Vary them; balance the labels; make sure each is correct; keep the same format in every example; and stay at three to five, since every tokenTokenThe unit a model reads and writes text in, which may be a word, part of one or a punctuation mark. Prices and context limits are counted in tokens, and Arabic text often needs more tokens than English of the same length. costs.
A common mistake: literal copying
The model may copy details you did not intend: length, a repeated word, a city name. Vary those details, or say the examples show the format, not the content.
Examples and real data
Never put real customer data in examples. The prompt goes to the model provider and may end up in a log or shared with a colleague. Test the prompt with and without examples on ten anonymised real messages and let the numbers decide.