What is Few-shot Prompting?


Few-shot prompting means giving an AI model several completed examples before asking it to perform a similar task. The examples show the relationship between the input and the output you expect.

This approach is useful when your task depends on a pattern, category system or writing style that is difficult to explain with a short instruction. Select relevant examples and test whether they improve the results.



How few-shot prompting works


A few-shot prompt combines a task description, demonstrations and a new input. Each demonstration should follow the same format. The examples provide context for the current request; they do not permanently train the model.

There is no universal number of examples that works best. Start with a small set that covers meaningful differences. Add another example only when it addresses a failure you have observed, such as confusion between two similar categories.



A practical few-shot prompt


The following fictional example classifies customer requests into a small set of labels. It includes an uncertain case so the prompt does not encourage forced guesses.

Classify the main request in the new message. Use only these labels: Delivery, Billing, Technical support, Other. Return one label only. If the request is too unclear, choose Other.

Input: My parcel has not arrived.
Output: Delivery

Input: I need a copy of my invoice.
Output: Billing

Input: The app closes when I sign in.
Output: Technical support

Input: Can someone contact me about an issue?
Output: Other

New input: The password reset link gives an error.
Output:

Illustrative output: Technical support

The completed pairs show the labels and the expected answer length. The final message is new task input. Review real examples from your own process before adopting the categories.



When should you use few-shot prompting?


  • When a task uses several labels that need clear boundaries.
  • When the output must follow a repeated structure across different inputs.
  • When your organisation has a particular writing style or naming convention.
  • When one demonstration misses important variations or exceptions.

Examples are especially useful when they clarify a decision. Four almost identical examples may be less informative than two normal cases and one carefully chosen boundary case. Avoid adding long background passages that do not help explain the task.



How to build and test your example set


  1. Write the task and define the allowed output.
  2. Choose reviewed examples with consistent answers.
  3. Include the cases that people often confuse.
  4. Reserve a separate set of inputs for testing; do not include their answers in the prompt.
  5. Compare the new prompt with your zero-shot or one-shot baseline.
  6. Record mistakes and revise the smallest part that could explain them.

For a classification task, count correct labels on the reserved sample. For writing tasks, use a short checklist covering facts, tone, structure and usefulness. Review both the average result and any failure that could cause a costly mistake.



Few-shot vs one-shot vs zero-shot prompting


Zero-shot prompting includes no completed examples. One-shot prompting includes one. Few-shot prompting includes several. All three still benefit from clear instructions and relevant source material.

More demonstrations take more space and may increase processing costs in usage-based services. Keep the prompt focused and compare the quality gain with the extra effort needed to maintain it.



Limitations and common mistakes


Contradictory labels, unrealistic examples and repeated wording can teach the wrong pattern within the request. A model may also rely on superficial details, such as a product name, instead of the distinction you wanted to show. Test examples that vary those details.

Do not use a few-shot prompt as a substitute for checking important output. If the task requires reliable structured data, validate the fields and allowed values in the surrounding process. Make sure sample data is approved for the tool you use.



Frequently asked questions


Is few-shot prompting the same as fine-tuning?


No. Few-shot prompting provides examples within the request. Fine-tuning is a separate training process that updates a model using a dataset.


Can few-shot prompting make results worse?


Yes. Poor or conflicting demonstrations can create confusion. Keep an unchanged test set so you can see whether a revision helps or harms your particular task.