Few-Shot Prompting

Two to five examples show the model the pattern. The point where more examples stop helping and just eat up space in the context window.

What few-shot prompting is

With few-shot prompting you give the language model several examples in the prompt that show what the result should look like. These examples are called "shots". Two to five are enough for most tasks.

A shot has two parts: the input, the way a real user would write it, and the output you want. Line several of them up and you get a small template the model follows when it fills in the last open line.

Nothing gets trained here. The model's weights stay the same, it only adjusts its attention within the current context. The technical term for this is in-context learning. Once the conversation ends, the pattern is gone again, and that's exactly why every example counts against your context window again on every call.

How many examples help

The biggest jump happens between zero and one example. Without a template the model guesses based on the average, a single example locks in the format. Going from one to three usually still gives you a clear gain, especially with more than two categories. From five on, the curve flattens.

It's best to go step by step. Test zero-shot first to see the baseline. If that's not enough, add one example that mainly clarifies the format. If nuances in the content are still off, go up to three to five.

The catch: every example uses tokens. For a single request that doesn't matter, but at thousands of calls you pay for every unnecessary example. A practical test: cut one example and check whether the result gets worse. If the quality stays the same, it was dead weight. If you constantly need changing reference material, retrieval augmented generation is the better route.

An example

In a sentiment analysis with three categories, the examples show where the line between the classes runs:

Task: Classify the customer reviews as Positive, Negative or Neutral.

Review: "Shipping was fast, but the product is damaged."
Sentiment: Negative

Review: "Pretty okay for the price, does the job."
Sentiment: Neutral

Review: "Better than expected! Will buy again."
Sentiment: Positive

Review: "Support helped me right away, thanks."
Sentiment:

Three examples are enough here because the task is clearly bounded. A fourth would barely sharpen the pattern.

What makes good examples

The examples should cover the whole task. If they're all short and positive, the output will be short and positive too. That's the most common mistake, label bias: show four positive examples and one negative, and the model rates neutral cases as positive too.

Then there's recency bias. Language models weight the end of the prompt more heavily, so put the most important example last, right before the actual task.

Formatting matters as well. Clear separators like ### show the model where one example ends. For tasks with several calculation steps, chain-of-thought is worth it: the example then shows the whole solution path instead of just the bare answer.

Fine-tuning is the alternative when examples aren't enough anymore. It changes the weights permanently, but it needs thousands of training examples and computing power to do so. For almost everything day to day, few-shot is enough. More basics are in the prompting guide and under prompt engineering.

Back to the AI and Automation Glossary.

FAQ

How many examples does few-shot prompting need?
For most tasks, two to five are enough. For a simple format requirement, like a fixed JSON structure, a single example is often enough. Five or more only pay off when the model has to tell several categories apart or the format is complex. Once you're in double digits, almost every extra example adds next to nothing and only takes up space in the context window.
What's the difference between few-shot prompting and fine-tuning?
Few-shot prompting doesn't change the model itself. The examples only sit in the prompt for the duration of the request and are gone afterwards. Fine-tuning adjusts the model's weights permanently and needs thousands of training examples and computing power to do it. For most tasks few-shot is enough. Fine-tuning only pays off for very specific domain knowledge or when you need the same style millions of times.
Why does the model still get things wrong despite the examples?
Usually because the examples are unbalanced: if four out of five examples are positive, the model tips toward positive even on neutral input, an effect called label bias. A second reason is recency bias, where the model weights the last example in the prompt more heavily than the earlier ones. You can fix both by representing the categories equally often and putting the most important example at the end.
Portrait of Eric Hinzpeter

Eric Hinzpeter

Eric Hinzpeter, Senior B2B Content Strategist. He builds AI agents and marketing automation for production use and writes up what comes out of it here.

About meLinkedIn (new tab)