HomeGuides › Few-Shot Prompting
Prompt Engineering

Few-Shot Prompting:
Complete Guide + 30 Real Examples

Few-shot prompting is one of the most reliable techniques for getting exactly the output format and quality you need from AI. By showing the model 2-5 examples before asking your question, you dramatically improve consistency and precision. Here's everything you need to know, with 30 ready-to-use examples.

What Is Few-Shot Prompting?

Few-shot prompting means including 2-5 worked examples in your prompt before asking the model your actual question. Each example shows the model the input format, the expected output format, and the quality standard you want. The model learns from these examples in real-time and applies the same pattern to your request.

It's called "few-shot" because you're giving the model "a few shots" (examples) to learn from. Compare to:

❌ Zero-Shot (Inconsistent)
Classify this review as positive, negative, or neutral: "The delivery was late but the product itself is good."
✅ Few-Shot (Consistent)
Classify reviews as positive, negative, or neutral. Review: "Love this product!" Label: positive Review: "Never arrived, waste of money" Label: negative Review: "It's okay, nothing special" Label: neutral Review: "The delivery was late but the product itself is good." Label:

When to Use Few-Shot (vs. Zero-Shot)

Use few-shot prompting when:

Stick with zero-shot when:

The Universal Few-Shot Template

Universal Few-Shot Template (copy & customize)
Here are examples of how to complete this task: --- Input: [Example input 1] Output: [Perfect example output 1] --- Input: [Example input 2] Output: [Perfect example output 2] --- Input: [Example input 3] Output: [Perfect example output 3] --- Now complete the task for this input: Input: [Your actual input] Output:

30 Few-Shot Examples by Category

Sentiment Classification

Few-Shot Sentiment Analysis
Classify the sentiment and extract the main topic from customer reviews. --- Review: "I've been using this blender for 3 months and it's broken already. Very disappointed." Sentiment: NEGATIVE | Topic: Product durability --- Review: "Arrived 2 days early and the packaging was perfect. Exactly what I ordered!" Sentiment: POSITIVE | Topic: Shipping and packaging --- Review: "It works fine but the instruction manual is confusing and the customer service took 3 days to respond." Sentiment: MIXED | Topic: Documentation and support --- Now classify: Review: "[PASTE YOUR REVIEW]" Sentiment:

Email Tone Transformation

Few-Shot Tone Rewriter
Rewrite emails to be professional but warm — not cold/formal, not too casual. Keep the core message identical. --- Formal: "We regret to inform you that your request cannot be processed at this time due to internal constraints." Warm-Professional: "I'm sorry, but we're not able to process this request right now — we've hit an internal bottleneck. I'll personally follow up with you as soon as that clears, which should be by end of week." --- Formal: "Please be advised that the meeting has been rescheduled to accommodate all stakeholder schedules." Warm-Professional: "Quick heads up — we moved the meeting to make it work for everyone. I've updated the invite, so you should see the new time in your calendar shortly." --- Now rewrite: Formal: "[PASTE FORMAL EMAIL]" Warm-Professional:

Structured Data Extraction

Few-Shot Data Extraction
Extract structured data from job postings into JSON format. --- Posting: "Senior Product Designer at TechCorp. San Francisco or Remote. $140K-$180K. 5+ years experience required. Benefits include health, dental, 4 weeks PTO. Apply by July 30th." JSON: {"title":"Senior Product Designer","company":"TechCorp","location":"San Francisco or Remote","salary_range":"$140K-$180K","min_experience_years":5,"benefits":["health","dental","4 weeks PTO"],"application_deadline":"July 30"} --- Posting: "Marketing Coordinator needed in Chicago. Entry level, $45K starting. Full-time. Great culture!" JSON: {"title":"Marketing Coordinator","company":null,"location":"Chicago","salary_range":"$45K","min_experience_years":0,"benefits":[],"application_deadline":null} --- Now extract: Posting: "[PASTE YOUR JOB POSTING]" JSON:

Brand Voice Application

Few-Shot Brand Voice
Write product descriptions in our brand voice: bold, direct, slightly irreverent, never corporate. --- Product: A boring black office chair Our version: "Chairs that try too hard are uncomfortable in every way. This one just works — eight hours in, you won't remember you're sitting." --- Product: A 15-inch laptop bag Our version: "Your laptop doesn't need a bag. You need a bag that happens to fit your laptop. And your charger. And your lunch. This is that bag." --- Now write in our brand voice: Product: [YOUR PRODUCT] Our version:

Common Few-Shot Mistakes to Avoid

Advanced: Dynamic Few-Shot Selection

Once you understand basic few-shot prompting, the next level is dynamic example selection — choosing different examples depending on the specific input you're working with. This is how production AI systems use few-shot prompting at scale.

