Examples for Format & Edge Cases
Pin output shape and clarify tricky boundaries.
Why Format Examples Exist
Instructions tell Claude what to do. Examples show it exactly what the output should look like.
Few-shot prompting means dropping 2-4 targeted examples into your prompt. The model generalizes from them - it doesn't just copy them back. In this lesson we use examples for two jobs: pinning the output shape and clarifying tricky edge cases.
These two jobs are where few-shot earns its keep: consistency, output format, and reducing hallucination on the weird inputs.
The Problem: Drifting Shape
Imagine you ask Claude to extract a date. Sometimes you get 2026-06-10, sometimes June 10, 2026, sometimes 10/06/2026. Every variation breaks the code that consumes the output.
A prose instruction like "return the date" is ambiguous. Vague guidance produces vague consistency. The fix is to show the exact shape you want instead of describing it.
All lessons in this course
- Why 2-4 Examples Work
- Examples for Format & Edge Cases
- Generalization vs Repetition
- Few-Shot to Reduce Hallucination