PromptKitHub guide

Few-Shot Prompting: Use Examples to Guide AI Output

Examples can be more precise than a long list of instructions. Few-shot prompting means showing an AI assistant a small number of input-and-output examples so it can infer the pattern you want. The technique is useful when the format, tone or decision rule is difficult to describe in words.

Quick takeaway: Use this approach when you need repeatable formatting, classification, rewriting or extraction and a simple instruction keeps producing inconsistent results.

1. Define the target pattern

Write down what the assistant should do and what a successful result looks like. If you cannot describe the desired output, adding examples will not solve the underlying ambiguity.

2. Choose representative examples

Pick examples that cover the normal case and, when useful, one edge case. Prefer real examples that reflect the task rather than polished examples that hide important details.

3. Keep examples consistent

Use the same labels, field names and output structure in every example. Small inconsistencies can teach the wrong pattern.

4. Add the new input last

Separate the examples from the live task with clear labels. Tell the assistant to apply the demonstrated pattern to the new input rather than copying the examples.

5. Review for pattern drift

Check whether the output follows the demonstrated rule or simply imitates surface wording. If it drifts, simplify the examples or make the rule more explicit.

Example: classify support requests

Instead of saying “categorize these messages,” provide two or three labeled examples such as “I cannot reset my password” → Account access, then give the new message. Keep the labels fixed and ask for only the category plus a short reason.

Example prompt
Task: classify each customer message into one of these labels: Account access, Billing, Technical issue, or Other.

Example 1:
Message: “My password reset link has expired.”
Label: Account access

Example 2:
Message: “I was charged twice for the same month.”
Label: Billing

Now classify the new message. Return only the label and one-sentence reason.

Common mistakes

FAQ

Do I always need examples?

No. If the task is simple and the output format is obvious, a clear instruction may be enough.

How many examples should I use?

Start with a small set. Add another example only when it covers a meaningful case that the current prompt misses.

Practical next step: Try the workflow with one real task. Keep the source material visible, save the prompt that works and note what you still had to correct by hand.