Few-shot prompting
Few-shot prompting places a small set of example inputs and outputs in the prompt so the model can imitate the task on a new input.
Few-shot prompting teaches by showing. You put a few solved cases in the prompt, each one an input next to the right output, and then add the new input. The model spots the pattern and answers the same way. When the examples are clear enough, some written instructions can be dropped altogether.
Nothing gets retrained. The GPT-3 paper tested this setup with the model frozen and everything given as plain text. It also named the smaller cases. One-shot means a single example plus a task description. Zero-shot means the description alone.
Which examples you pick matters a lot. One study found that changing the format, the chosen examples, or just their order could move accuracy from near guessing to near the best known score. Part of the reason is bias: models favour answers that sit near the end of the prompt or were common in their training data. So pick varied examples that cover the tricky cases, and test how many you really need.
Instructions alone can leave the intended labels, format, or edge cases ambiguous.
Follow three demonstrations into one new classification.
- 1 · chooseThe developer selects relevant examples that cover the normal case and important variations.
- 2 · pairEach demonstration places a sample input beside the output the application considers correct.
- 3 · appendThe new input follows the demonstrations in the same prompt, without changing the model's weights.
- 4 · completeThe model continues the demonstrated pattern to produce a new output.
Examples are temporary context for this request, not training updates stored in the model.
| Who | What they ask | What it works with |
|---|---|---|
| Support operations | “Which queue should receive this ticket?” | Examples of tickets paired with queue labels |
| Content team | “Rewrite this title in our style” | Before-and-after title pairs |
| Finance team | “Which expense category fits this note?” | Descriptions paired with approved categories |
| Developer tools | “Convert this command into the expected JSON” | Natural-language commands paired with JSON objects |
- It can demonstrate a task through text interaction without gradient updates or fine-tuning.
- Examples can steer formatting, phrasing, scope, and recurring patterns.
- Varied demonstrations can expose edge cases that a short instruction leaves implicit.
- Results can swing with the prompt format, the examples you pick, and even their order.
- Models can lean toward answers placed near the end of the prompt or common in their training data.
- Examples last only for this request; they do not permanently teach the model.
Sources used
This explainer is written in original language. The links below support its factual claims.
- paperLanguage Models are Few-Shot Learners, Brown et al. · read 27 Sept 2026
- docsPrompting best practices, Anthropic · read 27 Sept 2026
- docsPrompt design strategies, Google AI for Developers · read 27 Sept 2026
- docsPrompt engineering, OpenAI · read 27 Sept 2026
- paperCalibrate Before Use: Improving Few-Shot Performance of Language Models, Zhao et al. · read 27 Sept 2026