Zero-Shot vs Few-Shot: Teaching AI with Examples
Model keeps picking the wrong format or style no matter how you phrase the instructions? That is zero-shot prompting hitting its limit. Examples teach the pattern faster than words do.
Zero-shot: instructions only
A zero-shot prompt gives the task and nothing else, like asking a stranger cold: "Which explanation of how snow forms is better, the detailed one or the brief one?" The model picks what it guesses you want, usually the more detailed one, even if you wanted the shorter answer.
Few-shot: show the pattern
A few-shot prompt includes examples of the behavior you want. Give two examples where the shorter explanation was chosen, and the model infers the preference. It is like handing a new employee three completed forms: they see the pattern and fill out the next one the same way. Google's prompting guide recommends always including examples, and if they are clear enough you can drop the written instructions entirely.
How many examples
Two to five is usually enough. More than that and the model can overfit: it copies the examples too closely instead of learning the general rule. Experiment to find the sweet spot for your task.
The trade-off
Examples cost tokens and attention, and inconsistent examples actively hurt: if example 1 uses bullets and example 2 uses numbers, the model gets confused, because it notices spacing, line breaks, and punctuation. Instructions are cheap and scale well, but they teach style and format far less precisely than three consistent examples.
The smallest test
Rerun your last zero-shot prompt with three consistent examples and compare the two outputs side by side.
Based on: Gemini API Prompting Strategies (ai.google.dev)
Recommended for you
- PromptingClaude Code
Understanding AI Model Parameters: Temperature, Top-K, and Top-P
Hidden settings control how AI picks its words: temperature, top-K, top-P, max tokens, and stop sequences. Here is what each one does, in plain English.
- PromptingClaude Code
The System Prompt Your Coding Agent Actually Needs
A coding agent without a custom system prompt is a chatbot that writes code. The default prompt runs it like a generic assistant. Yours should run it like an engineer on your team.
- PromptingClaude Code
Choosing the Right Claude Model: Haiku, Sonnet, and Opus Explained Simply
Claude has three models: Haiku, Sonnet, and Opus. This guide explains which one to pick for each task and how to avoid wasting your usage limits.
- PromptingClaude Code
Adding Context and Breaking Down Complex Prompts
AI does not know your situation unless you tell it. Learn to add context and to split big tasks into small steps using chaining and aggregation.
Enjoyed this article?
Subscribe for new articles. No spam. Unsubscribe anytime.