Sub topic 1
Starting Point: Zero-Shot Prompts and Where They Fall Short
Prerequisites
You should understand how a language model generates a completion from a prompt, read short Python code, and recognize system, user, and assistant roles in chat prompts.
Zero-Shot Prompting
A zero-shot prompt gives the model an instruction without showing labeled examples. For instance:
Classify the review as positive, negative, or neutral. Answer with one word.
Review: The screen is bright but the speakers are weak.
Sentiment:This may work for familiar tasks. However, the model must infer several details from the instruction:
- What each label means.
- How much explanation to provide.
- Whether capitalization matters.
- What output format the caller expects.
- How to handle mixed or ambiguous input.
Small wording changes can produce different behavior. A model might answer mixed, explain its choice, or return Sentiment: negative when an application expects only negative.
What Few-Shot Prompting Adds
Few-shot prompting includes a small number of input-output examples in the prompt. The model uses these examples through in-context learning, which is the ability to adapt its response pattern from information in the current context without changing its trained parameters.
Classify each review as positive, negative, or neutral. Answer with one word.
Review: The battery lasts all day and charging is fast.
Sentiment: positive
Review: It stopped working after a week.
Sentiment: negative
Review: The package arrived on Tuesday.
Sentiment: neutral
Review: The screen is bright but the speakers are weak.
Sentiment:The examples teach both the task and its interface. They make the intended boundary between labels and the required output shape more concrete.
Anatomy of a Good Example
Each example should contain a clearly separated input and output. Use stable labels such as Review: and Sentiment:. Choose examples whose outputs are correct, unambiguous, and representative of real requests.
Examples should demonstrate the difficult decisions, not merely repeat easy cases. If reviews can contain both praise and criticism, include a mixed example and define which label applies.
Format and Wording Consistency
Keep the instruction, delimiters, label spelling, and output style consistent across examples. Do not alternate between Sentiment: positive, positive, and explanatory sentences unless that variation is intentional.
Exercise
Why can a few-shot prompt outperform a clearer zero-shot instruction?
Show answer
It demonstrates the intended decisions and exact output format, reducing what the model must infer from prose.