1What Is a Large Language Model?
A large language model is, mechanically, a function that reads a sequence of tokens and outputs a probability distribution over what the next token should be. That is the whole contract. Everything else — the apparent reasoning, the tool use, the ability to write a sonnet or a Kubernetes config — is what happens when you make that function very large, train it on a very large amount of text, and then wrap it carefully.
This chapter lays out the shape of the field so the rest of the book has somewhere to hang.
1.1The one function
Call the model \(p_\theta\), with parameters \(\theta\). Given a context of tokens \(x_1, \dots, x_t\), it produces
a distribution over the vocabulary. To generate text, you sample a token from that distribution, append it, and repeat. That is autoregressive generation: the model's own output becomes part of its next input.
Intuition
An LLM is a next-token predictor run in a loop. Its "thinking" is a side effect of predicting each next token well enough that the whole sequence hangs together.
Training is nothing more exotic than teaching \(p_\theta\) to assign high probability to the tokens that actually came next in a huge corpus of human text. The loss is cross-entropy — the number of bits of surprise the model feels at each real token. Drive that surprise down across trillions of tokens and, empirically, useful behavior falls out. This same loss is often reported as perplexity, \(2^{H}\) for a cross-entropy \(H\) in bits, which reads as the effective number of equally likely tokens the model is choosing among at each step.
Analogy
Think of a student who has read the entire internet and plays a relentless game of "guess the next word." To get good at the game on arbitrary text, they are forced to absorb grammar, facts, arithmetic, code, and the rhythms of argument. The game is trivial; being good at it is not. This leaks in one place: the student never gets to act in the world during study, only to predict — which is exactly why Part III exists.
1.2Why "large" is the whole story
Nothing about next-token prediction is new; the surprise is what happens at scale. As you increase parameters, data, and compute together, the loss falls along a smooth power law (Kaplan et al., 2020), and somewhere along that curve the model stops merely completing text and starts following instructions, doing multi-step arithmetic, and writing working code (Brown et al., 2020; Wei et al., 2022). We spend Chapter 9 on the exact shape of these scaling laws, because they are the closest thing the field has to a design equation.
Interview
Are these "emergent abilities" real, or an illusion? The strongest skeptical case (Schaeffer et al., 2023) is that a sharp jump can be manufactured by the metric: an all-or-nothing score like exact-match accuracy stays near zero until every step of a task is right, so a smoothly improving skill looks like a sudden switch. Measure the same capability with a continuous, per-token metric and the jump often smooths out. The honest answer is that capabilities do grow with scale, but the abruptness is partly a measurement artifact — a favorite trap for a confident candidate.
The practical consequence: much of LLM engineering is really systems engineering. Making a model bigger means splitting it across hundreds of GPUs to train (Chapter 8) and squeezing it back onto a few to serve (Part IV). A great deal of what an LLM engineer does is fight the memory and bandwidth of physical hardware.
1.3From a text predictor to an assistant
A freshly pretrained model is a base model. It will happily continue a document, but ask it a question and it might respond with a list of similar questions — because on the internet, questions are often followed by more questions. It is a mirror of its training distribution, not yet an assistant.
Turning it into ChatGPT- or Claude-like behavior takes post-training:
- Supervised fine-tuning (Chapter 10) shows it thousands of examples of the assistant format — a helpful answer following a user request.
- Preference optimization (Chapters 11–12), via RLHF (Christiano et al., 2017; Ouyang et al., 2022) or its RL-free cousins like DPO (Rafailov et al., 2023), tunes it toward responses humans actually prefer, using comparisons rather than demonstrations.
Interview
Why isn't supervised fine-tuning enough — why bother with RLHF? Because you can recognize a good answer more reliably than you can write the single best one. Preference methods learn from rankings of outputs the model itself generates, which is a richer and more scalable signal than a fixed set of gold demonstrations.
1.4The harness: the product around the weights
Here is the thing most architecture-focused explanations skip. The model you talk to through an API is not just the weights. A provider wraps it in a harness: the system that decides what context the model sees and what happens to its output.
The harness is where a lot of the "it just behaves" comes from:
- A system prompt sets the persona, rules, and defaults before you type anything (Chapter 18).
- Tool calling lets the model's text trigger real actions — searches, code execution, API calls — and feeds the results back (Chapter 19).
- Structured output forces valid JSON when a downstream system needs it (Chapter 20).
- Retrieval injects fresh or private documents into the context so the model can ground its answers (Chapter 21).
- Guardrails — separate classifiers and policies — filter inputs and outputs (Chapter 23).
Intuition
The weights are an engine. The harness is the car built around it: steering, brakes, dashboard, seatbelts. A benchmark tests the engine; a product ships the car.
Part V is devoted to the harness, because in 2026 most engineering roles that touch LLMs are really building harnesses, not training weights from scratch.
1.5The frontier
Two shifts define the current edge. First, reasoning models (Chapter 25) spend extra compute at inference time — generating long internal chains of thought, often trained with reinforcement learning on problems whose answers can be checked automatically (OpenAI, 2024; DeepSeek-AI, 2025). Compute at test time became a new axis to scale, alongside model size.
Second, the open problems (Chapter 26) remain stubborn: models still hallucinate confidently, we still cannot fully read what a model has learned, and we do not yet have alignment techniques we would trust on systems smarter than us. These are where the interesting research is, and they close the book.
1.6A map of the rest
If you want the shortest useful path: read the transformer chapter (4), the scaling-laws chapter (9), and the post-training chapters (10–12) to understand how models are made; then the inference and harness parts (IV–V) to understand how they are shipped. The appendix on running models locally is a good place to get your hands dirty on your own machine.
Onward to tokens.
References
- Brown, T., Mann, B., Ryder, N., Subbiah, M., et al. (2020). Language models are few-shot learners. Advances in Neural Information Processing Systems. arXiv:2005.14165.
- Christiano, P. F., Leike, J., Brown, T. B., Martic, M., Legg, S., & Amodei, D. (2017). Deep reinforcement learning from human preferences. Advances in Neural Information Processing Systems. arXiv:1706.03741.
- DeepSeek-AI (2025). DeepSeek-R1: Incentivizing reasoning capability in LLMs via reinforcement learning. arXiv preprint. arXiv:2501.12948.
- Kaplan, J., McCandlish, S., Henighan, T., Brown, T. B., et al. (2020). Scaling laws for neural language models. arXiv preprint. arXiv:2001.08361.
- OpenAI (2024). Learning to reason with LLMs. OpenAI blog.
- Ouyang, L., Wu, J., Jiang, X., Almeida, D., et al. (2022). Training language models to follow instructions with human feedback. Advances in Neural Information Processing Systems. arXiv:2203.02155.
- Rafailov, R., Sharma, A., Mitchell, E., Manning, C. D., Ermon, S., & Finn, C. (2023). Direct preference optimization: Your language model is secretly a reward model. Advances in Neural Information Processing Systems. arXiv:2305.18290.
- Schaeffer, R., Miranda, B., & Koyejo, S. (2023). Are emergent abilities of large language models a mirage?. Advances in Neural Information Processing Systems. arXiv:2304.15004.
- Wei, J., Tay, Y., Bommasani, R., Raffel, C., et al. (2022). Emergent abilities of large language models. Transactions on Machine Learning Research. arXiv:2206.07682.
Check yourself
Interview-style questions on this chapter. Pick an answer to see whether it holds up.
-
A base model, fresh from pretraining, is prompted "What is the capital of France?" It answers with a list of related questions instead of "Paris" — even though it will readily produce "Paris" in other contexts. What best explains this?
A base model only ever learned to continue text in the style of its corpus. It very likely knows the fact; it just has not been taught that a prompt is a request to be answered rather than a document to be continued. That is exactly what post-training (SFT, then preference optimization) fixes. -
An interviewer asks whether the 'emergent abilities' of large models are real. What is the strongest version of the skeptical view?
The mirage argument (Schaeffer et al., 2023) is that a nonlinear or all-or-nothing metric can manufacture a sudden jump out of a smoothly falling loss: switch to a continuous measure and the 'emergence' often smooths out. It does not deny that capabilities appear with scale, only that the sharp threshold can be a measurement effect. -
Cross-entropy loss is often reported as perplexity. If a model reaches a cross-entropy of 3 bits per token, its perplexity is 8. What does that number mean intuitively?
Perplexity is 2 raised to the cross-entropy in bits (or e to the nats), i.e. the effective number of equally-likely choices the model is deciding among per token. Lower perplexity means the model concentrates probability on fewer candidates. It is a monotone rescaling of the loss, not new information. -
Why is preference optimization (RLHF or DPO) used at all, when supervised fine-tuning already shows the model good answers?
The core asymmetry: recognition is easier than generation. Preference methods learn from comparisons among the model's own outputs, which covers far more of the output space than a fixed set of gold demonstrations and does not cap quality at what the annotators could themselves write. -
In this book's framing, the 'harness' around a model is best described as which of the following?
The harness does not change the weights at all; it shapes the model's inputs and mediates its outputs. Much of what feels like 'the model just behaves' comes from the harness, which is why Part V is devoted to it and why most LLM engineering roles in 2026 are really about building harnesses.