Skip to content
AITroveRead. Build. Understand.
Make this comfortable

Few-shot prompting: select examples that cover decisions, not just easy cases

Last updated: 5 Oct 20268 min read
tutorial
IntermediateBy AITrove Editorial

A few-shot set gives the model concrete input-output pairs for the current request. Its value comes from representative decisions and edge cases, not a large stack of similar positive examples. Select cases with distinct failure modes and keep them separate from the item to be classified. Include the negative or abstain case when the task permits uncertainty. If examples contain sensitive data, replace them with synthetic records that preserve the decision structure. Evaluate the prompt on records that were not used as examples.

Decision in practice

A support team classifies refund tickets into approved, denied, or needs-review. Three examples cover a valid 31-day warranty claim, an expired warranty with no exception, and a case where the purchase date is absent. A fourth shows conflicting order identifiers. Each example names the policy field that drove its label. The candidate ticket is placed after the examples with a clear boundary. The team then tests 52 held-out tickets across the same classes, including rare conflicts, instead of scoring the four prompt examples as if they were independent proof of quality.

Output
Example A: purchase age 31 days; policy window 44 days -> approved.
Example B: purchase age 61 days; no exception -> denied.
Example C: purchase date missing -> needs-review.
Candidate: classify ticket RT-582 and name the deciding field.

Performance and operating cost

Each extra example adds input tokens, latency, and sometimes distraction. The total context cost grows with example count and example length, while coverage can plateau or regress. Compare a zero-example baseline with a small, diverse set on the same held-out cases. If the task changes, refresh examples and evaluation together but preserve a stable core set for comparison. An example is a teaching artifact, not a policy source: the current policy still controls the answer.

Common Mistakes

  • Do not choose only favorable examples.
  • Do not leak the evaluation answer into the prompt examples.
  • Do not let an old example override the current policy.

Connected lessons

Continue with: Few-shot examples: teach the boundary with near misses.

prompt engineering
tutorial
Storage details