Instead of always using the same 3 examples, you build a library of 20-50 high-quality examples and select the 3 most similar to your current input. The examples closest to your actual input consistently outperform generic examples, because they set the right pattern for the specific task variant you're working on.

Dynamic Few-Shot Meta-Prompt
I need you to classify [TASK TYPE]. Before I give you the example set, select the 3 most relevant examples from what I'm about to provide, based on their similarity to the actual input. My full example library: [EXAMPLE 1: Input / Output] [EXAMPLE 2: Input / Output] [EXAMPLE 3: Input / Output] [EXAMPLE 4: Input / Output] [EXAMPLE 5: Input / Output] [... up to 20 examples ...] My actual input: [ACTUAL INPUT] Step 1: Identify the 3 examples from my library most similar to the actual input. Step 2: Apply the pattern from those 3 examples to the actual input. Step 3: Produce the output.

Few-Shot vs Chain-of-Thought: When to Combine

Few-shot prompting and chain-of-thought prompting are complementary techniques. The most powerful approach is few-shot chain-of-thought — providing examples that show not just the input/output pair, but also the reasoning steps in between.

Few-Shot + Chain-of-Thought (The Most Powerful Combination)
Solve math word problems by showing your reasoning before the answer. --- Problem: A bakery made 120 cookies. They sold 45 on Monday and 38 on Tuesday. On Wednesday they made 60 more. How many cookies do they have? Reasoning: Start with 120. After Monday: 120 - 45 = 75. After Tuesday: 75 - 38 = 37. After Wednesday's batch: 37 + 60 = 97. Answer: 97 cookies --- Problem: A train leaves at 9:15am and arrives at 2:45pm. If it stops for 20 minutes total, how long is the actual travel time? Reasoning: Total time from 9:15am to 2:45pm = 5 hours 30 minutes = 330 minutes. Subtract stops: 330 - 20 = 310 minutes = 5 hours 10 minutes. Answer: 5 hours and 10 minutes --- Now solve: Problem: [YOUR PROBLEM] Reasoning:

Real-World Application: Building Your Own Example Library

The most valuable thing you can do with few-shot prompting is build a personal library of high-quality input/output examples for your most common tasks. This library becomes a reusable asset that improves every AI interaction for that task type.

The best examples come from your actual best outputs. Every time you use AI and it produces a result you're genuinely happy with, save the prompt and output as a candidate for your few-shot library. After 4-6 weeks of doing this across your key use cases, you'll have a library that dramatically raises your baseline output quality.

Library structure recommendation: Organize examples by task type (email writing, data classification, content generation, code review) and annotate each with why it represents a good output — what specific qualities make it worth emulating.

Frequently Asked Questions: Few-Shot Prompting

How many examples should I include in a few-shot prompt?

The research suggests 3-5 examples is the sweet spot for most LLMs. Below 3, there may not be enough pattern for the model to learn from. Above 5-6, you see diminishing returns and the prompt becomes expensive in tokens. For complex or highly varied tasks, 5 diverse examples outperform 3. For simple, consistent tasks, 2 good examples can be sufficient.

Does the order of examples matter in few-shot prompting?

Yes, and it matters more than you might expect. Research from Stanford shows that recency bias causes LLMs to weight the last example most heavily. This means you should put your strongest, most representative example last. Also, avoid grouping all examples of one type together — alternate between different input variants to avoid the model over-indexing on one pattern.

Should my few-shot examples use real data or made-up data?

Ideally, use real examples from your actual use case — they represent the exact distribution of inputs the model will encounter. However, made-up examples that accurately represent the task structure work almost as well. What matters most is that the examples demonstrate the exact format, quality level, and reasoning style you want replicated. Never use poor-quality examples just because they're real.

Does few-shot prompting work with image generation models?

Traditional few-shot prompting (showing text input/output pairs) doesn't apply to image generation in the same way. However, multimodal models like GPT-4o support a visual version: providing example images alongside the instruction can guide style and composition. For text-to-image models like Midjourney and DALL-E 3, style consistency is better achieved through detailed style descriptors and negative prompts than through example-based learning.

What's the difference between few-shot and fine-tuning?

Few-shot prompting teaches the model within the context window of a single conversation — the examples are part of the prompt, not part of the model's weights. Fine-tuning actually updates the model's weights using a training dataset, creating a permanent behavioral change. Few-shot is faster, cheaper, and requires no ML expertise; fine-tuning produces more consistent results at scale but requires significant data preparation and compute cost. For most use cases, well-crafted few-shot prompting achieves 80-90% of fine-tuning's benefit at near-zero cost.

Build Few-Shot Prompts with AI Assistance

Our prompt generator can help you build optimized few-shot prompts for any task.

Try the Free Prompt Generator →