P

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

Zero-shotOne-shotIn-context learningChain-of-thought

FAQ

How many examples in few-shot?
2-5 are enough. Simple tasks: 2. Complex tasks: 3-5. Beyond 5, marginal gains.
Few-shot or fine-tuning?
Few-shot first — fast, free, flexible. Fine-tuning if you have thousands of examples or a very specialized domain.
Does the order of examples matter?
Yes. The last example has more influence (recency bias). Place the most representative one last.

See also

How to use this prompt

  1. Copy the prompt with the button above.
  2. Paste it into ChatGPT, Claude or your favorite AI assistant.
  3. 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

Get new prompts every week

Join our newsletter.