Stage 2 · Lesson 4 of 9
Few-shot examples
are two to five sample inputs, each with its ideal output, placed in the prompt. They are often the fastest way to fix format and tone, because an example is harder to misread than a description. Choose them on purpose.
Cover the common case, an , and a case where the right answer is a refusal or "unknown". Mark them clearly as examples, for instance inside <example> tags, so the model does not treat them as real input. Watch out for copying.
Models imitate surface details, so if all three examples start the same way or all have three items, the outputs will too. Vary them. And never reuse your questions as examples, or your tests only check what you already showed the model.
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- CoursePaidGrokking Prompt Engineering for Software Engineers
Design Gurus · Beginner · Subscription
Prompting patterns for engineers building features, not for chatting
- ToolFreeVercel AI SDK Documentation
Vercel · Intermediate
Free: the Foundations and Getting Started guides for prompts, generateText and streamText
Practise
Keep handy
Also worth your time
Few-shot, chain of thought, JSON enforcement and parsing failures in one place