M01-L04 · source screen S04 · 8 min

Prompting modes: zero-shot, one-shot, multi-shot

0:00 / 0:00

Learning objectives

  • Define zero-shot, one-shot and multi-shot (few-shot) prompting.
  • Explain why in-prompt examples are not training data.
  • Weigh the token cost of examples against the quality they add, and choose the smallest reliable prompt.
  • Decide model and number of examples together, guided by an eval.

Estimated teaching time: 8 min · Prerequisites: M01-L02 (tokens, context budget); M01-L03 (model tiers)

1. The three modes

Separate from how you word a prompt is how many worked examples you give the model inside it. A worked example is an input paired with the exact output you want.

ModeWhat the prompt containsHarbor Goods example
Zero-shotThe instruction, no examples. You describe the task and ask for the result."Classify this ticket into order_status, refund, product_question or other."
One-shotThe instruction plus one example input paired with its desired output.…plus: "Where is my parcel?" → {"category": "order_status"}
Multi-shot (few-shot)The instruction plus several such examples.…plus two or three tickets with their exact JSON answers.
Zero-, one- and multi-shot from one functionExecuted
INSTRUCTION = (
    "Classify the support ticket. Reply with JSON only: "
    '{"category": <one of order_status, refund, product_question, other>}'
)

# Worked examples: input paired with the exact output we want.
EXAMPLES = [
    ("Where is my parcel? It was due Monday.", '{"category": "order_status"}'),
    ("I returned the jacket two weeks ago, still no money back.", '{"category": "refund"}'),
]


def build_messages(ticket: str, shots: int) -> list[dict]:
    """shots=0 is zero-shot, 1 is one-shot, 2+ is multi-shot (few-shot)."""
    messages = []
    for question, answer in EXAMPLES[:shots]:
        messages.append({"role": "user", "content": f"{INSTRUCTION}\n\nTicket: {question}"})
        messages.append({"role": "assistant", "content": answer})
    messages.append({"role": "user", "content": f"{INSTRUCTION}\n\nTicket: {ticket}"})
    return messages


for shots in (0, 1, 2):
    msgs = build_messages("Do the boots run small?", shots)
    chars = sum(len(m["content"]) for m in msgs)
    print(f"{shots}-shot: {len(msgs)} messages, {chars} characters sent on every call")
Real output Actual output from running the file
0-shot: 1 messages, 152 characters sent on every call
1-shot: 3 messages, 347 characters sent on every call
2-shot: 5 messages, 555 characters sent on every call
Executed locally with python3 on 2026-10-20. Builds the message lists only; no API call. Examples are placed as prior user/assistant turns, one common way to supply worked examples.

2. The cost and quality trade-off

Each example you add costs tokens on every call and consumes context budget, so the choice trades quality against cost. The script above shows the effect: the same request grows from 152 to 555 characters as examples are added, and that extra input is sent and billed on every single call.

  • Reach for zero-shot when the task is simple and the output shape is obvious.
  • Move to one-shot or multi-shot when the output has a specific structure, casing, or edge case that a description keeps missing.
  • One or two correct examples often fix the issue faster than another paragraph of instructions.

Worked example: the zero-shot triage prompt keeps returning {"category": "Order Status"}, title case with a space, which breaks the code that expects order_status. Rewriting the instruction a third time is slow and uncertain. Adding one correct example shows the exact casing, and the problem typically disappears.

3. Mode choice interacts with model choice

Prompting mode and model choice are related levers. A more capable model often succeeds zero-shot on a task where a smaller model needs a few examples to match the structure. So adding examples can let a cheaper model do the job.

The two decisions are worth making together. Try the simplest model and the fewest examples that meet your eval. Add capability or examples only where the eval says you need them.

References

Source notes

  • Primary source: S04 of 'MSO Foundations: Developer Module 1', three tab panels.
  • The ticket-classification prompts and outputs in this lesson are illustrative (Harbor Goods is fictional); the zero-shot 'wrong casing' output is a typical failure, not a recorded model response.