A generative model is a program that produces new samples from a distribution known only through examples: molecular conformations, trajectories of a robot arm, spectrograms or images.
Such a program can propose candidates (the companion book), supply plausible actions to a controller (the companion book) or create media (the companion book). Each use makes the same demand: the samples must cover everything the data covers, not only the easy parts, and they must be steerable toward what the user asks for.
Diffusion and flow models meet both demands with a training problem that is plain regression: a network is shown a data point corrupted by a known amount of noise and asked to undo the corruption, with no adversary and no intractable likelihood. The price is paid at sampling time. Generating one sample means running the network many times, and every sampler is an approximate numerical solution of a differential equation whose accuracy depends on the step count.
The stakes are therefore mostly about what can silently go wrong. A sampler with too few steps drops probability mass without raising any error. A loss weighting changes which noise levels the network is good at. A guidance scale that raises classification accuracy can also push samples off the data manifold. A metric that cannot tell a good model from a poor one gives false comfort. The method of the companion book is to remove the uncertainty one layer at a time. Gaussian mixtures have a score that can be written down exactly, so a sampler can first be tested with the true score. Only after the samplers are validated do we train small networks, and then the remaining error is learning error.
A word on scale. The code in this book runs on one CPU core with NumPy, SciPy and scikit-learn only. The public image sets that a reader may expect for this article are not available offline, so two small stand-ins are used: synthetic two-dimensional point clouds, and the 8 by 8 handwritten digits bundled with scikit-learn (originally from the UCI repository, Alpaydin and Kaynak, 1998), reduced to 16 principal components. The networks are small multilayer perceptrons. Everything the companion book shows concerns mechanisms (what the weights do, what a step count costs, what guidance changes), and none of the quantitative results should be read as statements about large image models.
Continue with the book
Explore the full treatment, worked examples, and exercises in Applied AI for Generation and Control.
Companion article for Applied AI for Generation and Control, published by Choral Software. Article text and original examples © 2026 Choral Software. All rights reserved.
