Skip to content

Few-Shot Prompting With Examples

Showing a model a few examples of the input and output you want is often clearer than describing it. How to choose good examples.

Editorial team 2 min read

Few-shot prompting includes a small number of worked examples in the prompt so the model can infer the pattern.

When It Helps

  • A particular output format or style that's hard to describe.
  • Classification into your own categories.
  • Extraction where edge cases need showing, not telling.
  • Matching a house tone of voice.

Example

Classify each support message as billing, technical or other.

Message: "I was charged twice this month."
Category: billing

Message: "The export button does nothing."
Category: technical

Message: "Do you have an office in Perth?"
Category:

Choosing Good Examples

  • Representative: cover the common cases.
  • Varied: differ in length, wording and difficulty, so the model doesn't copy surface features.
  • Include edge cases: ambiguous or tricky inputs with the answer you want.
  • Balanced: don't show five examples of one class and one of another.
  • Correct: a wrong example teaches the wrong behaviour.

How Many?

Often three to five is enough. More examples cost more tokens and help less once the pattern is clear.

Combine With Instructions

Examples work best alongside a clear instruction explaining the task and any rules the examples might not make obvious.

Keep Evaluation Separate

Don't reuse your test cases as prompt examples, or your evaluation will overstate performance.

More in Generative AI

All Generative AI guides →
Generative AI Guide · 2 min

Prompt Engineering Fundamentals

The building blocks of a good prompt — context, task, constraints and format — with before-and-after examples.

Generative AI 2 min read 24 Jul 2026

Generative AI Guide · 2 min

Getting Structured Output From LLMs

How to get JSON and other machine-readable output reliably from a language model, and how to validate it.

Generative AI 2 min read 22 Jul 2026

Generative AI Guide · 2 min

Why Language Models Hallucinate

What hallucination is, why it happens, and practical ways to reduce and catch it.

Generative AI 2 min read 21 Jul 2026

Generative AI Guide · 2 min

Retrieval-Augmented Generation (RAG) Explained

How RAG grounds a language model's answers in your own documents, the components involved, and where it goes wrong.

Generative AI 2 min read 20 Jul 2026