Few-shot prompting is a technique where you include a small number of example input and output pairs in the prompt, then add the real input. The model infers the pattern from the examples and applies it, with no change to its weights.
Why it matters
Examples communicate format, tone and edge-case handling more reliably than a long description. Few-shot prompts often improve consistency on classification, extraction and style-matching tasks, and they are far cheaper than fine-tuning. The cost is tokens: every example is sent on every request and occupies part of the context window.
Example
Classify the sentiment as positive, negative or neutral.
Text: "Setup took five minutes." -> positive
Text: "The dashboard keeps timing out." -> negative
Text: "The report is attached." -> neutral
Text: "Alerts arrived late again." ->
The model should answer "negative", copying the label style it saw.
Common mistakes
- Using examples that are all one class, which biases the model toward that label.
- Including inconsistent or mislabelled examples. The model copies mistakes faithfully.
- Adding many examples when two or three diverse ones would do, wasting context and money.
Related
Get notified when this term updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.