Skip to content
LiveNext 10:46:03

Definition

What is Few-shot prompting?

Few-shot prompting is Few-shot prompting is giving an AI model a handful of worked examples inside your prompt so it copies the pattern, format and tone you want, without any retraining.

Few-shot prompting means putting a small number of examples in your prompt, usually two to five, before you ask the model to do the real task. The model reads the examples, notices the pattern, and continues it.

How it works

A large language model predicts what text should come next. If your prompt shows three product descriptions written in a dry, two-sentence style, the most likely next text is a fourth description in that same style. You are not changing the model. You are changing what it sees right before it answers.

The examples live in the context window, so they cost tokens on every request. They also disappear when the conversation ends. Nothing is saved to the model's weights, which is what separates this from fine-tuning.

Zero-shot, one-shot, few-shot

  • Zero-shot: you give an instruction and no examples.
  • One-shot: you give one example.
  • Few-shot: you give several.

Modern models follow plain instructions well, so zero-shot is often enough. Examples earn their place when the instruction alone is hard to say, such as a specific tone, a strict output layout, or a judgment call like "what counts as urgent."

A quick example

Suppose you want support emails sorted into labels:

Email: "I was charged twice." Label: billing Email: "The app crashes on launch." Label: bug Email: "Can you add dark mode?" Label: feature request Email: "I can't log in after the update." Label:

The model will almost certainly answer "bug," in the same short format as your examples.

Tips that make it work

  • Make the examples varied. Three near-identical examples teach the model the wrong lesson.
  • Include a tricky case, not only easy ones.
  • Keep the format of every example identical, down to punctuation.
  • Check the order. Models can lean toward the last example they saw.
  • If the answer must be a fixed format, pair examples with structured output.

When to move on

If you need dozens of examples to get reliable results, or your prompt is getting expensive, that is a signal to try fine-tuning or to tighten the instructions. For reasoning problems, examples that show the steps can help, which connects few-shot prompting to chain of thought.

Few-shot prompting is one of the core techniques of prompt engineering: show the model what good looks like, and it will usually match it.

Questions people ask

What is the difference between zero-shot and few-shot prompting?

Zero-shot gives the model only an instruction. Few-shot adds a small number of worked examples so the model can copy the pattern.

How many examples should a few-shot prompt have?

Usually two to five varied examples is enough. More examples cost more tokens and often add little.