Sub topic 1
Starting point: zero-shot prompts and where they fall short
Prerequisites
This chapter assumes you know three things:
- What a large language model (LLM) is, and that a prompt produces a completion.
- How to read short Python code.
- The roles in a chat-style prompt: system, user, and assistant.
What a zero-shot prompt is
A zero-shot prompt gives the model an instruction and an input, with no examples of the finished task. The model relies only on what it learned in training and on the words you wrote.
Classify the sentiment of this review as positive, negative, or neutral.
Review: The screen is bright but the speakers are weak.
Sentiment:For common tasks this often works. Modern models have seen many sentiment labels, summaries, and translations, so a clear instruction is enough. Zero-shot is also the right place to start. It is the cheapest prompt, the shortest, and the easiest to read. It also gives you a baseline score to compare against later.
Where zero-shot falls short
Zero-shot prompts fail in predictable ways. Each failure comes from something the instruction leaves open.
| Failure | What happens | Example |
|---|---|---|
| Format drift | The answer is correct but shaped differently each time | "Positive.", "The sentiment is positive", "**Positive**" |
| Unclear label rules | The model draws the category lines somewhere you did not intend | A mixed review is labeled neutral one time and negative the next |
| Style mismatch | The tone or length does not match what you need | A long paragraph where you wanted one word |
| Unusual task | The task is specific to your data or team, so training gives no hint | Tagging support tickets with your internal category codes |
The common cause is ambiguity. An instruction is a description, and descriptions can be read more than one way. Showing the model what you mean is often shorter and clearer than describing it.
Seeing the problem in code
The function below builds a zero-shot prompt. It then checks whether a reply is exactly one of the allowed labels, which is what a program reading the output would need.
LABELS = {"positive", "negative", "neutral"}
def zero_shot_prompt(review):
return (
"Classify the sentiment of this review as positive, "
"negative, or neutral.\n\n"
f"Review: {review}\n"
"Sentiment:"
)
def is_clean(reply):
return reply.strip().lower() in LABELS
replies = [
"positive",
"Sentiment: positive",
"The review is mostly negative, though it praises the screen.",
]
for reply in replies:
print(repr(reply), "->", is_clean(reply))Running it prints:
'positive' -> True
'Sentiment: positive' -> False
'The review is mostly negative, though it praises the screen.' -> FalseAll three replies may be reasonable to a human reader. Only the first can be used directly by code. You could add a line such as "Answer with one word", and that often helps. But it does not settle where the boundary between negative and neutral sits for your data.
A workflow for deciding
- Write the clearest zero-shot instruction you can, including the allowed output format.
- Run it on a small set of real inputs, including awkward ones.
- Record how many outputs are wrong in label, wrong in format, or wrong in style.
- If the errors come from ambiguity, add examples. This is few-shot prompting, the subject of the next chapter.
Common mistakes at this stage
- Judging a prompt on one or two easy inputs. Test awkward cases too.
- Skipping the baseline. Without a zero-shot score, you cannot tell whether examples helped.
- Stacking more and more rules into the instruction. Long rule lists can conflict, and the model may ignore some of them.
Exercise
A zero-shot prompt asks a model to label support tickets as "billing", "bug", or "other". The labels are right, but replies come back as "This looks like a billing issue." Your parser expects a single word. Name the failure type from the table, and give one change to try before adding examples.
Show answer
This is format drift. The content is correct, but the shape of the answer varies. First try tightening the instruction, for example "Answer with exactly one word: billing, bug, or other." If outputs still vary, or the model disagrees with you about which tickets count as "other", add examples.