Skip to main content
ModelTerms

Prompting · beginner

Few-Shot (few-shot prompting, in-context learning)

Few-shot prompting includes a small number of input-output examples directly in the prompt so the model can pattern-match without any fine-tuning.

Explanation

Demonstrating "Q: ... A: ..." pairs for 3-5 examples then leaving the final Q empty often dramatically improves performance, especially for unusual formats or classification schemes the model has not seen.

Few-shot is sometimes called in-context learning: the model "learns" the task from the examples in the context window, without any weight update. The effect was the headline finding of the GPT-3 paper in 2020.

Examples

  • Three (sentiment, label) pairs followed by a new sentence to classify.
  • Five examples of "convert this English sentence to SQL" before asking for a new query.

When to use few-shot

When zero-shot quality is unstable or the output format is unusual.

Frequently asked

What is Few-Shot?

Few-shot prompting includes a small number of input-output examples directly in the prompt so the model can pattern-match without any fine-tuning.

What is an example of few-shot?

Three (sentiment, label) pairs followed by a new sentence to classify.

How is Few-Shot related to Zero-Shot?

Few-Shot and Zero-Shot are both prompting concepts. Zero-shot prompting asks the model to perform a task without showing any examples — only the instruction and the input. Modern instruction-tuned models do this well.

When should I use few-shot?

When zero-shot quality is unstable or the output format is unusual.

Is Few-Shot considered beginner?

Few-Shot is generally considered beginner-level material in the AI and LLM space.

Side-by-side comparisons

Sources