Skip to content
AI360XpertBeta

Zero-Shot Prompting

Ask for what you want and show nothing. The model answers from its training alone, so every word of the instruction carries weight.

A zero-shot prompt pairs one instruction with one new input and zero examples, so the answer leans on pretraining alone; adding two shown pairs steadies the output shape.
A zero-shot prompt pairs one instruction with one new input and zero examples, so the answer leans on pretraining alone; adding two shown pairs steadies the output shape.

Why Does This Exist?

You ask for a CEO name and get a sentence. You ask again and get a bare name with a friendly intro glued on. A third try returns a neat ORG | CEO line, then the next input breaks the streak. When that output feeds code, each surprise shape is a crash, and that crash is why this page exists.

Zero-shot prompting is the cheapest possible move: one instruction, one new input, zero examples. It works at all because instruction tuning trained the model to read bare instructions as orders. That makes it the right first try for anything new, and the wrong place to demand a shape a parser can trust.

This page teaches the no-example move: what the prompt contains, why the reply shape is a guess, and when to stop describing and start showing. Showing is few-shot prompting. The reason showing works is in-context learning. When a crash is unacceptable rather than annoying, skip both and read structured outputs.

One idea carries over from elsewhere. The model writes the next token from the tokens before it, so everything in the prompt is evidence and nothing else is. The full story lives in next-token prediction.

Think of It Like This

The food truck menu with no photos

Your favorite food truck has a chalkboard with dish names and nothing else. You order the spicy noodles. The cook has made thousands of bowls and holds a firm idea of spicy, so you get a good bowl, but whether it matches your idea of spicy is luck. The dish name is the instruction. The missing photos are the zero examples. The cook's memory of every past order is pretraining.

Now the truck tapes two photos beside each dish name. Every customer points, every bowl matches, and nobody argues about spicy. Those photos are few-shot examples: they replace judgment with matching.

Where it stops: photos sit on the board once and serve every customer free. Examples ride inside every prompt, so each one spends context, latency, and money on every call. And the cook learns your taste across visits while the model starts each prompt fresh, with its weights unchanged.

How It Actually Works

Build one string in fixed order: an instruction, then your question. Call the whole string PP, which means the full prompt you send. Call the instruction II, which means the line that states the task and the shape. Call the count of shown examples kk, which means how many input-output pairs appear before your question. Here k=0k = 0. Call your real input xnewx_{new}, which means the question you care about, and the reply ynewy_{new}, which means what the model writes next.

Then PP is II followed by xnewx_{new} with the output left blank. No weights change. The model predicts the next token from the run before it, but with no repeated shape anywhere in PP, no continuation is strongly favored. Wording and pretraining break the tie instead, so the reply answers the task in whatever shape the instruction most strongly suggests. That is the whole mechanism: zero evidence of shape in, no guaranteed shape out.

The shape of the prompt

Here is the prompt used through this page, with k=0k = 0. Same task as the few-shot version, minus the pairs:

Extract the CEO. Reply as ORG | CEO.
Input: Meta was founded by Mark Zuckerberg.Output:

The hoped-for finish is ynewy_{new}, which is Meta | Mark Zuckerberg. Four words, same divider, no intro. But nothing in PP rules out The CEO of Meta is Mark Zuckerberg., which answers the task just as well and breaks a parser waiting on the divider.

Worked example

Count the prompt above by splitting on whitespace, the way the snippet below does. II is 8 words. The final question block is 8 words. Add them: 8+8=168 + 8 = 16 words in, with k=0k = 0. The hoped-for answer is 4 words out, and the chatty alternative is 7.

Set that against the sibling page. Its k=2k = 2 prompt runs 38 words in for the same 4-word answer. The 22-word gap is the trade stated plainly: zero-shot spends 16 words and risks the shape, few-shot spends 38 and steadies it, and the whole prompt travels on every call, which you can feel in context windows.

Reach for zero-shot first and keep it while the output is read by a person. Move on when a parser reads it, when the label set is yours rather than the world's, or when the task needs several steps held in order. Zero-shot rests on one assumption: an instruction-tuned model that reads a bare instruction as an order. A raw next-token model with no such tuning treats your instruction as text to continue, and the reply reads like autocomplete instead of obedience.

Code

The point here is the shape risk, made visible. This builder assembles the same k=0k = 0 prompt and runs a divider-based parser over two candidate replies, one shaped and one chatty:

def build_zero_shot(instruction: str, query: str) -> str:    return f"{instruction}\n\nInput: {query}\nOutput:"

def parse_ceo(reply: str) -> tuple[str, str]:    org, sep, ceo = reply.partition("|")    if not sep:        return "", reply.strip()  # no divider, nothing to split on    return org.strip(), ceo.strip()

instruction: str = "Extract the CEO. Reply as ORG | CEO."prompt: str = build_zero_shot(instruction, "Meta was founded by Mark Zuckerberg.")print(len(prompt.split()))  # -> 16print(parse_ceo("Meta | Mark Zuckerberg"))  # -> ('Meta', 'Mark Zuckerberg')print(parse_ceo("The CEO of Meta is Mark Zuckerberg."))  # -> ('', 'The CEO of Meta is Mark Zuckerberg.')

Sixteen words in, and the parser tells the story. The shaped reply splits cleanly into its two fields, while the chatty reply returns an empty organization field with the whole sentence unsplit. That empty string is what a zero-shot crash looks like from the inside.

Watch Out For

Chatter around the answer breaks the parser

It works in chat and crashes in production. The symptom is intermittent: most replies parse, then one arrives as Sure! Here it is: Meta | Mark Zuckerberg or drops the divider entirely, and the split or json.loads call throws. Don't trust a prompt that passed three manual tries.

Fix it by restating the output contract last (Reply with only the value, no other words.) and by validating every reply before it touches the pipeline, with one retry on failure. When failures must be impossible rather than rare, stop requesting the shape and constrain it: show one example per shape with few-shot prompting, or enforce it with structured outputs.

Your labels are not the model's labels

You ask for exactly one of Promoter, Passive, or Detractor, and the reply says Positive. The symptom is a confident answer in the world's vocabulary instead of yours: the model reached for the most common label words in its training rather than your company terms.

Fix it by enumerating the allowed outputs word for word in the instruction (Reply with exactly one of: Promoter, Passive, Detractor.), so the target tokens appear verbatim in PP. When a category still drifts, show one example per label. A single demonstration of each class beats another paragraph of description.

The Quick Version

  • Zero-shot prompting sends one instruction plus a new input with zero examples attached.
  • The reply shape comes from wording and pretraining, so unshaped answers are normal.
  • A 16-word zero-shot prompt does the work of a 38-word few-shot one and risks the shape to save the context.
  • Enumerating the allowed outputs word for word stops the model inventing its own labels.
  • One example per label turns a failing zero-shot prompt into few-shot prompting.
  • Instruction tuning is what makes a bare instruction read as an order at all.