Few-Shot Prompting: Teaching AI With Examples
Why Examples Work So Well
Describing what you want is useful. Showing what you want is better.
When you include examples in a prompt, the AI learns from them directly. It picks up on patterns of tone, structure, length, vocabulary, and style that would be very hard to fully describe in words. This technique is called few-shot prompting, and it is one of the most reliable ways to get consistent, high-quality output.
The name comes from machine learning terminology. Zero-shot means no examples are provided, the model reasons from the task description alone. One-shot means one example. Few-shot means a small number, typically two to five.
Zero-Shot vs Few-Shot: The Practical Difference
Here is a concrete comparison.
Zero-shot prompt:
Write a subject line for a promotional email about a 30% discount on our software.
Keep it under 50 characters and make it create urgency.
This works reasonably well. The AI understands the task and will produce something usable. But it may not match your brand's specific tone or style.
Few-shot prompt:
Write a subject line for a promotional email about a 30% discount on our software.
Keep it under 50 characters and make it create urgency.
Here are examples of subject lines in our style:
- "Last chance: 40% off ends tonight"
- "Your team is missing out on this"
- "We cut the price. You cut the time."
Now write a new one for the 30% discount.
The few-shot version learns from your examples and mirrors their style: short, punchy, direct. The output is much more likely to match your brand without editing.
How to Choose Good Examples
The quality of your examples determines the quality of the output. Choosing the right examples matters.
Pick examples that represent what you actually want. If your best-performing emails have a specific structure or tone, use those. Do not choose examples at random.
Use examples that cover the range of variation you care about. If you want the AI to handle both formal and casual contexts, include examples of both. If you only show formal examples, the AI will default to formal.
Keep examples consistent in style. Mixed examples confuse the model. If your three examples have very different tones, the AI will average them rather than match any of them.
Two to four examples is usually enough. More examples do not always mean better results. Beyond five or six, the returns diminish and the prompt becomes very long. Three strong examples usually outperform ten mediocre ones.
Input-Output Examples
For classification, labelling, and transformation tasks, you can provide input-output pairs. This is especially useful when you want the model to apply a consistent transformation to new content.
Example for sentiment classification:
Classify the sentiment of each customer review as Positive, Negative, or Neutral.
Examples:
Review: "The product works exactly as described. Very happy with it."
Sentiment: Positive
Review: "Took three weeks to arrive and the packaging was damaged."
Sentiment: Negative
Review: "It is okay. Does what it says."
Sentiment: Neutral
Now classify these reviews:
Review: "Absolutely love it. Have already recommended it to three friends."
Sentiment:
Review: "Not what I expected from the photos on the website."
Sentiment:
This pattern works for any task where the transformation is consistent: translating tone, extracting data, reformatting text, labelling content.
Style Transfer With Examples
One of the most powerful applications of few-shot prompting is style transfer: taking content and rewriting it in a specific voice.
Rewrite the following paragraph in our company's writing style.
Our style (examples):
- "Most software promises to save you time. We measured it instead."
- "You should not need an IT degree to update your own website."
- "Built for the people who actually use it, not the people who buy it."
Paragraph to rewrite:
"Our platform offers a comprehensive suite of productivity tools designed to
optimise workflows and enhance organisational efficiency at scale."
Rewrite:
The examples teach the model to move away from corporate jargon toward plain, direct language. Without examples, a request to "rewrite in our style" leaves the model guessing what that style is.
Building a Personal Few-Shot Library
The most efficient way to use few-shot prompting regularly is to maintain a small library of your best examples for each content type you produce frequently.
For example:
- Three subject lines that have performed well for you
- Three social captions that represent your voice
- Three email intros that set the right tone
- Three ways you typically open a meeting summary
When you need to produce that content type, drop in your library examples as the few-shot set. This turns a prompt you write from scratch each time into a template you reuse with minor adjustments.
The advanced tutorials later in this course cover prompt libraries in depth.
Discussion
Sign in to comment. Your account must be at least 1 day old.