A model is only as good as its data
If a language isn't in the training data, the model can't work with it; if an image model only ever sees animals, it fails on plants. Because collecting data is hard and expensive, developers often rely on what's available rather than what they'd ideally want — the "use what we have, not what we want" problem — which biases models toward whatever the internet happens to contain.
Key concept · Common Crawl and the English bias
Many models train on variations of Common Crawl (a nonprofit web crawl) or Google's cleaned subset C4. Its quality is questionable — clickbait, misinformation, fake news — yet it's used because it's available. English dominates it (~46% of the data, ~8× the next language, Russian), so general-purpose models work far better in English: on the MMLU benchmark, GPT-4 scores much higher in English than in under-represented languages like Telugu. Non-English use also costs more — tokenization is less efficient, so the same meaning takes far more tokens (median length 7 in English vs. 72 in Burmese), meaning higher latency and API cost.
Key concept · Domain-specific models
General models (Gemini, GPTs, Llamas) do well across common domains present in their data, but struggle on domains they never saw — drug discovery (protein/DNA/RNA data) or cancer screening (X-ray, fMRI) need data that's expensive, private, and absent from the public internet. That's why domain-specific models exist: DeepMind's AlphaFold (protein structures), NVIDIA's BioNeMo (drug discovery), Google's Med-PaLM 2 (medical). To build one you curate a very specific dataset.
The transformer, and how we measure a model's scale
Before training, developers choose an architecture and a size. The dominant architecture is the transformer (Vaswani et al., 2017), built on the attention mechanism. It arose to fix two problems with the earlier seq2seq (RNN) approach: seq2seq's decoder had to work from a single final hidden state (like answering about a book from only its summary), and its RNNs processed tokens sequentially, making long sequences slow.
Key concept · Attention — and the alternatives
Attention lets the decoder look at (attend to) all input tokens when generating each output token, weighting the relevant ones, and it enables parallel processing. The transformer has been so heavily optimized since 2017 that it's "sticky" — hard to displace. But alternatives are emerging for long-sequence efficiency: RWKV (parallelizable RNN), state space models (SSMs) — S4, H3, Mamba (linear-time scaling vs. the transformer's quadratic) — and hybrids like Jamba (interleaving transformer and Mamba layers).
Key concept · Three numbers that signal scale
A model's scale is captured by three numbers: number of parameters (a proxy for learning capacity); number of training tokens (a proxy for how much it learned — today's LLMs train on trillions); and FLOPs, floating point operations (a proxy for training cost). Watch two subtleties: a sparse model like a mixture-of-experts (MoE) activates only a subset of parameters per token (Mixtral 8×7B has 46.7B total but only ~12.9B active, so its cost matches a ~13B model); and FLOPs (compute for a task) differ from FLOP/s (a machine's peak speed).
Key concept · The Chinchilla scaling law
Given a fixed compute budget, what model and dataset size are best? The Chinchilla scaling law (DeepMind, 2022) found that for compute-optimal training, the number of training tokens should be roughly 20× the number of parameters (a 3B model wants ~60B tokens), and model size and data should scale together. Caveats: it optimizes for training, not inference (Llama chose smaller-than-optimal models for cheaper, more usable inference); and two scaling bottlenecks loom — running out of internet training data, and electricity. Related ideas: emergent abilities (capabilities that appear only at scale), inverse scaling (rare cases where bigger is worse), and scaling extrapolation (predicting good hyperparameters for a large model from small ones).
Turning a raw pre-trained model into an assistant
Pre-training optimizes a model for completion, not conversation, and on indiscriminate data it can be unsafe. Post-training fixes both. The popular recipe has two steps after pre-training — often pictured as putting a smiley face on a "shoggoth": supervised finetuning then preference finetuning.
Key concept · Supervised finetuning (SFT) — demonstration data
SFT teaches the model to respond instead of merely continuing text. You show it demonstration data: (prompt, response) examples of the behavior you want — also called behavior cloning. The data should span the request types you care about (question answering, summarization, translation…). Unlike simple labeling, writing good demonstrations needs skill — for InstructGPT, generating one (prompt, response) pair could take up to 30 minutes and most labelers had college or advanced degrees. To cut this cost, teams increasingly turn to synthetic (AI-generated) data.
Key concept · Preference finetuning & RLHF
Demonstration teaches the model to converse, but not which conversations it should have. Preference finetuning aligns it to human preference. The classic algorithm is RLHF (reinforcement learning from human feedback), in two parts: (1) train a reward model that scores a response, and (2) optimize the model (often with PPO) to produce responses the reward model scores highly. The reward model is trained on comparison data — (prompt, winning_response, losing_response) — because it's easier and more reliable for labelers to compare two responses than to score one (pointwise). Newer approaches like DPO (used for Llama 3) skip the separate RL loop and are gaining traction; a simpler alternative some teams use is best-of-N — generate several outputs and keep the one the reward model likes best.
How a model turns probabilities into a response
Given an input, a model computes a probability for every possible next token, then samples one. Sampling is why the same prompt can give different answers — and, the author argues, the most underrated concept in AI, since it explains both hallucination and inconsistency.
Key concept · Logits → softmax → probabilities
A neural network outputs a logit for each token in the vocabulary (the logit vector's size = vocabulary size). Logits aren't probabilities — they don't sum to one and can be negative — so a softmax layer converts them into a probability distribution. Greedy sampling always picks the highest-probability token; that's fine for classification but makes language generation repetitive and boring, so models instead sample from the distribution.
Key concept · Sampling strategies — temperature, top-k, top-p
Temperature rescales the logits before softmax: higher temperature (e.g. 0.7–1+) flattens the distribution for more creative/random output, lower (→0) sharpens it toward greedy and more deterministic output. Top-k restricts sampling to the k most-likely tokens. Top-p (nucleus) restricts it to the smallest set of tokens whose probabilities sum to p. All three trade off creativity against predictability and let you tune output to your application.
Key concept · Test-time compute and structured outputs
Because sampling is stochastic, generating multiple outputs and selecting among them — test-time compute, e.g. best-of-N with a scorer or a majority vote — raises quality at the cost of more inference. The sampling process can also be constrained to force structured outputs (valid JSON, a fixed set of labels) by restricting which tokens may be sampled — essential when a downstream system must parse the response.
Key concept · Why models hallucinate and are inconsistent
Sampling makes outputs probabilistic. Inconsistency — different answers to the same prompt, or the same answer phrased differently — follows directly from sampling from a distribution (lowering temperature reduces it). Hallucination — plausible but false statements — has two commonly cited causes: the model can't distinguish between data it was given and text it generated itself, and there's a mismatch between the model's internal knowledge and the labeler's knowledge (training it to assert things it doesn't "know" teaches it to make things up). Understanding this probabilistic nature is what lets you work with these behaviors rather than being surprised by them.
Chapter 2 quiz
Fifteen questions on training data, modeling, post-training, and sampling. Answer first, then expand Show answer.
Part A · Multiple choice
Why do general-purpose models perform better in English?
- A English dominates web training data like Common Crawl (~46%)
- B English is simpler
- C Models are hard-coded for English
- D Other languages are banned
Show answer
A. Under-represented languages (e.g. Telugu) also score lower on benchmarks like MMLU.
Besides quality, why is non-English inference often more expensive?
- A Tokenization is less efficient, so the same meaning takes more tokens
- B Servers charge a language fee
- C It needs a different model
- D It isn't more expensive
Show answer
A. Median token length was 7 in English vs. 72 in Burmese — cost/latency scale with tokens.
The dominant architecture for language foundation models is the:
- A Transformer (attention mechanism)
- B RNN/seq2seq
- C GAN
- D Decision tree
Show answer
A. It fixed seq2seq's single-hidden-state bottleneck and sequential processing.
The three numbers that signal a model's scale are:
- A Parameters, training tokens, FLOPs
- B Layers, GPUs, epochs
- C Price, latency, accuracy
- D Weights, biases, gradients
Show answer
A. Capacity, how much it learned, and training cost respectively.
In a mixture-of-experts (MoE) model, cost/speed track:
- A Only the active parameters per token, not the total
- B The total parameters always
- C The vocabulary size
- D The number of experts only
Show answer
A. Mixtral 8×7B: 46.7B total but ~12.9B active → behaves cost-wise like a ~13B model.
The Chinchilla scaling law's rule of thumb for compute-optimal training is:
- A Training tokens ≈ 20× the number of parameters
- B Tokens = parameters
- C Parameters = 20× tokens
- D Ignore data size
Show answer
A. Model size and data should scale together.
What does supervised finetuning (SFT) use?
- A Demonstration data — (prompt, response) examples (behavior cloning)
- B Comparison data
- C Raw web text
- D Reward scores
Show answer
A. It teaches the model to respond rather than merely complete text.
RLHF consists of which two parts?
- A Train a reward model; optimize the model to maximize its scores
- B Pre-train; tokenize
- C Quantize; distill
- D Prompt; retrieve
Show answer
A. The reward model is trained on comparison data; optimization often uses PPO.
Logits are converted into a probability distribution by:
- A A softmax layer
- B The reward model
- C Tokenization
- D Greedy search
Show answer
A. Logits can be negative and don't sum to one; softmax fixes both.
Raising the temperature makes a model's output:
- A More random/creative (flatter distribution)
- B More deterministic
- C Faster
- D Shorter
Show answer
A. Lower temperature sharpens toward greedy/deterministic output.
Part B · True or false
Comparison data is easier and more reliable to collect than pointwise scores.
Show answer
True. Labelers compare two responses (winning/losing) rather than assigning absolute scores.
Greedy sampling is a good default for open-ended language generation.
Show answer
False. It produces repetitive, boring text; it suits classification, not generation.
Model inconsistency (different answers to the same prompt) is a direct result of sampling.
Show answer
True. Sampling from a distribution is stochastic; lowering temperature reduces it.
Top-p (nucleus) sampling picks the smallest set of tokens whose probabilities sum to p.
Show answer
True. Top-k instead keeps a fixed number k of the most-likely tokens.
Part C · Short answer
Name the two commonly cited causes of hallucination given in the chapter.
Show answer
(1) The model can't distinguish between data it was given and text it generated itself; (2) a mismatch between the model's internal knowledge and the labeler's knowledge (being trained to assert things it doesn't "know").