# Zero-Shot vs Few-Shot Prompting?

> Zero-shot gives a model only instructions, few-shot adds worked examples. How each works, when examples pay off, and their risks, for your AI interview.

**In short:** Zero-shot prompting gives the model a task with no examples. Few-shot prompting adds a few worked examples to the prompt, so the model copies the pattern. Examples steer format and judgement, but they cost space on every call and can skew the answers.

AI and LLM interview question Q077, Prompt and context engineering. Beginner, very common (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/zero-shot-vs-few-shot-prompting

## Say it in 30 seconds

Zero-shot means I ask the model to do a task with only my instructions. Few-shot means I also paste a few finished examples first, so it copies the pattern. I start with zero-shot because it's cheap. If the model keeps getting the format or the labels wrong, I add three to five examples that cover the real edge cases, then measure again. Examples cost space on every call and can skew the answer, so they have to earn their place.

## Say it in 2 minutes

Zero-shot prompting means I give the model a task and no examples. I describe what I want, list the allowed labels, and let the model work from what it already learned in training. Few-shot prompting means I add a handful of finished cases to the prompt first, each with its correct answer, so the model can copy the pattern. Nothing is retrained in either case. The examples are just text in the prompt.

Take an insurance claims bot that sorts each claim into fast-track, needs an adjuster, or possible fraud. Zero-shot handles the simple claims, but on messy notes it may invent a label of its own. Three or four real examples, chosen to cover the hard cases, fix the labels and the judgement together.

Examples are not free, though. They add to every single request, which adds up across thousands of claims a day. The model can also lean toward the label that sits nearest the end of the prompt. A 2021 study found few-shot results could swing from near chance to near state-of-the-art, depending on the examples' order and format. So I mix the labels, measure on a test set of real cases, and keep the longer prompt only when it wins.

In practice I start with zero-shot, add three to five varied examples when the output misses, and check both versions on real cases before I ship.

## What are zero-shot and few-shot prompting, in plain words?

A prompt is the text you send a model: the task, any context, and the question. Zero-shot prompting sends the task with no examples. Few-shot prompting adds a few finished examples first, so the model can see the pattern you want.

Neither one changes the model's weights, the numbers inside it. The examples only live in the prompt for that one call. Researchers call this learning from the prompt alone, or in-context learning.

Think of a new claims clerk. On day one she reads the handbook, which is zero-shot: the rules, but no cases. On day two she sits beside a senior colleague and watches three finished decisions before she touches a claim, which is few-shot. An insurer's triage model works the same way. The handbook is the instruction, and the three decisions are the examples.

- **Zero-shot:** A task sent with instructions only, and no examples.
- **Few-shot:** The same task, with a few worked examples in the prompt.
- **Demonstration:** One worked example inside a prompt. The paper that named these settings uses this word.
- **In-context learning:** Picking up a pattern from the prompt alone, with no retraining.

## How does few-shot prompting steer the model?

Few-shot prompting works like that day-two watching, done in text. The model reads the examples as part of its input, notices the shape of each answer, and copies that shape for the new case. OpenAI and Anthropic both describe examples as a way to steer the output.

> "Few-shot learning lets you steer a large language model toward a new task by including a handful of input/output examples in the prompt, rather than fine-tuning the model." (OpenAI)
>
> "A few well-crafted examples (known as few-shot or multishot prompting) improve accuracy and consistency." (Anthropic)

*Diagram, Same task, with or without examples: Zero-shot sends only the task. Few-shot sends the same task with labelled examples first. Both go to the same model, which returns one label, so only the prompt changes.*
1. The task and the label list go in, with nothing else.
2. The same task goes in, with three labelled claims first.
3. The model returns one label from the list.

The GPT-3 paper defines these settings. Its zero-shot setting allows no demonstrations, only an instruction in natural language. Its few-shot setting fills the prompt with as many demonstrations as fit in the context window, and one-shot sits in between with a single example.

Zero-shot is the right first try when the model already knows the task and the output can be loose, such as a friendly summary of a meeting. Anthropic's guide says Claude responds well to clear, explicit instructions, so a clear zero-shot prompt is a fair place to start.

## When do examples help, and what do they cost?

- **Zero-shot: Short and quick.** One short prompt per call. Good when the model already knows the task and the output can be loose.
- **Few-shot: Steers format and judgement.** Shows the exact labels, tone and shape. The examples travel with every request, so they cost on each call.
- **The catch: Examples can skew answers.** Order, label mix and format all move the result. Four examples with one label can pull answers toward it.

Say an insurer's claims bot sorts each new claim into Fast-track, Needs adjuster or Possible fraud. Zero-shot handles the simple claims, but on messy notes it starts to invent labels of its own. Anthropic's guide calls examples one of the most reliable ways to steer format and tone, so the usual fix is three or four real examples, picked to cover the hard cases.

Here is a prompt builder in standard Python. The insurer and its claims are made up, and the code calls no model. It prints the prompt with no examples, then the same prompt with three.

```python
# A made-up insurance claims bot. We build the prompts here and call no model.
LABELS = ["Fast-track", "Needs adjuster", "Possible fraud"]

EXAMPLES = [
    ("Hail damage to roof, two neighbours reported the same storm.", "Fast-track"),
    ("Water damage to kitchen, plumber's invoice dated before cover began.", "Needs adjuster"),
    ("Third claim on the same car in six weeks, each from a different garage.", "Possible fraud"),
]

def build_prompt(claim, examples):
    parts = ["Sort each claim into one of: " + ", ".join(LABELS) + "."]
    for text, label in examples:
        parts.append("Claim: " + text + "\nLabel: " + label)
    parts.append("Claim: " + claim + "\nLabel:")
    return "\n\n".join(parts)

NEW_CLAIM = "Car scraped in a car park, no witnesses, claim filed the day after cover began."
print(build_prompt(NEW_CLAIM, []))
print("----")
print(build_prompt(NEW_CLAIM, EXAMPLES))
```

Output:

```text
Sort each claim into one of: Fast-track, Needs adjuster, Possible fraud.

Claim: Car scraped in a car park, no witnesses, claim filed the day after cover began.
Label:
----
Sort each claim into one of: Fast-track, Needs adjuster, Possible fraud.

Claim: Hail damage to roof, two neighbours reported the same storm.
Label: Fast-track

Claim: Water damage to kitchen, plumber's invoice dated before cover began.
Label: Needs adjuster

Claim: Third claim on the same car in six weeks, each from a different garage.
Label: Possible fraud

Claim: Car scraped in a car park, no witnesses, claim filed the day after cover began.
Label:
```

Every example costs context space on every call, since the whole prompt is sent again each time. A zero-shot prompt stays short. The examples add to each request, and that adds up across thousands of claims a day. Some providers cache repeated prompt text, which cuts the cost, but the space still counts toward the context window.

## Why can examples make answers worse?

Examples can also make things worse. A 2021 study named Calibrate Before Use tested few-shot prompts on GPT-3 and found the results could be unstable:

> "We show that this type of few-shot learning can be unstable: the choice of prompt format, training examples, and even the order of the training examples can cause accuracy to vary from near chance to near state-of-the-art." (Calibrate Before Use, 2021)
>
> "Diverse: Cover edge cases and vary enough that Claude doesn't pick up unintended patterns." (Anthropic)

The study traced the wobble to the model's bias toward certain answers, such as those placed near the end of the prompt or common in its pre-training data. So vary the labels, avoid a long run of one label, and test the order you actually ship. Anthropic's guide asks for examples that are relevant to your real use case and diverse.

*Diagram, How the mix of examples steers the answers: Both prompts hold the same task. Four matching examples can pull answers toward one label. Mix the labels and include the hard cases, so the examples teach the judgement, not a habit.*
1. Mixed examples show where each label starts and stops.
2. Four matching examples can push the model toward that one label.
3. Claims like the examples often get the right label.
4. Other claims can get the common label, even when it is wrong.

> **Tip:** Asked how you'd improve a weak answer, check the prompt first, then add examples. Don't say few-shot always wins. Say it depends on the task, the cost and a test set.

### How would you choose between them for a new feature?

Start with the cheapest version, and let a test set decide. Here is the order I would follow.

1. **Write the zero-shot prompt:** Say the task, the allowed labels and the output format in plain words.
2. **Run it on real past cases:** Take about a hundred past claims with the decisions adjusters made, and score the outputs.
3. **Add examples only where it misses:** Pick three to five cases that cover the misses, with mixed labels. Anthropic's guide suggests three to five for best results.
4. **Measure both again:** Keep the longer prompt only if it wins on the test set by enough to pay for its extra space.
5. **Shuffle the examples:** Change their order and run the test again. If the score moves a lot, the prompt is fragile.

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] Zero-shot means instructions only. Few-shot adds a few worked examples.
- [ ] Neither changes the model's weights. The examples live in the prompt.
- [ ] Use few-shot for unusual labels, formats or judgement calls.
- [ ] Name the cost: examples take context space on every call.
- [ ] Name the risk: order, label mix and format can skew the answers.
- [ ] Test both on real cases before keeping the longer prompt.

