5.1.3. Zero-Shot and Few-Shot Prompting
💡 First Principle: "Shots" are examples you provide. Zero-shot gives the model only an instruction; few-shot gives it a handful of input→output examples to lock in a pattern or format. You add shots when the shape of the answer matters more than the instruction alone can convey.
The distinctions the exam expects:
- Zero-shot — instruction only, no examples. ("Write a function that validates an email address.") Best for common, well-understood tasks where the model already knows the pattern.
- One-shot — a single example to demonstrate the desired form.
- Few-shot — multiple examples that establish a pattern, format, or convention the model should mirror. Best when you need a specific output shape, naming style, or edge-case handling that an instruction alone wouldn't pin down.
A worked example: asking for a standard FizzBuzz is fine zero-shot. But if you need test cases in your team's specific assertion style, two or three example tests (few-shot) get the model to mirror that style far more reliably than describing it in words.
💡 Key Point: Few-shot is a tool for shaping form, not a universal upgrade. It costs context space, so use it when the pattern genuinely needs demonstrating.
⚠️ Exam Trap: "Few-shot always beats zero-shot" is false. For common tasks, zero-shot is often enough and more efficient. Examples help when the desired format or convention is specific.
Reflection Question: When does providing examples (few-shot) clearly earn its cost, and when would zero-shot be the better, leaner choice?