liveBook · Manning

Few-shot learning

As explained in Build a Large Language Model (From Scratch)

The ability to learn a new task from only a few examples rather than extensive training data.

Few-shot learning lets a GPT-like language model perform a new task from a minimal number of examples supplied in the input, without retraining or task-specific architecture changes. section 1.4

Few-shot learning fits into the LLM workflow as follows:

  • A pretrained model performs text completion and uses example inputs to infer the target task. section 1.3
  • Examples are placed directly in the prompt, unlike fine-tuning, which trains further on labeled data. section 1.4 section 1.3
  • Zero-shot learning omits task-specific examples, while few-shot learning includes a small number of them. section 1.4
Figure 1.6 In addition to text completion, GPT-like LLMs can solve various tasks based on their inputs without needing retraining, fine-tuning, or task-specific model architecture changes. Sometimes it is helpful to provide examples of the target within the input, which is known as a few-shot setting. However, GPT-like LLMs are also capable of carrying out tasks without a specific example, which is called zero-shot setting.
figure

Compare zero-shot and few-shot prompting, including how target examples appear in the input without model retraining. section 1.4

How Build a Large Language Model (From Scratch) covers it

How deep it goes
Defines few-shot and contrasts it with zero-shot learning, but stops short of prompt construction or implementation details.
Examples
Uses target examples embedded in an input prompt and contrasts them with example-free zero-shot inputs.
What it assumes
Assumes familiarity with pretrained LLMs and text completion while distinguishing few-shot learning from fine-tuning.
What you can do after
Apply it via GPT-like LLM inputs that provide a few task examples without retraining or changing model architecture.
How it connects
Connects few-shot learning with GPT, text completion, zero-shot learning, pretraining, fine-tuning, and transformer architecture.

Also explained in

Compare how 18 books explain few-shot learning →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Large Language Model (From Scratch). The section links point to the parts of the book it draws on.