**Common traps**

- Trap: "Few-shot always gives better answers." Better: It can, but only a test on real cases shows it. Measure zero-shot and few-shot side by side first.
- Trap: "More examples are always better." Better: Past a few, examples eat context and can skew the answer. Anthropic's guide suggests three to five.
- Trap: "Examples teach the model new facts." Better: They show a pattern and a format. For facts the model lacks, you have to supply the source text.

## Can you spot the skew?

**Spot the skew:** Which set of examples is most likely to push a new claim toward one label?

A. Examples: Fast-track, Needs adjuster, Possible fraud, Fast-track. Every label appears.
B. Examples: Needs adjuster, Fast-track, Possible fraud, Needs adjuster. The labels vary.
C. Examples: Fast-track, Fast-track, Fast-track, Fast-track. All four cases get the same label.
D. Examples: Possible fraud, Needs adjuster, Fast-track, Possible fraud. Edge cases are included.

**Answer:** C. Four identical labels teach the model that one answer is the norm, so it may send many new claims to Fast-track. Vary the labels and include the hard cases.

**Quick check:** A bank's FAQ bot answers general questions well with zero-shot. Its team now needs replies in one exact internal refund-code format. What is the first thing to try?

A. A bigger model, to get better formatting
B. Three to five examples in that exact format
C. A higher temperature, for more variety
D. Fine-tuning on a full training set

