Concepts and techniques
This overview gives you the whole of AI Engineering in one sitting: the single idea the book is organized around, what the thinnest working system contains, how the later parts upgrade it, and where the book connects to the rest of the library. Read it after the book’s front matter and alongside the system the solutions build, which is the component-and-contract map of the same story.
The core insight
Section titled “The core insight”A language model is a function from a prefix of token ids to a distribution over the next id. Everything else in the stack is plumbing that makes that function cheap to train, cheap to run, and safe to expose, and each piece of plumbing has a contract you can test in isolation.
That framing explains the book’s method. An LLM system is a stack of contracts: a checkpoint format between training and serving, file formats between Python and Rust, an HTTP API between the engine and everything in front of it. If you understand both sides of each contract, nothing in the stack is magic. So the book starts with the thinnest model that exercises every contract and then upgrades one component at a time while the contracts stay fixed. And because numbers are only right if they are checked, every section lists the cases a correct solution must handle and shows how its solution handles each one.
The tracer: the thinnest system that works
Section titled “The tracer: the thinnest system that works”The first turn of the spiral, the tracer, puts a real model behind a real engine with as little model as possible. Four ideas carry it.
The byte tokenizer has 256 ids, needs no training, and has no unknown tokens. Its one subtlety is on the way out: decoding a stream of bytes must handle incomplete UTF-8, because a multi-byte character can be split across two generated tokens.
The count bigram estimates the next byte from the current one by counting with add- smoothing:
Its negative log-likelihood on held-out text is the baseline every later model must beat. The reference implementation computes the bigram’s logits in Python.
The checkpoint is the first cross-language contract. Python writes model.safetensors, and the Rust engine, built on Candle, reads the same weights. Shared fixture files check that both languages behave the same way.
You build all of this in the byte bigram and serve it from your first endpoint.
The spine: upgrading one component at a time
Section titled “The spine: upgrading one component at a time”After the tracer, each part of the book replaces or extends one component behind the same contracts. In order, the parts are autograd and training (Foundations), tokenizers, statistical language models, recurrent networks, attention origins, the 2017 transformer, objectives and adaptation, the modern decoder block, inference, optional standalone C kernels, serving in Rust, training at scale, and an optional post-training part. Vision foundations and speech recognition then extend the system to images and audio, and the capstones run it on one goal.
Because the system is built in passes that interleave these parts with chapters from other books, each part belongs to one or more passes of the course path. The table gives the mapping.
| Part | Course pass |
|---|---|
| Foundations | 1 (the tracer), 2 |
| Tokenizers | 3 |
| Statistical language models | 3 |
| Recurrent networks | 4 |
| Attention origins | 4 |
| The transformer (2017) | 5 |
| Objectives and adaptation | 5 |
| The modern decoder block | 5 |
| Inference | 6 |
| Optional standalone C kernels | 6 |
| Serving | 1 (the tracer), 7 |
| Training at scale | 9 |
| Post-training (optional) | 10 |
| Vision foundations | 12 |
| Speech recognition | 12 |
| Capstones | 9, and 10 for the optional second |
Connections to other books
Section titled “Connections to other books”The model stack in this book meets several other books at specific sections. In Mathematics, vectors, matrices, and matmul is the matrix multiply every logit goes through. In AI Engineering, the tracer gateway is the front door to the engine. In Systems Engineering, the tracer deploy builds the images and charts the engine runs in. And LLM systems and inference in AI Engineering describes the production systems this spine rebuilds in miniature.
The same ideas in industry
Section titled “The same ideas in industry”None of the design choices here are academic; each mirrors a widely used open-source system.
| Project | Practice it shares with this book |
|---|---|
| Hugging Face | safetensors, transformers checkpoints, tokenizers |
| llama.cpp / ggml | C kernels behind a stable ABI, served over an OpenAI-compatible HTTP API |
| vLLM, SGLang | Python model code over custom kernels, a separate serving engine |
Further reading
Section titled “Further reading”- Karpathy, Neural Networks: Zero to Hero (free).
- Jurafsky and Martin, Speech and Language Processing (free), chapters 3 (n-gram LMs) and 9 (transformers).
- Raschka, Build a Large Language Model (From Scratch).