§1.5–1.8Scale, the GPT Architecture, and the Roadmap

Foundations pp. 4–6 · ~7 min read

  • emergent behavior
  • zero-shot
  • few-shot
  • autoregressive
  • foundation model

We now know an LLM is a pretrained-then-fine-tuned transformer. Two questions remain before we start building: what data makes pretraining work, and what exactly the GPT architecture is. Then §1.7 lays out the three-stage roadmap the rest of the book follows.

1.5 Utilizing large datasets

The “large” in LLM is as much about the corpus as the model. GPT-3 was pretrained on a blend of web crawls, books, and Wikipedia totalling hundreds of billions of tokens. The striking thing about the mix is that the proportion each source contributes to training is not the same as its raw size — only a fraction of each dataset is actually sampled, weighting quality over sheer volume. Click any row to see why.

DatasetDescriptionTokens (billions)Share of training (%)
CommonCrawl (filtered)Web crawl data410
60
+
WebText2Web crawl data19
22
+
Books1Internet-based book corpus12
8
+
Books2Internet-based book corpus55
8
+
WikipediaHigh-quality text3
3
+
GPT-3's pretraining data mix (book table, p. 6). Bars show each source's share of the sampled training tokens. Click a row for detail; click a header to sort.

Pretraining a model at this scale is expensive — training GPT-3 is estimated to have cost several million dollars in compute — which is exactly why, in Chapter 5, we will load OpenAI’s already-pretrained weights rather than pay to reproduce them, and only pretrain our small model on a tiny dataset to prove the mechanism works.

Emergent behavior

Something surprising happens as these models scale up. Trained only to predict the next word, large models begin to exhibit emergent behavior — abilities like translation, arithmetic, and multi-step reasoning that were never explicitly part of the training objective. These capabilities are not attributable to any single parameter; they appear spontaneously as a product of scale and are largely absent in smaller models.

model scale (parameters, log) →task capability →emergencethresholdflat for small modelssharp rise
Emergent abilities: near-zero for small models, then a steep climb once the model crosses a scale threshold.

1.6 A closer look at the GPT architecture

The model we build is a GPT — a decoder-only transformer. It drops the encoder half of the original transformer entirely and keeps only the decoder, trained on the single self-supervised task of predicting the next word. Because each prediction is fed back in to help produce the next one, generation is autoregressive : the model consumes its own output, one token at a time.

ThecatsatontheGPTmat
1

Predict the next token

Given "The cat sat on the", the model outputs a probability distribution over the whole vocabulary and picks the most likely next token: "mat".

1 / 3

Autoregressive generation: the model predicts one token, appends it, and feeds the longer sequence back in.

This deceptively simple objective is what enables zero-shot and few-shot use: a large enough GPT can perform a brand-new task from the prompt alone (zero-shot) or from a handful of in-prompt examples (few-shot), with no weight updates at all — a direct consequence of the emergent behavior above.

1.7 Building an LLM — the three-stage roadmap

Here is the plan for the whole book. Keep this map in mind; every chapter slots into one of these three stages.

STAGE 1 — Build1. Data prep(ch2)2. Attention(ch3)3. Architecture(ch4)Building an LLM4. PretrainSTAGE 2 — Pretrain5. Trainingloop (ch5)6. Evaluate(ch5)Foundation model7. load weights8/9. fine-tuneSTAGE 3 — Fine-tuneClassifierclass labels · ch6Assistantinstructions · ch7
The book’s roadmap. Stage 1 (ch2–4) builds the model, Stage 2 (ch5) pretrains it into a foundation model, Stage 3 (ch6–7) fine-tunes it. Keep this map handy — each chapter is one box.

1.8 Summary

  • An LLM is a deep neural network trained on massive text; “large” spans both its billions of parameters and its huge corpus.
  • LLMs rely on the transformer and its self-attention mechanism; deep learning removed the need for manual feature engineering.
  • They are trained in two steps: pretraining on unlabeled text (self-supervised next-word prediction) yields a foundation model , which fine-tuning then specializes.
  • GPT is a decoder-only, autoregressive transformer. At scale it shows emergent behavior and can work zero- or few-shot.
  • The book proceeds in three stages: build (ch2–4) → pretrain (ch5) → fine-tune (ch6–7). Next up: Chapter 2 turns raw text into the tokens and embeddings the model actually consumes.

📝 Check yourself: scale, GPT, and the roadmap

0 / 5
  1. 1.In GPT-3's training mix, which single source contributed the largest share of the sampled tokens?

  2. 2.GPT-3 was trained on hundreds of billions of tokens but the book notes only a fraction were actually sampled. What is the headline parameter count of GPT-3?

  3. 3.What does 'emergent behavior' mean in the context of LLMs?

  4. 4.GPT performs 'few-shot' learning. What does that mean?

  5. 5.In the book's three-stage roadmap, what is produced at the end of Stage 2 (pretraining)?