Zero-Shot: No Examples Needed
A zero-shot prompt is a request with no demonstration examples. You describe the task and expect the model to handle it from its training.
Modern large language models (GPT-4, Claude, Gemini) perform well on zero-shot tasks thanks to the scale of their training.
Zero-shot classification example:
Classify the sentiment of the following review. Reply with one word: positive, negative, or neutral.
Review: "Delivery arrived on time, the product matches the description, but the packaging was slightly dented."
For clearly defined tasks with an obvious format, zero-shot works great.
Few-Shot: Learning by Example
Few-shot prompting means showing the model several input → expected output pairs before your actual request. The model recognises the pattern and applies it.
Weak few-shot (inconsistent format):
Question: Capital of France?
Answer: Paris is a beautiful city on the Seine.
Q: Capital of Germany?
A: Berlin
Question: Capital of Japan?
Problem: format shifts (Question/Answer vs. Q/A), answer lengths vary. The model doesn't know which pattern to follow.
Strong few-shot (consistent format):
Classify the news article by topic. Topics: Sports, Technology, Politics, Culture.
Article: "Apple unveiled a new M4 chip for the MacBook Pro."
Topic: Technology
Article: "Brazil's national team reached the World Cup final."
Topic: Sports
Article: "The government approved the new 2025 budget."
Topic: Politics
Article: "The film 'Dune' won three Academy Awards."
Topic:
A single consistent pattern (Article / Topic) with three examples clearly establishes what to do.
How Many Examples?
- 1–2 examples — enough to set the format
- 3–5 examples — optimal for most tasks
- 6+ examples — only for complex or highly non-standard tasks
More examples aren't always better. Two great examples outperform eight mediocre ones.
When Few-Shot Is Essential
Few-shot particularly helps when:
- The task requires a non-standard output format
- A specific style or tone is needed
- Classification uses custom categories
- Data extraction must follow a precise structure
Example: extracting data in a specific format:
Extract the name, title, and company from the text. Format: JSON.
Text: "Meeting with Anna Petrova, VP of Marketing at TechStart, went well."
Result: {"name": "Anna Petrova", "title": "VP of Marketing", "company": "TechStart"}
Text: "Ivan Sokolov, senior developer at DataFlow, presented a new product."
Result: {"name": "Ivan Sokolov", "title": "senior developer", "company": "DataFlow"}
Text: "Maria Ivanova, CEO of CloudBase, raised a $5M Series A."
Result:
Example Order Matters
Research shows that examples placed closer to the end of the prompt have more influence on the response. Put your most representative example last.