Advanced

At the close of the Basics part, we trained a recurrent neural network on H. G. Wells’s The Time Machine. Prompted with the words “The Time Traveller”, that small model produces recognizable English words and punctuation, yet its grammatical coherence unravels after a dozen characters. By contrast, today’s frontier foundation models—built from the very same elementary primitives of parameterized layers, loss functions, automatic differentiation, and gradient-based optimizers—hold extended technical conversations, write and debug software, solve competitive mathematics problems, and synthesize photorealistic images and video from a sentence of text.

What separates a classroom prototype from a modern frontier system? Crossing that gap requires solving four fundamental challenges that small models on toy datasets never encounter:

  1. Optimization stability and scaling. In Basics, we treated minibatch stochastic gradient descent, learning-rate schedules, and batch sizes largely as convenient recipes. As networks grow to millions or billions of parameters, however, a learning rate that trains a narrow layer smoothly can cause a wider or deeper network to diverge instantly, and poorly conditioned loss surfaces can stall progress for millions of steps.
  2. Long-range memory and parallel sequence processing. A classical recurrent network is forced to compress everything it has read into a single fixed-width hidden vector before knowing which details will matter later—and because each time step waits for the previous one, recurrent training cannot exploit the massive parallelism of modern GPUs.
  3. Hardware bottlenecks and distributed systems. Modern accelerators perform floating-point arithmetic far faster than they can move tensors between off-chip memory and on-chip registers, or across network links between GPUs. At scale, a model’s real-world training and inference speed is governed as much by memory bandwidth, numerical precision, and communication topology as by its raw operation count.
  4. Learning beyond static labels. Supervised cross-entropy works whenever every input has a unique ground-truth label. Yet an autonomous agent acting in an environment must learn from delayed, sparse scalar rewards whose distribution shifts as the agent’s own policy changes; and a generative model synthesizing high-resolution images has no single target label to match, requiring objectives that compare entire probability distributions or reverse continuous corruption processes.

The nine chapters of this part—implemented in both PyTorch and JAX—tackle these four challenges systematically:

These chapters do not need to be read strictly in linear order; the dependency diagram in the Preface (Figure 1) maps out which chapters build on which. Together, they provide the architectural, mathematical, and systems toolkit that the Language Models and Image Models parts apply to large-scale foundation models.