Few-shot prompting
Definition
Including a few input and output examples in the prompt so the model can copy their pattern, format and level of detail.
In more detail
Examples are the most direct way to show format, tone and edge-case handling. Choose varied examples, because models copy surface features: if every example is short, outputs will be short too.
Three to five examples are often enough. Put them in a clearly marked block, label inputs and outputs consistently, and include at least one tricky case, such as an input that should be refused or a field that should be left empty. Few-shot examples cost tokens on every request, so move stable examples to the start of the prompt where prompt caching can reuse them, and check with an eval whether they still help when you switch to a stronger model.
Related terms
Prompt engineering
Designing, testing and refining prompts so a model produces the output you need reliably, across many inputs and not just one.
Zero-shot prompting
Asking a model to perform a task from instructions alone, without giving it any worked examples of the inputs and outputs.
Prompt template
A prompt with placeholders, such as {question} or {context}, that code fills in at run time so the instructions are reused.
Read more about Few-shot prompting
- Prompting fundamentals: clear tasks, examples and formats
How to write a good prompt: frame the task, say who the output is for, show an example and specify the format, so a model's answers are useful and repeatable.
- Prompt patterns cheat sheet
Copyable prompt patterns for Claude, ChatGPT and Gemini: briefing, examples, output formats, long documents, checking the work and avoiding made-up answers.
- Prompt engineering
Writing clear, testable instructions for models and checking them on real inputs.