Scaling Laws and Pretraining: Why Bigger Became Better
Hook #
You've arrived at the final course, and it answers the question the whole Deep Learning and NLP arc has been building toward: how did "predict the next word" — the humble n-gram task from the classical-toolbox lesson — become ChatGPT, Claude, and Gemini? The answer is shorter and stranger than you'd expect: scale. Take the decoder-only transformer from the last quarter, train it on next-token prediction (the same self-supervised objective — no labels, just text), and then make it bigger: more parameters, more data, more compute. That's it. There was no fundamental new idea between GPT-2 and GPT-4 — the architecture is essentially the same transformer; what changed is the scale (GPT-2 had ~1.5 billion parameters; GPT-3 had 175 billion; GPT-4 is larger still and trained on far more data). And the deeply surprising empirical fact — the one that reorganized the entire field — is that scaling works, predictably: model quality improves as a smooth mathematical function (a power law) of size, data, and compute. These are the scaling laws, and they turned "make it bigger" from a hunch into a science you can plan — you can predict how much better a model will be before you train it, which is why labs spend hundreds of millions of dollars on a single training run with confidence it'll pay off. Stranger still, at large scale, models exhibit emergent abilities — capabilities (arithmetic, reasoning, following instructions, translation) that were absent in smaller models and appear as if a switch flipped once the model got big enough. This lesson explains scaling laws (why bigger got better, predictably), pretraining at scale (the same next-token objective, now on the whole internet), the GPT-2→3→4 evolution (scale, not new ideas), and emergence (why scale produced qualitatively new behavior) — the foundation of everything else in this course.
What you'll be able to do by the end of this lesson #
- Explain what an LLM fundamentally is — a decoder-only transformer (from 15.3) trained on next-token prediction (the language-modeling objective from 16.1's classical toolbox), scaled up enormously — and why "it's just autocomplete" is both true and radically incomplete.
- Explain scaling laws — model loss falls as a smooth power law in model size, dataset size, and compute — and why this made LLM development predictable and plannable (you can forecast a model's quality before training it), including the Chinchilla correction (compute-optimal training needs far more data per parameter than early models used).
- Trace the GPT-2 → GPT-3 → GPT-4 evolution as primarily a story of scale (parameters, data, compute), not new architecture — and understand pretraining at this scale (self-supervised next-token prediction on a large fraction of the internet, one enormously expensive one-time run).
- Explain emergent abilities — capabilities that are absent in small models and appear at large scale (in-context learning, multi-step reasoning, instruction-following) — and connect this to "the bitter lesson": general methods that scale with compute tend to beat clever hand-engineered ones.
A quick try before we start #
Here's the whole surprise of modern AI in one thought experiment. In the classical-toolbox lesson, you met the n-gram language model: predict the next word by counting short sequences. It was crude — tiny context, no generalization. Now imagine you don't count; you train a transformer (unlimited-context, generalizing via embeddings) to predict the next word, on a lot of text. A small one is a decent autocomplete. Now make it ten times bigger and train on ten times more text. Then ten times again. And again. What happens? Your intuition might say "it gets a bit better at autocomplete." What actually happens is that somewhere along the way it starts being able to translate languages it was never explicitly taught to translate, answer questions, write code, do arithmetic, follow instructions written in plain English, and reason through multi-step problems — none of which anyone programmed, all of which emerged from "predict the next word, at scale." Why? Because — the profound insight from 15.3 — to predict the next word well across all of human text, you must implicitly learn everything that helps: grammar, facts, logic, arithmetic, code, style, reasoning. A small model learns a little of that; a huge model, trained on enough text, learns a lot of it — enough that the capabilities become usable. And the scaling laws say this improvement is smooth and predictable: plot the loss against compute on a log-log scale and you get a straight line, so you can extrapolate — "if I 10× the compute, the loss drops by this much" — which is why labs bet hundreds of millions on a single run. Hold this: the LLM is not a new idea; it's the n-gram's dream (predict the next word) realized with a transformer and made astonishing by sheer scale — and scale's payoff is predictable enough to plan a company around.
Why this matters here #
This lesson matters because it explains the central mechanism of the entire modern-AI era — scale — and reframes everything you're about to learn. Every capability, cost, and limitation of the LLMs you'll build applications on traces back to scaling a next-token predictor: the model's remarkable generality (it does everything because next-token prediction demanded it learn everything), its enormous cost (training a frontier model costs tens-to-hundreds of millions of dollars in compute — the scaling laws are what justify that spend), its knowledge cutoff (it knows what was in its training data, frozen at pretraining time — which is why you'll need retrieval-augmented generation later to give it fresh or private knowledge), and its confident hallucination (it's optimizing plausibility — next-token likelihood — not truth, exactly as 16.1's generation lesson warned). Understanding scaling laws also demystifies the industry structure you're entering as an AI engineer: the reason only a handful of labs train frontier models (the compute is astronomically expensive), the reason "just use a bigger model" is often the answer and often the wrong answer (bigger is better but also slower and costlier — the match-complexity-to-requirement discipline from 16.1's classification lesson applies hard here), and the reason the field moves at a breathless pace (each scale-up unlocks new emergent abilities). This is the foundation lesson: it tells you what an LLM is and why it behaves as it does, which is the ground everything else in the course stands on.
The deeper significance is "the bitter lesson" and what it means for you as an engineer. Rich Sutton's famous essay observes that, over and over in AI's history, general methods that leverage more computation have beaten clever, human-knowledge-engineered methods — chess, Go, speech recognition, vision, and now language all fell not to hand-crafted expert systems but to general learning algorithms scaled with compute. Early NLP (the classical toolbox — hand-built rules, linguistic features, task-specific models) was the "clever human knowledge" approach; the LLM (one general architecture, one general objective, scaled) is the "leverage computation" approach — and, bitterly for the researchers who spent careers on the former, the general scaled method won decisively. This is a humbling and clarifying lesson for an engineer: it suggests that elegance and hand-crafted cleverness are often not the path to capability — scale and generality are — and it explains why the field bet everything on "make the transformer bigger" rather than "design a smarter architecture." But it's also not the whole story, and the engineer's nuance matters: the bitter lesson is about raw capability, not about deployment — in practice, the smaller/cheaper/faster model is often the right business choice (16.1's ladder), scale has limits (data runs out, costs explode, and the Chinchilla result showed early models were wastefully scaled), and the interesting engineering is increasingly not training bigger models (only a few labs can) but building well with the models that exist — which is what "AI Engineering," the subject of this course, actually is. Understanding scale is understanding both why LLMs are miraculous and why your job is mostly not about scale but about wielding these scaled artifacts wisely.
The engineer's lens #
The first lens is what an LLM actually is — a scaled next-token predictor, no more and no less. Strip away the mystique and an LLM is: a decoder-only transformer (the architecture from 15.3 — self-attention, masked so each token sees only prior tokens, stacked deep), trained via self-supervised next-token prediction (the language-modeling objective from 16.1 — given a prefix, predict the next token; the "label" is just the next token in the text, so no human annotation is needed and you can train on trillions of tokens from the web), at enormous scale (billions of parameters, trillions of training tokens, thousands of GPUs for months). That's the entire recipe. Everything the model does at inference is: given your input tokens, repeatedly predict the next token and append it (autoregressive generation — the same mechanism from 15.3's decoder). "It's just autocomplete" is therefore literally true — and yet radically incomplete, because (15.3's key insight) autocomplete done well enough requires understanding, and scale made it good enough that the understanding became usable. For the engineer, holding both halves is essential: the "just a next-token predictor" half explains the model's failure modes (it hallucinates because it optimizes plausibility not truth; it has a knowledge cutoff because its weights froze at pretraining; it's stateless between calls because it just maps tokens→tokens), while the "but scale made it capable" half explains its power (generality, reasoning, instruction-following). Every good decision you'll make as an AI engineer comes from respecting both — trusting the model's fluency while never trusting its factuality without grounding.
The second lens is scaling laws — turning "bigger" into a predictable science, and the Chinchilla correction. The empirical discovery that reorganized AI is that a language model's loss (its next-token prediction error on held-out text) falls as a smooth power law in three quantities: the number of parameters, the size of the dataset, and the amount of compute — plot loss vs. any of these on log-log axes and you get a straight line over many orders of magnitude. The consequence is profound: model quality became predictable — you can train a few small models, fit the curve, and extrapolate to forecast how good a much larger model will be before spending the money to train it. This is why frontier training runs (tens-to-hundreds of millions of dollars) are fundable: the scaling laws de-risk them. The crucial refinement is Chinchilla (Hoffmann et al., 2022): the original scaling recipe over-invested in parameters and under-invested in data — most large models (including GPT-3) were undertrained, and for a fixed compute budget you get a better model by making it smaller but training it on much more data (roughly, tokens should scale with parameters — ~20 tokens per parameter). This "compute-optimal" insight is why modern models (Llama, etc.) are often smaller than GPT-3 yet better — they're trained on far more data. For the engineer, scaling laws explain the industry's behavior (why labs race to scale, why only a few can afford it, why "a bigger model will probably be better" is a safe bet but "we should train it ourselves" almost never is) and they explain a practical fact you'll live with: newer, smaller, cheaper models frequently beat older, larger ones (because they're better-trained and better-tuned), so "pick the model" is an ongoing evaluation task, not a one-time "biggest wins" decision.
The third lens is emergence and the GPT evolution — why scale produced qualitatively new behavior, and why that's both exciting and unsettling. The scaling laws describe smooth improvement in loss — but the capabilities that ride on top of that loss sometimes appear suddenly. Emergent abilities are capabilities that are absent (near-random) in smaller models and present in larger ones, appearing as a sharp jump rather than a gradual climb: multi-step arithmetic, chain-of-thought reasoning, in-context learning (learning a task from a few examples in the prompt, with no weight updates — the basis of few-shot prompting, next lesson), and instruction-following all emerged at scale. The GPT evolution is the concrete story: GPT-2 (2019, ~1.5B params) was a fluent but unreliable text generator; GPT-3 (2020, 175B params) was the same architecture, ~100× bigger, and it emergently gained in-context few-shot learning — you could describe a task in the prompt and it would do it, no fine-tuning — which was the shock that launched the prompt-engineering era; GPT-4 (2023, larger and multimodal) pushed reasoning, reliability, and breadth further. The through-line: the architecture barely changed; scale did the work, and scale produced not just "more of the same" but qualitatively new abilities. This is exciting (you get capabilities nobody explicitly built) and unsettling (emergent abilities are hard to predict — you don't fully know what a bigger model will be able to do until you train it, which is part of why AI safety, later in this course, is a live concern: capabilities can appear that weren't anticipated). For the engineer, emergence explains why in-context learning / prompting works at all (it's an emergent ability of scaled models — the foundation of the next three lessons), why the field is surprising even to its builders, and why "just try a bigger model on your hard task" is often worth doing (the capability you need may have emerged at a scale you haven't tried). Emergence is where "predict the next word, but bigger" stops sounding mundane and starts explaining how a next-token predictor became something you can converse with.
What to focus on in the resources #
- Hugging Face LLM Course, Ch. 1 (free) — primary. The best structured on-ramp: what an LLM is (scaled next-token predictor), pretraining, model families, with runnable code. Start here; use later chapters as you hit each topic in this course.
- Karpathy — 'Let's Build GPT' + 'Intro to LLMs' (free) — primary. The most demystifying resources anywhere. Build a GPT from scratch (pretraining, the training loop, next-token prediction) so "scale up a transformer to predict the next token" becomes something you've seen implemented. The 'Intro to LLMs' talk is the conceptual companion. The course's 'build GPT' project follows this.
- Scaling-laws papers — Kaplan et al. & Chinchilla (free). Read the abstracts and the key plots even if you skip the math: loss falls as a power law in size/data/compute (Kaplan), and compute-optimal training needs far more data per parameter than early models used (Chinchilla). The shape of the curves is the era's intellectual foundation.
- Skip on first pass: the exact power-law exponents, the compute-optimal derivation, mixture-of-experts and other architecture tweaks, and multimodal details. Get: an LLM = decoder-only transformer + next-token pretraining + scale; scaling laws (smooth power-law improvement → predictable, plannable; Chinchilla → more data per parameter); GPT-2→3→4 = scale, not new ideas; emergent abilities (capabilities appear at scale — in-context learning, reasoning, instruction-following); and the bitter lesson (general methods that scale beat hand-crafted cleverness — but deployment still favors the right-sized model).
Explain it back #
Explain to a colleague what an LLM fundamentally is, what scaling laws are, and why "emergence" matters. A strong answer: an LLM is not a new idea — it's the decoder-only transformer (15.3) trained on next-token prediction (the language-modeling objective from 16.1's classical toolbox — the n-gram's task, now with a transformer), scaled up massively (billions of parameters, trillions of tokens). At inference it just repeatedly predicts the next token and appends it (autoregressive generation) — so "it's just autocomplete" is literally true, but incomplete, because (15.3's insight) predicting the next word well requires implicitly learning grammar, facts, logic, and code — and scale made it good enough that this understanding became usable. Scaling laws are the empirical discovery that a model's loss falls as a smooth power law in model size, data, and compute — a straight line on log-log axes — which made model quality predictable: you can forecast how good a bigger model will be before training it, which is why labs fund hundred-million-dollar runs. The Chinchilla correction showed early models were undertrained — for a fixed compute budget you want a smaller model trained on much more data — which is why modern models are often smaller yet better. The GPT-2→3→4 story is scale, not new architecture: GPT-3 was GPT-2 ~100× bigger, and it emergently gained in-context learning (describe a task in the prompt and it does it, no fine-tuning) — the shock that launched prompting. Emergent abilities are capabilities absent in small models that appear suddenly at scale (reasoning, arithmetic, instruction-following) — which is exciting (free capabilities) and unsettling (hard to predict — part of why AI safety is a live concern). Underneath is the bitter lesson: general methods that scale with compute beat hand-crafted cleverness — which is why the field bet on "make the transformer bigger" and the classical NLP toolbox lost. But for the engineer, the job is mostly not training bigger models (only a few labs can) — it's building well with the models that exist, which is AI Engineering.
Where this connects #
Backward: The LLM is the decoder-only transformer from 15.3 (transformer-variants), trained on the next-token language-modeling objective from 16.1's classical-toolbox lesson (the n-gram's task, realized) — this lesson is where those two threads fuse. Self-supervised pretraining (no labels, train on the internet) is the transformer-variants lesson's key idea, now at maximum scale. Emergent in-context learning is why the generation lesson's "prompt an LLM to do any task" works. And hallucination (optimizing plausibility, not truth) is the generation lesson's warning, explained here by what the model is.
Forward: This lesson is the foundation for the rest of the course. The base pretrained model this lesson describes is not yet an assistant — the next lesson (instruction tuning + RLHF) is what turns this next-token predictor into a helpful, aligned chatbot. In-context learning (emergent here) is the basis of prompt engineering (lesson 3). The knowledge cutoff (weights frozen at pretraining) is why you'll need retrieval-augmented generation (lesson 4). Scale drives the inference/serving costs (lesson 5). And emergence's unpredictability is why safety (lesson 6) is a live concern. This is the ground: an LLM is a scaled next-token predictor, and everything else in this course — and in your career as an AI engineer — is about wielding that artifact well.
That's the free preview. Sign in to continue this course.
Sign in to continueNew here? Make a desk →