
Building AI systems
Designing Machine Learning Systems
Chip Huyen · O'Reilly Media · 2022
The argument
A machine learning system is more than a model. It is data pipelines, features, training, deployment, monitoring and the people around them, and each design decision should be judged by how it helps the whole system meet its objectives. The author frames the goal as systems that are reliable, scalable, maintainable and adaptable, and argues that production ML differs from research ML and from traditional software mainly because it depends on data that keeps changing.
How the book is built
- 01
Overview
Chapter 1
Asks when to use machine learning at all, shows common use cases, and then separates machine learning in research from machine learning in production, and ML systems from traditional software. The point is that production has different priorities from a benchmark: latency, cost, fairness and changing data matter as much as accuracy.
- 02
Systems design
Chapter 2
Connects business objectives to ML objectives. It lists four requirements for an ML system (reliability, scalability, maintainability, adaptability), describes the project as an iterative process, and covers how to frame a problem: the type of ML task, the choice of objective function, and the contrast between mind and data.
- 03
Data engineering fundamentals
Chapter 3
Covers data sources and formats (JSON, row-major versus column-major, text versus binary), data models (relational, NoSQL, structured versus unstructured), storage engines, transactional versus analytical processing, and ETL. It also compares how data moves between processes: through databases, through services and through real-time transport, and batch versus stream processing.
- 04
Training data
Chapter 4
Sampling comes first, with nonprobability, simple random, stratified, weighted, reservoir and importance sampling. Labeling covers hand labels, natural labels and handling a lack of labels. It then treats class imbalance (why it is hard and how to handle it) and data augmentation, from simple label-preserving transformations to perturbation and synthesis.
- 05
Feature engineering
Chapter 5
Contrasts learned and engineered features, then covers common operations: handling missing values, scaling, discretization, encoding categorical features, feature crossing and positional embeddings. A full section is devoted to data leakage, its common causes and how to detect it, followed by how to engineer good features through importance and generalization.
- 06
Model development and offline evaluation
Chapter 6
Covers developing and training models, evaluating them, ensembles, experiment tracking and versioning, distributed training and AutoML. The offline evaluation half stresses baselines and evaluation methods, so a number is always read against something.
- 07
Deployment and prediction service
Chapter 7
Opens with four deployment myths: that you only deploy one or two models at a time, that performance stays the same if you do nothing, that you will not need to update models often, and that most ML engineers need not worry about scale. It then compares batch and online prediction, covers model compression (low-rank factorization, knowledge distillation, pruning, quantization), and compares ML on the cloud and on the edge, including browsers.
- 08
Distribution shifts and monitoring
Chapter 8
Separates software system failures from ML-specific failures, then focuses on data distribution shifts: their types, how to detect them and how to address them. The monitoring half covers ML-specific metrics, the monitoring toolbox and observability.
- 09
Continual learning and testing in production
Chapter 9
Explains stateless retraining versus stateful training, why and how to do continual learning, its challenges, four stages of adoption, and how often to update. The test-in-production half covers shadow deployment, A/B testing, canary releases, interleaving experiments and bandits.
- 10
Infrastructure and tooling for MLOps
Chapter 10
Covers storage and compute, public cloud versus private data centers, development environments, moving from dev to prod with containers, resource management with schedulers and orchestrators, and workflow management. It ends with the ML platform: model deployment, model store, feature store, and build versus buy.
- 11
The human side
Chapter 11 and Epilogue
Covers user experience (consistency, handling mostly correct predictions, smooth failing), team structure (cross-functional teams, collaboration, end-to-end data scientists) and responsible AI, with case studies of irresponsible AI and a framework for avoiding it.
Concepts worth keeping
Four system requirements
Reliability, scalability, maintainability and adaptability. They give a checklist for review: does it keep working when inputs are odd, does it handle more load, can a new teammate change it, can it adapt to new data.
Data leakage
Information from outside the training window leaking into features, which makes offline scores look better than production will be. The book gives it its own section because it is common and easy to miss.
Batch versus online prediction
Batch precomputes predictions on a schedule. Online computes them per request. The book discusses moving from one to the other and unifying the two pipelines so features are computed the same way in both.
Distribution shift
Production data drifts away from training data. This is the central reason a model degrades without any code change, and the reason monitoring and retraining are part of the design.
Test in production
Shadow deployment runs a new model silently beside the old one, canary releases expose a small share of traffic, A/B tests compare outcomes, and bandits shift traffic toward the better option as evidence arrives.
Model compression
Low-rank factorization, knowledge distillation, pruning and quantization reduce size and cost at some accuracy trade-off, which matters most for edge and latency-bound serving.
What the author concludes
The publisher overview describes the book as a holistic, iterative framework for designing systems that are reliable, scalable, maintainable and adaptive to changing environments and business requirements, built on real case studies. The consistent conclusion across chapters is that the model is one component. Data quality, deployment strategy, monitoring and team practices decide whether it creates value after launch.
Limits to keep in mind
- It was published in May 2022, before the current wave of large language models. The systems thinking carries over directly, but LLM-specific topics such as prompt engineering and RAG are covered in the author's later book, AI Engineering.
- It is a design guide, not a hands-on coding course. Expect to pair it with framework documentation for the actual implementation.
- Tool choices in the infrastructure chapter reflect the ecosystem at the time of writing, so read them as categories rather than recommendations.
What I take into AI engineering work
- Start from the business objective and write down how the ML objective maps to it before choosing a model.
- Check for data leakage before celebrating an offline metric, and always compare against a baseline.
- Plan for monitoring and retraining at design time. A deployed model is the start of the work.
- Roll out with shadow deployment or a canary release instead of switching everything at once.
- Design failure behavior and user experience for mostly correct predictions.
Sources
My note
The argument that stands out is that machine learning in production differs from research in its requirements, its data and its failure modes. Data quality and labeling decisions shape a system more than the choice of model. Deployment is described as the start of the work, since models drift and monitoring and retraining need a plan from the beginning.
Next bookAI Engineering