Prompt Engineering – Zero-shot, One-shot, Few-shot & Chain-of-Thought Prompting
Same task, four prompts — how much example and reasoning scaffolding you give changes everything
Same task, four prompts — how much example and reasoning scaffolding you give changes everything
Zero/one/few-shot describe how many worked examples you put in the prompt before asking the real question; chain-of-thought asks the model to show intermediate reasoning before its final answer. All four are ways of shaping an LLM's output without touching its weights.
Prompt engineering is the cheapest lever you have over an LLM's behavior — no fine-tuning, no extra infrastructure, just structuring the input. Picking the right style (and knowing when fancier isn't better) is directly relevant to anyone building on top of an LLM, and it's a favorite exam topic because it's easy to test with a concrete example.
All four techniques are about in-context learning — giving the model information inside the prompt itself, at inference time, rather than training it further:
Below is the same task — classifying a review's sentiment as Positive, Negative, or Mixed — written in all four styles, so the contrast is visible directly.
Zero-shot
Classify the sentiment of this review as Positive, Negative, or Mixed.
Review: "The battery life is amazing but the screen cracked within a week."
Sentiment:One-shot
Classify the sentiment of the review as Positive, Negative, or Mixed.
Review: "This laptop runs so fast and the design is sleek."
Sentiment: Positive
Review: "The battery life is amazing but the screen cracked within a week."
Sentiment:Few-shot
Classify the sentiment of the review as Positive, Negative, or Mixed.
Review: "This laptop runs so fast and the design is sleek."
Sentiment: Positive
Review: "Terrible purchase, it stopped working after two days."
Sentiment: Negative
Review: "Great camera, but the battery drains too quickly."
Sentiment: Mixed
Review: "The battery life is amazing but the screen cracked within a week."
Sentiment:Chain-of-thought
Classify the sentiment of the review as Positive, Negative, or Mixed. Think step by step about
each aspect mentioned before giving the final answer.
Review: "The battery life is amazing but the screen cracked within a week."
Reasoning: The review mentions two aspects — battery life (positive) and screen durability
(negative). Since a clear positive and a clear negative are both present, the overall sentiment
is mixed rather than purely one or the other.
Sentiment: MixedNotice the few-shot example is also the one most likely to correctly produce "Mixed" rather than forcing a binary Positive/Negative choice — simply because it's the only style that demonstrates the Mixed class exists before the real question arrives.
Applying the few-shot prompt above: the model has now seen one Positive, one Negative, and one Mixed example before the real review. Given that the real review explicitly states one positive aspect (battery) and one negative aspect (screen), the few-shot context makes "Mixed" the pattern- consistent answer — compare this to the zero-shot version, which (with no demonstrated Mixed class) is more likely to force a binary Positive-or-Negative call.
Zero/one/few-shot vary how many demonstrations you give; CoT varies whether you ask for visible reasoning — pick based on whether the task's difficulty is in knowing the pattern (more examples help) or in reasoning through the answer (CoT helps).