Few-shot prompts: show task rules across several examples
A few-shot prompt gives a model several examples of task inputs and desired outputs alongside the instructions. Zero-shot has no task examples; one-shot has one. Multiple examples can show different input types and decision boundaries, but adding more does not automatically improve accuracy. State the criteria first, choose representative and consistent examples, and compare results on the same evaluation data.
A few-shot prompt gives a model several examples of task inputs and desired outputs alongside the instructions. Zero-shot has no task examples; one-shot has one. Multiple examples can show different input types and decision boundaries, but adding more does not automatically improve accuracy. State the criteria first, choose representative and consistent examples, and compare results on the same evaluation data.
How many examples count as few-shot?
Few-shot means multiple in-prompt demonstrations, but there is no single example-count threshold used by every paper or service. The GPT-3 study distinguished zero-, one-, and few-shot evaluation by the number of demonstrations; its few-shot condition typically used dozens of examples depending on the task. In everyday API use, “few-shot” often refers to a small number, so record the actual number instead of treating “few” as a fixed count.
Examples are context that guides the current request. Putting examples in an API prompt is generally different from updating model parameters through training. Few-shot does not mean the model permanently stores the demonstrations.
How should you choose examples?
Before collecting many examples, list the input types and decisions the model must distinguish. Choose examples that make those distinctions concrete.
| Selection criterion | Check | Customer sentiment example |
|---|---|---|
| Coverage | Are important input types included? | Positive, negative, neutral, and mixed sentiment |
| Boundaries | Do examples distinguish confusing categories? | Clarify how to handle praise mixed with a complaint |
| Label reliability | Would reviewers agree with the expected answer? | Apply the label rules; flag genuinely ambiguous cases |
| Variation | Are lengths and wording varied? | Include short messages and complete sentences |
| Format consistency | Do all outputs follow the same contract? | JSON with only the specified keys and values |
Suppose the task is to classify a customer message as positive, neutral, or negative and return JSON. Demonstrations should cover different sentiments. Their labels must follow the written definitions, and the prompt should define whether mixed sentiment or uncertainty is allowed. If examples silently apply different rules, adding more can increase confusion.
A short demonstration set might look like this:
Example 1 input: “Thanks for resolving this so quickly.”
Example 1 output: {"label":"positive"}
Example 2 input: “This is my third message and I still have no answer.”
Example 2 output: {"label":"negative"}
Example 3 input: “My order number is 1842.”
Example 3 output: {"label":"neutral"}
New message: “<message to classify>”This illustrates a format; it is not a complete production labeling policy. Define neutral sentiment, mixed cases, and uncertainty according to the service’s purpose.
Which should you choose: zero-shot, one-shot, or few-shot?
First see whether clear instructions are enough. Zero-shot is a concise baseline when the criteria are easy to state. Compare one-shot when a single example clarifies a key pattern. Use several examples when the task spans multiple input types or decision boundaries.
OpenAI’s prompt guidance recommends varied possible inputs and examples that closely match the instructions. For reasoning models, it also suggests starting without examples and adding them if complex output requirements remain. The right choice can vary by model, so evaluate with the model you will use.
| Method | Task examples | Consider when | Cost or limitation |
|---|---|---|---|
| Zero-shot | 0 | Rules can be stated directly | The model may infer unstated rules |
| One-shot | 1 | One case demonstrates the output pattern | A single case may not cover varied inputs |
| Few-shot | Several | Several input types or boundaries need demonstration | Longer context and more example maintenance |
This is a practical guide, not a performance forecast. Review actual outputs and context limits; example count alone does not determine quality or cost.
How can you evaluate a few-shot prompt?
Use evaluation inputs separate from the demonstrations and compare with a zero-shot baseline:
Prepare representative and ambiguous cases, with expected answers and review criteria.
Run zero-shot on the same model version, settings, and evaluation inputs.
Identify recurring error types, then choose examples that address those distinctions.
Run few-shot with the same settings and compare label accuracy, output validity, uncertainty handling, and errors by input type.
Record the change across the full evaluation set and recheck regression cases before deployment.
This is an illustrative evaluation procedure, not a test performed here or a measured result. Real evaluation needs reference answers and criteria that reflect the costs of errors. For subjective tasks, do not turn disputed labels into certain ground truth without review.
What if adding examples does not help?
Check clarity and example quality before increasing the count. Ask whether label definitions are vague, examples contradict each other, the examples differ from real user wording, or the output format is inconsistent. Remove weak cases or replace them with examples for recurring boundaries, then compare on the same evaluation set.
More examples use more prompt context and require more maintenance. Choose representative cases rather than including everything; keep background text limited to what the task needs. If the task requires many source documents or current information, consider whether adding demonstrations is the right solution.
Prompt examples do not replace application safeguards. Implement input validation, server-side authorization, structured-output validation, and review of consequential results in the application.
Takeaway
Few-shot prompting uses several in-context demonstrations to show task rules and variation. Define the decision criteria first, then provide diverse examples with consistent labels and formats. Compare with a zero-shot baseline on the same evaluation data to see whether the examples actually help.
References
[OpenAI API: Prompt engineering](https://developers.openai.com/api/docs/guides/prompt-engineering) — describes few-shot examples, varied inputs and consistency with instructions.
[OpenAI API: Reasoning best practices](https://developers.openai.com/api/docs/guides/reasoning-best-practices) — recommends trying reasoning models without examples first and adding them for complex requirements when useful.
[Brown et al., Language Models are Few-Shot Learners (2020)](https://arxiv.org/abs/2005.14165) — distinguishes zero-, one-, and few-shot and reports task-specific results and limits.