liveBook · Manning

Few-shot learning

As explained in Understanding AI

Few-shot prompting is a prompting technique in which a model receives multiple examples before performing a task.

Want a model to follow a pattern without writing a long rulebook? Few-shot prompting provides several examples before the actual task, letting the model infer the expected format, style, or classification pattern. section 3.2.2

Use few-shot prompting when:

Sentiment classification

Example 1: Review: "The battery life is excellent." Sentiment: Positive. Example 2: Review: "Charging takes too long." Sentiment: Negative. Review: "The vehicle is comfortable and easy to drive." Sentiment: Positive. Several labeled examples establish the pattern more clearly than an instruction alone. section 3.2.2

Figure 3.4 Three common prompting approaches. In zero-shot prompting, the model receives only a task. In one-shot prompting, a single example is provided. In few-shot prompting, multiple examples are provided to establish a clearer pattern.

Compare the progression from zero-shot prompting, which gives only a task, to one-shot and few-shot prompting, which provide increasingly clear examples. section 3.2.2

Start with zero-shot prompting, add one example when results are inconsistent, and provide several examples when the task remains ambiguous. Examples guide output; they do not remove the need to evaluate it. section 3.2.2 section 3.5

How Understanding AI covers it

How deep it goes
Explains the technique through definition, comparison, use cases, and one worked classification example, without covering underlying model internals.
Examples
Demonstrates sentiment labels for vehicle reviews and contrasts task-only, single-example, and multiple-example prompts.
What it assumes
Assumes familiarity only with asking a language model for a task and teaches the progression from zero-shot to few-shot prompting.
What you can do after
Apply it via prompt examples to improve consistency when instructions alone leave format, style, or classification ambiguous.
How it connects
Connects few-shot prompting with zero-shot prompting, one-shot prompting, prompt engineering, and classification.

Also explained in

Compare how 24 books explain few-shot learning →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Understanding AI. The section links point to the parts of the book it draws on.