What it is
Few-shot prompting means including a small number of worked examples (typically two to five) in your prompt before the real task. Each example pairs an input with the output you want, and the model infers the pattern and applies it to the new input.
It's the difference between describing a style and demonstrating it. When something is easier to show than to explain, show it.
When to use it
- You need a consistent format or house style that is hard to describe in words
- Classifying or labeling items using rules that are specific to you
- Zero-shot attempts keep drifting in tone, length, or structure
- Transforming data from one shape to another (messy notes into clean records)
- Matching an existing voice, such as your past product descriptions or social posts
How it works
Why it works
Language models are strong pattern-followers. When a prompt contains several input→output pairs, the model picks up on the length, tone, vocabulary, structure, and even the implicit decision rules, then continues the pattern for the next input. You don't retrain anything; the examples simply steer the response.
A practical example
Say you want customer feedback tagged the way your team does it:
Classify each piece of customer feedback as BUG, FEATURE_REQUEST, or PRAISE. Reply with the label only. Feedback: "The export button does nothing when I click it." Label: BUG Feedback: "Would love a dark mode for late-night work." Label: FEATURE_REQUEST Feedback: "Setup took two minutes. Honestly impressed." Label: PRAISE Feedback: "The app crashes whenever I upload a photo from my phone." Label:
Ending on an open Label: makes the expected next step obvious.
Choosing good examples
Examples teach everything they contain, including things you didn't intend:
- Cover the variety. Include each category or case you care about, plus a tricky edge case if you have one.
- Vary the surface. If every example is short and about billing, the model may assume all answers should be short and about billing.
- Mix the order. Don't put all examples of one label together, or the last label may get over-used.
- Keep the format identical across examples so the pattern is unmistakable.
Watch out: The model may copy details from your examples too literally, such as reusing a name or number. Use clearly fictional or varied content, and add an instruction like "don't reuse details from the examples."
Combine with instructions
Few-shot works best alongside a clear instruction, not instead of one. State the task, then show examples. Two to five examples are usually enough; adding many more lengthens the prompt without always improving results.
Step by step
- 1
Write a one-sentence instruction describing the task and output format.
- 2
Pick 2–5 examples that cover the main cases, including at least one tricky one.
- 3
Format every example identically (same labels, same separators, same order of fields).
- 4
Vary the examples' length, topic, and order so the model learns the rule, not a coincidence.
- 5
Add the real input in the same format and leave the output slot open.
- 6
Test on a few new inputs; if a case fails, add or swap an example that covers it.
Weak vs strong
Write a product description for our ceramic mug in the same style as our other ones. Make it good.
Write a product description in our house style. Here are two examples: Product: Linen tea towel Description: Soft from day one, softer every wash. Stonewashed linen that dries fast and looks better rumpled. 50 x 70 cm. Product: Oak cutting board Description: One solid piece of oak, oiled by hand. Heavy enough to stay put, handsome enough to serve on. 40 x 25 cm. Product: Speckled ceramic mug, 350 ml Description:
Practical use cases
Consistent labeling
Tag support tickets, survey answers, or expenses into your own categories with a handful of labeled examples.
Matching a brand voice
Paste two or three past posts or product blurbs so new ones sound like they came from the same writer.
Data cleanup
Show how messy entries like "jon smith, ACME, 555 1234" should become clean structured rows, then process the rest.
Teaching a format
Demonstrate a specific flashcard, changelog, or meeting-note format once or twice so every future one matches.
Practice exercise
Build a mini classifier. Pick something you sort regularly: emails (reply / read later / ignore), recipes (weeknight / weekend), or expenses (food / travel / software).
- Write a one-line instruction and three labeled examples, one per category.
- Test it on five new items. Note any mistakes.
- Add or replace one example to fix the most common mistake, and test again.