PromptLab Docs
DocsCore Concepts
Back to App

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

TypeExamples in promptWhen to use
Zero-shot0 — just an instructionSimple tasks, capable models
One-shot1 exampleFormat establishment, structured output
Few-shot2–5 examplesComplex 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 prompt

In 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.

💡 Tip
Start with zero-shot. If the output format is inconsistent, add one example. If it's still inconsistent, add two more. Avoid adding more examples than necessary — they consume tokens.