liveBook · Manning

Self-supervised learning

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

A training approach in which the model derives supervision signals from the input data itself rather than from human-provided labels.

Self-supervised learning trains a model without human-provided labels by deriving targets from the input data itself. In LLM pretraining, the next word becomes the label for the preceding sequence, allowing training on massive unlabeled text collections. section 1.3 section 1.6

The GPT pretraining workflow connects self-supervision to the model pipeline:

  • Prepare large amounts of raw text, with filtering such as removing formatting characters or documents in unknown languages. section 1.3
  • Use each sequence to create training pairs: preceding words provide the input, and the upcoming word provides the target. section 1.6
  • Train a decoder-style GPT model autoregressively, predicting one word at a time from the words that precede it. section 1.6
  • Continue with supervised fine-tuning when task-specific labeled data, instruction-answer pairs, or class labels are available. section 1.3

Next-word prediction

Given a sentence prefix, the model predicts the next word. Repeating this task across large text datasets teaches patterns in how words and phrases fit together, producing a pretrained model that can later support text completion, spelling correction, classification, and translation. section 1.6 section 1.3

Figure 1.7 In the next-word prediction pretraining task for GPT models, the system learns to predict the upcoming word in a sentence by looking at the words that have come before it. This approach helps the model understand how words and phrases typically fit together in language, forming a foundation that can be applied to various other tasks.
figure

Shows how GPT predicts each upcoming word from the preceding sequence and uses the resulting language patterns as a foundation for other tasks. section 1.6

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

How deep it goes
Explains on-the-fly next-word labels and GPT’s autoregressive flow, but defers implementation details.
Examples
Uses raw text, sentence prefixes, upcoming words, and GPT text completion as concrete training examples.
What it assumes
Contrasts self-supervised pretraining with conventional supervised learning and introduces labeled fine-tuning afterward.
What you can do after
Apply self-supervision by training a GPT-style model to predict upcoming words from large unlabeled text datasets.
How it connects
Connects pretraining with next-word prediction, GPT, transformer decoders, autoregressive models, and fine-tuning.

Also explained in

Compare how 8 books explain self-supervised 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.