Back to blog
Prompting
Claude Code

Zero-Shot vs Few-Shot: Teaching AI with Examples

Thang Doan
Thang Doan

When you ask an AI a question without giving it any examples, that is called a "zero-shot" prompt. When you include a few examples to show it what you want, that is a "few-shot" prompt. This distinction can make a huge difference in your results.

Zero-Shot: No Examples, Just Instructions

A zero-shot prompt is like walking up to someone and asking a question cold. You provide the task and nothing else. For example: "Which explanation is better for how snow forms, Explanation 1 (detailed) or Explanation 2 (brief)?"

The model will pick what it thinks is best, usually the more detailed one. But what if you wanted the shorter answer?

Few-Shot: Show, Do not Just Tell

A few-shot prompt includes examples that show the model the pattern you want. If you provide two examples where the shorter explanation was chosen, the model will learn to prefer concise answers.

It is like showing a new employee three completed forms so they can see the pattern, they will fill out the next one the same way.

Why Few-Shot Usually Wins

Google actually recommends always including few-shot examples in your prompts. They found that prompts without examples are less effective. In fact, if your examples are clear enough, you can even remove the written instructions entirely.

How Many Examples Should You Give?

Usually two to five examples is enough for the model to pick up the pattern. But there is a catch: if you give too many examples, the model might overfit, meaning it starts copying the examples too closely instead of understanding the general pattern. Experiment to find the sweet spot.

Keep Your Examples Consistent

This is a big one: make sure all your examples follow the exact same format. If example 1 uses a bullet list but example 2 uses a numbered list, the model gets confused. Pay attention to spacing, line breaks, and punctuation, the model notices all of it.

The takeaway: Start with zero-shot for simple tasks. For anything that needs specific formatting, style, or behavior, add two to five consistent examples. It takes an extra minute but saves you from bad results.

Based on: Gemini API Prompting Strategies (ai.google.dev)

Recommended for you

Enjoyed this article?

Subscribe for new articles. No spam. Unsubscribe anytime.

By subscribing you agree to receive the newsletter. See the Privacy page.