Few-Shot Prompting: Definition and Examples
Few-shot prompting provides a few examples (2-5) in your prompt to show the AI the expected format, tone, or type of response, without fine-tuning.
Full definition
Few-shot is one of the most powerful prompt engineering techniques. Instead of describing what you want, you show the expected result through concrete examples.
The principle: include 2-5 input/output pairs before your actual query. The model detects the pattern and applies it.
Few-shot differs from zero-shot (no examples) and one-shot (single example). Beyond 5 examples, gains are often marginal.
Example quality is crucial: representative, consistent, error-free. A bad example teaches bad habits.
Etymology
Comes from machine learning (few-shot learning). Popularized by the GPT-3 paper (2020) demonstrating in-context learning.
Concrete examples
Sentiment classification with 3 examples
Classify the sentiment:
Review: "Fast delivery"
Sentiment: Positive
Review: "Damaged package"
Sentiment: Negative
Review: "Customer service was incredible"
Sentiment:
Structured data extraction
Extract the info:
Text: "Marie Dupont - Marketing Dir. - Acme SAS"
JSON: {"name":"Marie Dupont","position":"Marketing Dir."}
Text: "Jean Martin, CTO @ StartupXYZ"
JSON:
Technical rewriting into plain language
Practical usage
Use few-shot when a simple instruction isn't enough. Choose 2-3 varied examples. Place them just before your query.
Related concepts
FAQ
How many examples in few-shot?
Few-shot or fine-tuning?
Does the order of examples matter?
See also
How to use this prompt
- Copy the prompt with the button above.
- Paste it into ChatGPT, Claude or your favorite AI assistant.
- Replace the bracketed variables with your details, then refine the result.
About Prompt Guide
Prompt Guide is a free library of 2500+ ready-to-use prompts for ChatGPT, Claude and other AIs, with guides to learn prompting and tools to build and optimize your own prompts.
More definitions
Fine Tuning: Definition and Examples
Fine tuning is the process of adjusting a pre-trained AI model on a specific dataset to improve its performance for a particular task or
Flash Attention: Definition and Examples
Flash Attention is an optimized algorithm for computing the attention mechanism in Transformers, drastically reducing memory consumption and accelerating...
Frequency Penalty: Definition and Examples
The Frequency Penalty is a language model parameter that penalizes tokens proportionally to the number of times they appear in the generated text
Function Calling: Definition and Examples
Function Calling is a capability of language models (LLMs) that allows them to identify when to call an external function and generate the required arguments.
Function Grounding: Definition and Examples
Function Grounding is a technique that anchors an AI model's responses in executable functions or tools, allowing it to interact with systems
GDPR AI: Definition and Examples
GDPR AI refers to the application of the General Data Protection Regulation to artificial intelligence systems, governing the collection, processing, and use of personal data by AI algorithms and models.
Get new prompts every week
Join our newsletter.