Few-Shot Prompting
Few-shot prompting teaches the model by demonstration. Instead of describing what you want, you show it — with input/output examples that establish the exact pattern to follow.
What is few-shot prompting?
Few-shot prompting means including a small number of worked examples directly in your prompt. The model uses these examples to infer the task format, style, and output structure — without you having to describe it explicitly.
It's one of the most reliable techniques for getting consistent, structured output from LLMs.
Zero-shot, one-shot, few-shot
| Type | Examples in prompt | When to use |
|---|---|---|
| Zero-shot | 0 — just an instruction | Simple tasks, capable models |
| One-shot | 1 example | Format establishment, structured output |
| Few-shot | 2–5 examples | Complex patterns, domain-specific tasks |
When to use few-shot
Few-shot is especially valuable when:
- You need output in a specific, consistent format (JSON, tables, labeled fields)
- The task is domain-specific with non-obvious conventions
- Zero-shot produces inconsistent output despite clear instructions
- You need the model to maintain a specific tone or writing style
Writing good examples
Quality matters more than quantity. 2 excellent examples outperform 5 mediocre ones.
- Cover the variation you expect — if inputs vary in complexity, include examples across that range
- Be consistent in format — every example should look identical in structure
- Use realistic inputs — toy examples don't generalize as well
- Include edge cases — show the model how to handle tricky situations
User: Classify the sentiment: "The delivery was fast but the product broke immediately."
Assistant: {"sentiment": "mixed", "positive": ["fast delivery"], "negative": ["product broke"]}
User: Classify the sentiment: "Absolutely love this! Will buy again."
Assistant: {"sentiment": "positive", "positive": ["love it", "repeat purchase"], "negative": []}
User: Classify the sentiment: "Your text input here..." ← actual promptIn PromptLab
In the Playground, click Few-Shot in the bottom toolbar to open the few-shot panel. Add user/assistant pairs — PromptLab injects them as conversation history before your prompt.
In Prompt Tuning, the Examples layer is your few-shot slot. Toggle it on/off to A/B test whether examples improve your output.