When you want an AI to do something specific โ€” classify text in a particular way, write in a distinct style, or follow a strict output format โ€” telling it what to do in words often isn't enough. The most reliable way to communicate a precise pattern is to show the model what you want through worked examples. That's the core idea behind few-shot prompting.

Zero-Shot vs. Few-Shot: What's the Difference?

In zero-shot prompting, you describe a task and ask the model to complete it with no prior examples. This works well for common, straightforward tasks where the model has seen plenty of similar cases during training.

In few-shot prompting, you include between 2 and 10 complete examples of the input-output pattern you want the model to follow, then pose your actual question. The model uses these examples as a template and mirrors the structure, format, and style.

๐Ÿ“Œ Rule of thumb: Use few-shot when zero-shot produces inconsistent outputs, when format precision matters, or when your task involves a pattern the model may not have seen frequently in training data.

A Simple Few-Shot Example: Sentiment Classification

Suppose you're building a tool to classify customer reviews as Positive, Negative, or Neutral in a specific one-word format. Zero-shot often produces verbose explanations instead. Here's how few-shot fixes this:

Few-Shot Prompt
Classify the sentiment of each customer review as: Positive, Negative, or Neutral. Review: "Absolutely love this product, it exceeded every expectation." Sentiment: Positive Review: "Arrived broken and the return process was a nightmare." Sentiment: Negative Review: "It works as described. Nothing special but does the job." Sentiment: Neutral Review: "The setup took two hours and the manual was completely useless." Sentiment:

With these three examples, the model will reliably return a single-word label rather than a paragraph-length explanation. The examples have taught it the exact format you need.

How Many Examples Should You Include?

Research and practical experience point to a sweet spot:

Choosing Good Examples

The quality of your examples matters far more than the quantity. Follow these principles:

Few-Shot for Writing Style

Few-shot prompting is also powerful for establishing a specific writing voice or tone. If you want the AI to write in the style of your brand, include examples of that style before making your request:

Style Transfer Prompt
Write product descriptions in our brand voice. Here are examples: Input: A water bottle with a flip-top lid Output: "Stay hydrated on your terms. Our flip-top bottle opens with one hand and seals with confidence โ€” engineered for the pace of your day." Input: A leather notebook Output: "Every great idea deserves a worthy home. Supple full-grain leather, 192 ivory pages, and a ribbon marker that stays exactly where you left off." Input: A bamboo desk organizer Output:

Common Mistakes to Avoid

Few-shot prompting is one of the highest-leverage techniques available. Once you start applying it to tasks where consistency matters, you'll find it's the single change that most reliably improves output quality.