Skip to content

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.

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-α\alpha smoothing:

P(b∣a)=cab+α∑xcax+256α.P(b \mid a) = \frac{c_{ab} + \alpha}{\sum_x c_{ax} + 256\alpha}.

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.

PartCourse pass
Foundations1 (the tracer), 2
Tokenizers3
Statistical language models3
Recurrent networks4
Attention origins4
The transformer (2017)5
Objectives and adaptation5
The modern decoder block5
Inference6
Optional standalone C kernels6
Serving1 (the tracer), 7
Training at scale9
Post-training (optional)10
Vision foundations12
Speech recognition12
Capstones9, and 10 for the optional second

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.

None of the design choices here are academic; each mirrors a widely used open-source system.

ProjectPractice it shares with this book
Hugging Facesafetensors, transformers checkpoints, tokenizers
llama.cpp / ggmlC kernels behind a stable ABI, served over an OpenAI-compatible HTTP API
vLLM, SGLangPython model code over custom kernels, a separate serving engine