**Answer:** B. A few examples show the exact format for the cost of some prompt text. A bigger model does not learn a format it was never shown, and a higher temperature only adds randomness. Fine-tuning can wait until examples fall short.

## Can you answer these from memory?

**Flash cards**

- **What is zero-shot prompting?** A task sent with instructions only, and no examples.
- **What is few-shot prompting?** The same task, plus a few worked input and output examples in the prompt.
- **Does few-shot change the model's weights?** No. The examples live in the prompt for that one call.
- **What does an example cost?** Context space on every call, since the prompt is sent again each time.
- **What is the main risk?** Order, label mix and format can skew the answers, as a 2021 study found.
- **Where should you start?** Zero-shot. Add three to five varied examples only if the output misses.

## Likely follow-up questions

- Q076 What is prompt engineering? https://designervenkat.online/interview/ai/what-is-prompt-engineering
- Q078 What is chain-of-thought, and when does it help? https://designervenkat.online/interview/ai/what-is-chain-of-thought-prompting
- Q081 What makes a good prompt? https://designervenkat.online/interview/ai/what-makes-a-good-prompt
- Q087 Why template and version your prompts? https://designervenkat.online/interview/ai/why-template-and-version-your-prompts
- Q098 How do you pick and order few-shot examples? https://designervenkat.online/interview/ai/how-do-you-pick-and-order-few-shot-examples

## Learn it in depth

- [Zero-shot and few-shot](https://designervenkat.online/learn/ai-engineering/zero-shot)
