Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Prompting Techniques and Context Engineering  ›  Lesson

Zero-Shot and Few-Shot Prompting

Few-Shot 12 minA zero-shot prompt describes the task with no examples, while a few-shot prompt adds a handful of worked examples that show the model the exact format and judgement you want.

Zero-Shot and Few-Shot Prompting

Pedal Point's ticket sorter keeps putting "My parcel is a week late and I'm furious" under returns. The instructions clearly say late parcels are order_status, yet the model reads anger and assumes the customer wants their money back. Rewriting the rule a fourth time is not working. Showing it will.

The rule

Zero-shot tells the model; few-shot shows it.

A zero-shot prompt describes the task and gives no examples:

Classify the email as order_status, returns, product_question or other.

It works well for clear, common tasks. A few-shot prompt adds a handful of worked examples, each an input and the exact output you want:

Email: Where is my order 4417? It's been ten days.
Label: order_status

Email: The saddle is too narrow, how do I send it back?
Label: returns

Email: Does the Trail 2 frame fit 29-inch wheels?
Label: product_question

Email: {new email}
Label:

Examples teach what descriptions struggle to: the precise format, the tone, and where the line falls between similar categories. A rule says "late parcels are order_status"; an example shows what a late parcel sounds like.

Choose examples with care, because the model imitates them closely:

  • Aim at the boundary. Include the cases the model gets wrong, like an angry late-delivery email labelled order_status.
  • Balance the labels. If most examples say returns, answers drift toward returns.
  • Vary the surface. Different lengths, products and wording, so the model learns the rule, not a phrase.
  • Match the format exactly. Whatever your examples look like, the output will copy it.

A handful of examples is usually enough. More cost tokens on every request and give diminishing returns.

Examples also quietly fix format. If you need replies shaped exactly like Label: returns with nothing else, two examples in that shape often beat a paragraph explaining it. And when examples and instructions disagree, models often lean toward the examples, so update both together whenever the rules change.

The shortcut

Start zero-shot; add one example for each mistake you see. Each example should answer the question, "What did the model misunderstand?"

Fixing the furious-but-late emailsStep 1 of 4
  1. Run zero-shot

    Late-delivery complaints with angry wording come back as returns.

The trap is testing only on the examples you added. Of course they pass; the proof is emails the prompt has never seen.

Drills

Answer fast — trust the rule.

quick drill

A prompt describes the task but contains no worked examples. What is it?

quick drill

Four of your five examples are labelled returns. What is the likely effect?

quick drill

Which example most helps with the late-delivery confusion?

quick drill

How should you check whether the new examples worked?

Remember

  • Zero-shot tells the model; few-shot shows it.
  • Start zero-shot; add one example per mistake.
  • Balance labels, aim at the boundary, test on unseen inputs.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainChoose the examples

Pedal Point's ticket classifier keeps labelling complaints about late deliveries as 'returns'. You decide to add examples to the prompt. Explain how many you would add, how you would choose them, and one way the examples themselves could make things worse.