How to become an ML Engineer
Step by step and free: 12 phases, 89 topics and 314 graded practice questions.
Open any topic and mark it Learning, Done or Skip to track your progress. Sign in to save it to your account.
0 of 89 done · 0 learning · 0 skipped · Start with the first topic
Saved on this device only. Sign up free or sign in to keep your progress everywhere.
It's saved on this device only. Sign up free to keep it everywhere; your marks move into your account.
What is an ML Engineer?
An ML engineer builds, trains and ships models that make predictions from data, and answers for whether they work. They frame the problem and the label, prepare features without leakage, choose between gradient-boosted trees, neural networks and fine-tuned pretrained models, run and compare experiments, evaluate against baselines with the right metric, and put models into serving with monitoring, drift detection and retraining. They work with data engineers, product teams and platform engineers.
Who this roadmap is for
Software engineers, data scientists and analysts who already write Python, know some linear algebra and probability, and want to build models that run in production. Comfort with NumPy or pandas helps. It is not for people who only want to call a hosted LLM API; prompt and agent work have their own roadmaps.
What you will be able to do
You will be able to set up a sound train, validation and test split, train classical and deep models in PyTorch, debug and tune a training run, judge whether an improvement is real, scale training with mixed precision and sharding, fine-tune foundation models, build ranking systems, and ship models with monitoring and fairness checks.
The ML Engineer roadmap
ML Engineer
-
Phase 1 Machine learning foundations
-
Phase 2 Math and code for ML
-
Phase 3 Training data and features
-
Phase 4 Classical models
-
Phase 5 Deep learning foundations
-
Phase 6 Training models well
-
Phase 7 Evaluating models
-
Phase 8 Training at scale
-
Phase 9 Foundation models and fine-tuning
-
Phase 10 Ranking and recommendation
-
Phase 11 Shipping and running models
-
Phase 12 Responsible ML
All topics, in order
Mark each topic Learning, Done or Skip, and sign in to save your place to your account. Done is your own word, not passing: a topic is passed when you score 50 or more on its questions. This order is the study plan.
-
Phase 1 · Machine learning foundations
-
What an ML engineer does
As an ML engineer you own a model end to end: the prediction it makes, the data it learns from, the training code, the evidence that it works and how it behaves once real traffic reaches it. Data scientists answer questions with data, MLOps engineers run the platform your model ships on, and AI engineers build on models someone else trained. You are judged by a model that keeps making good decisions in production, not by a notebook score.
Reading
- Google: Rules of Machine Learning developers.google.com
- Chip Huyen: Machine learning systems design huyenchip.com
- Hidden Technical Debt in Machine Learning Systems (NeurIPS 2015) papers.nips.cc
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
When ML is the right tool
Machine learning pays off when the pattern is too complex to write as rules, labelled examples exist or can be collected, the decision repeats often enough to justify the upkeep, and an occasional wrong answer is tolerable. If a dozen rules get you most of the way, ship the rules first: they are a baseline, they generate data and they set the bar a model must clear. A model adds training, serving, monitoring and retraining costs that never go away.
Reading
- Google: Introduction to ML problem framing developers.google.com
- Google: Rules of Machine Learning (before machine learning) developers.google.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Supervised learning and the label
Supervised learning fits a mapping from features to a label you already hold, so the label definition is the most important decision you make. Write it as one sentence: what is predicted, for which entity, at what moment, over what horizon, using only data available at that moment. Then pick the output the downstream decision needs (a class, a number or a ranking), because that choice fixes your loss, your metric and how a threshold gets set.
Reading
- Google: Framing an ML problem developers.google.com
- scikit-learn: supervised learning scikit-learn.org
- Google: Rules of Machine Learning developers.google.com
Start the 5 questionsTest yourself on this topic
5 graded questions · scored out of 100 with feedback · free
-
Loss functions
The loss is the number training actually pushes down, and it is rarely the metric you report. Squared error chases the mean and is dragged by outliers, absolute error chases the median, log loss rewards honest probabilities, and pinball loss fits a chosen quantile. Pick the loss whose best answer is the quantity your decision needs, then track the reported metric separately, because a lower loss does not always mean a better metric.
Reading
- PyTorch: loss functions docs.pytorch.org
- Google ML Crash Course: Linear regression loss developers.google.com
- Dive into Deep Learning: Softmax regression d2l.ai
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Overfitting and the bias-variance trade-off
A model that scores well on its training data and badly on new data is overfitting; one that is poor on both is underfitting. Before you change anything, plot training and validation error against training set size: a wide gap that narrows with more data says collect more or regularise, while two high, flat curves say add capacity or better features. Every choice made by looking at the validation set leaks into it a little, so keep a final test set you score once.
Reading
- scikit-learn: underfitting vs overfitting scikit-learn.org
- Google ML: Overfitting developers.google.com
- scikit-learn: validation and learning curves scikit-learn.org
Start the 5 questionsTest yourself on this topic
5 graded questions · scored out of 100 with feedback · free
-
Baselines first
Before any real model, score the simplest honest predictor: the majority class, the mean, the same day last week, or the rule the business already runs. Use the same split and the same metric you will use later, so the comparison is fair. A complex model has to beat the strongest simple baseline by enough to pay for its training, serving and upkeep. If it does not, ship the baseline and spend the time on data.
Reading
- scikit-learn: dummy estimators scikit-learn.org
- Google: Rules of ML developers.google.com
- Forecasting: Principles and Practice, simple forecasting methods otexts.com
Start the 6 questionsTest yourself on this topic
6 graded questions · scored out of 100 with feedback · free
Chapter 1 lab
Instruct a coding agent to build a first forecast and an honest baseline report
A prompt lab that closes the chapter: you write the instruction, and it is graded on a rubric.
Start the lab -
-
Phase 2 · Math and code for ML
-
Vectors, matrices and shapes
Almost every model is a stack of matrix multiplies, so you need to read them fluently. A dot product scores how aligned two vectors are, a matrix multiply runs many dot products at once, and a batch of inputs is one more leading dimension. Most bugs you will meet are shape bugs: write the expected shape beside each tensor, assert it in code, and distrust any operation that silently combines two shapes you did not mean to combine.
Reading
- Dive into Deep Learning: Linear algebra d2l.ai
- Mathematics for Machine Learning (free book) mml-book.github.io
- MIT OpenCourseWare 18.06: Linear Algebra ocw.mit.edu
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Probability for model outputs
A classifier that outputs probabilities is a model of a distribution, and training it means making the observed labels as likely as possible. Minimising cross-entropy is exactly maximising that likelihood, and squared error is the same idea under Gaussian noise. Knowing which distribution your loss assumes tells you what the output means: a softmax gives one distribution over exclusive classes, while a sigmoid per label gives independent yes or no chances.
Reading
- Dive into Deep Learning: Probability and statistics d2l.ai
- Deep Learning book: Probability and information theory deeplearningbook.org
- Mathematics for Machine Learning (free book) mml-book.github.io
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Gradient descent
Gradient descent improves the parameters by stepping against the gradient of the loss, and the learning rate sets the size of each step. Too large and the loss bounces or explodes; too small and training crawls. In practice you compute the gradient on a minibatch, which is cheaper and adds noise that often helps the model generalise. Batch size and learning rate interact, so when you change one, retune the other.
Reading
- Dive into Deep Learning: Stochastic gradient descent d2l.ai
- Google ML Crash Course: Gradient descent developers.google.com
- An overview of gradient descent optimization algorithms (arXiv) arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Numerical stability
Floating point numbers have limited range and precision, so exp of a large logit overflows, the log of a tiny probability becomes minus infinity, and the resulting NaN spreads through every weight. Library losses avoid this by working on raw logits with the log-sum-exp trick, so pass them logits, not softmax outputs. When a NaN appears, find the first operation that produced it before you reach for a lower learning rate.
Reading
- PyTorch: CrossEntropyLoss docs.pytorch.org
- PyTorch: autograd anomaly detection docs.pytorch.org
- Deep Learning book: Numerical computation deeplearningbook.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Vectorised array code
A Python loop over a million rows runs one interpreted step at a time; the same work as one NumPy or PyTorch array operation runs in compiled code, often a hundred times faster. Broadcasting stretches arrays of compatible shapes so you can combine a batch with a vector without copying. Learn its rules, because it also turns a shape mistake into a wrong answer instead of an error: an array of shape (n,) minus one of shape (n, 1) quietly becomes n by n.
Reading
- NumPy: Broadcasting numpy.org
- NumPy: quickstart numpy.org
- PyTorch: broadcasting semantics docs.pytorch.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Testing ML code
ML code fails quietly: a wrong transform still trains, it just trains worse. Unit test the deterministic parts (feature transforms, label construction, metric code) on tiny hand-checked inputs, assert shapes and value ranges at boundaries, and keep a smoke test that trains a few steps on one small batch and checks that the loss falls. Seed everything in tests so a failure reproduces, and run the serving path on the same examples as training.
Reading
- Google Research: The ML Test Score rubric research.google
- Andrej Karpathy: A recipe for training neural networks karpathy.github.io
- PyTorch: reproducibility docs.pytorch.org
- pytest documentation docs.pytest.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
-
Phase 3 · Training data and features
-
Labels and annotation quality
A model can only be as good as its labels, and labels made by people disagree more than you expect. Write annotation guidelines with worked edge cases, have a sample labelled twice and measure agreement with a statistic such as Cohen's kappa, and read low agreement as a task definition that is unclear, not as careless annotators. Audit a slice of labels yourself before training, and record which guideline version produced each label.
Reading
- Pervasive Label Errors in Test Sets (arXiv) arxiv.org
- scikit-learn: cohen_kappa_score scikit-learn.org
- Snorkel: rapid training data creation with weak supervision (arXiv) arxiv.org
- cleanlab documentation docs.cleanlab.ai
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Checking data before you train
Upstream data changes without warning: a column switches units, a join drops half the rows, a category gets renamed. Put checks between the raw snapshot and training: the schema, null rates, value ranges, row counts against the last snapshot, and the distribution of key features and the label. Fail the run loudly when a check breaks, because a model trained on broken data still produces a confident score and a plausible artefact.
Reading
- TensorFlow Data Validation guide tensorflow.org
- Great Expectations documentation docs.greatexpectations.io
- Pandera documentation pandera.readthedocs.io
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Train, validation and test splits
Your split has to copy how the model will meet new data. Rows from the same customer, patient or device belong on one side only, and when you predict the future, train on the past and test on a later window. Leakage is any route by which test or future information reaches training: a scaler fitted on all rows, a duplicate, a feature computed after the label. Its signature is an offline score too good to be true, so investigate before you celebrate.
Reading
- scikit-learn: cross-validation scikit-learn.org
- scikit-learn: pipelines scikit-learn.org
- scikit-learn: common pitfalls and data leakage scikit-learn.org
Start the 7 questionsTest yourself on this topic
7 graded questions · scored out of 100 with feedback · free
-
Cross-validation
Cross-validation trains and scores the model on several folds so you see both the average score and how much it moves between folds. Build folds the way you built the split: group folds keep an entity together, and time series folds always train on earlier data than they test. If you tune hyperparameters on the same folds you report, the score is optimistic, so use nested cross-validation or an untouched test set for the final number.
Reading
- scikit-learn: cross-validation scikit-learn.org
- scikit-learn: nested versus non-nested cross-validation scikit-learn.org
- scikit-learn: TimeSeriesSplit scikit-learn.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Feature engineering
Features turn raw records into signals a model can use: ratios, counts over a window, time since an event. The same code must compute them in training and in serving, or the model meets inputs it never saw. Treat missing values on purpose, because missingness often carries signal: impute and add a flag. Most gaps between offline and online scores trace back to features rather than models, so test feature code as carefully as model code.
Reading
- scikit-learn: preprocessing scikit-learn.org
- Google ML: Numerical data developers.google.com
- scikit-learn: ColumnTransformer for mixed data scikit-learn.org
- scikit-learn: imputation of missing values scikit-learn.org
Start the 6 questionsTest yourself on this topic
6 graded questions · scored out of 100 with feedback · free
-
Point-in-time feature joins
Each training row must see feature values as they stood when the prediction would have been made, not as they stand today. A plain join on customer id pulls in the current balance or latest status, which may have been caused by the very outcome you are predicting. Join on the entity and an as-of timestamp, taking the latest value at or before the prediction time, and allow for the delay before a value really lands in your systems.
Reading
- pandas: merge_asof pandas.pydata.org
- Feast: point-in-time joins docs.feast.dev
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Encoding categorical features
Categories need numbers before most models can use them. One-hot encoding suits a few dozen values; for thousands, use hashing, a learned embedding, or target encoding, which replaces each category with its average label. Target encoding leaks the label unless you compute it out of fold and pull rare categories towards the overall mean. Always decide what a category the model never saw in training turns into at serving time.
Reading
- scikit-learn: encoding categorical features scikit-learn.org
- scikit-learn: TargetEncoder scikit-learn.org
- scikit-learn: feature hashing scikit-learn.org
- CatBoost: transforming categorical features catboost.ai
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Class imbalance
When positives are rare, accuracy rewards a model that never predicts them. Stratify splits and folds so each keeps some positives. If you resample or reweight, do it on training folds only and evaluate at the real rate with precision, recall or PR-AUC. Undersampling negatives inflates predicted probabilities, so correct or recalibrate them before anyone reads a score as a real chance. Often a well-chosen threshold on an unresampled model is all you need.
Reading
- Google ML: Imbalanced datasets developers.google.com
- imbalanced-learn user guide imbalanced-learn.org
- PLOS ONE: precision-recall beats ROC on imbalanced data journals.plos.org
Start the 5 questionsTest yourself on this topic
5 graded questions · scored out of 100 with feedback · free
Chapter 3 lab
Instruct an agent to audit a feature pipeline for leakage
A prompt lab that closes the chapter: you write the instruction, and it is graded on a rubric.
Start the lab -
-
Phase 4 · Classical models
-
Linear and logistic regression
Linear regression predicts a number as a weighted sum of features; logistic regression passes that sum through a sigmoid to predict a probability. They train in seconds, hold up well with regularisation and are easy to inspect, which makes them the first real model to fit after a baseline. Read coefficients with care: they only compare across features on the same scale, and correlated features split credit between them unpredictably.
Reading
- scikit-learn: linear models scikit-learn.org
- Google ML Crash Course: Logistic regression developers.google.com
- An Introduction to Statistical Learning (free book) statlearning.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Decision trees
A decision tree splits the data on one feature at a time, choosing each split to make the groups below it purer, until it reaches a leaf that predicts. Trees handle mixed types and interactions without scaling, and a shallow one can be read by anyone. A deep tree memorises its training data, so limit depth, minimum leaf size or both, and expect a single tree's predictions to jump when the data changes slightly.
Reading
- scikit-learn: decision trees scikit-learn.org
- Google: Decision Forests course developers.google.com
- An Introduction to Statistical Learning (free book) statlearning.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Bagging and random forests
Bagging trains many trees on bootstrap samples and averages them, which cancels much of each tree's variance. A random forest also limits each split to a random subset of features, so the trees make different mistakes and their average improves further. Forests need little tuning and give a free validation score from the rows each tree never saw, the out-of-bag estimate. They rarely beat well-tuned boosting, but they are very hard to break.
Reading
- scikit-learn: forests of randomized trees scikit-learn.org
- Google Decision Forests: Random forests developers.google.com
- scikit-learn: OOB errors for random forests scikit-learn.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Gradient-boosted trees
Gradient boosting adds small trees one at a time, each fitted to the errors the ensemble still makes, and on tabular data it is usually the strongest model you can train. The settings that matter most are the learning rate, the number of trees (found by early stopping on validation data), tree depth or leaf count, and row and column subsampling. XGBoost, LightGBM and CatBoost differ more in speed and category handling than in accuracy.
Reading
- XGBoost documentation xgboost.readthedocs.io
- LightGBM: parameters tuning lightgbm.readthedocs.io
- CatBoost documentation catboost.ai
- Why do tree-based models still outperform deep learning on tabular data? (arXiv) arxiv.org
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Clustering
Clustering groups rows by similarity without labels, and the result depends almost entirely on the features you choose and how you scale them. K-means finds round clusters of similar size and needs the count up front; density-based methods such as DBSCAN and HDBSCAN find odd shapes and leave noise unassigned. With no ground truth to score against, judge clusters by whether they stay stable across resamples and help the people who will act on them.
Reading
- scikit-learn: clustering scikit-learn.org
- Google: Clustering course developers.google.com
- HDBSCAN documentation hdbscan.readthedocs.io
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Anomaly detection
Anomaly detection flags rows unlike the rest, usually because real anomalies are too rare or too varied to train a classifier on. Isolation forests separate outliers in a few random splits; autoencoders flag inputs they reconstruct badly. The hard part is the threshold: set it from how many alerts a person can review a day, and keep every confirmed case, because once you have enough labelled anomalies a supervised model usually wins.
Reading
- scikit-learn: novelty and outlier detection scikit-learn.org
- ADBench: anomaly detection benchmark (arXiv) arxiv.org
- PyOD documentation pyod.readthedocs.io
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Time series forecasting
A forecast predicts future values from the past, so every feature must be known at forecast time and every test must run forward in time. Lags, rolling statistics and calendar effects turn a series into a table, and one global gradient-boosted model trained across many related series often beats a separate model per series. Evaluate with a rolling backtest over several cut-off dates, always against a seasonal naive baseline.
Reading
- Forecasting: Principles and Practice (free book) otexts.com
- scikit-learn: time-related feature engineering scikit-learn.org
- Nixtla StatsForecast documentation nixtlaverse.nixtla.io
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
-
Phase 5 · Deep learning foundations
-
Neural networks and backpropagation
A neural network is a chain of layers, each a linear map followed by a non-linear activation such as ReLU or GELU; without the non-linearity the whole stack collapses into one linear model. Backpropagation applies the chain rule from the loss backwards, reusing each layer's saved intermediate values to get every gradient in one pass. That reuse is why training stores activations, and why activation memory, not weights, often limits your batch size.
Reading
- Dive into Deep Learning: Multilayer perceptrons d2l.ai
- Dive into Deep Learning: Forward and backward propagation d2l.ai
- Deep Learning book: Deep feedforward networks deeplearningbook.org
- Andrej Karpathy: micrograd github.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
PyTorch tensors and autograd
A PyTorch tensor carries a shape, a dtype and a device, and mixing devices or dtypes is the most common first error. When a tensor requires gradients, autograd records every operation on it, and backward walks that record to fill in each parameter's gradient. Run evaluation under torch.no_grad or inference_mode so nothing is recorded, and log a loss with item or detach, or you keep its whole graph alive in memory.
Reading
- PyTorch: Tensors tutorial docs.pytorch.org
- PyTorch: Automatic differentiation with torch.autograd docs.pytorch.org
- PyTorch: Autograd mechanics docs.pytorch.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
The PyTorch training loop
Every PyTorch training loop repeats the same moves: take a batch from the DataLoader, run the forward pass, compute the loss, call backward, step the optimizer and clear the gradients. Gradients add up across backward calls, so forgetting to zero them silently trains on stale ones. Call model.train before training and model.eval before validation, because dropout and batch normalisation behave differently in each mode and a forgotten switch skews every score.
Reading
- PyTorch: Optimizing model parameters docs.pytorch.org
- PyTorch: Datasets and DataLoaders docs.pytorch.org
- PyTorch: torch.nn.Module (train and eval) docs.pytorch.org
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Optimizers: SGD, momentum and AdamW
Plain SGD moves each weight by its gradient times the learning rate; momentum keeps a running average of past gradients so steps build speed in consistent directions. Adam also scales each weight's step by its recent gradient size, which makes it forgiving across very different layers, and AdamW applies weight decay separately from that scaling, the version you almost always want. Adam keeps two extra values per parameter, which you pay for in memory.
Reading
- PyTorch: torch.optim docs.pytorch.org
- Adam: a method for stochastic optimization (arXiv) arxiv.org
- Decoupled weight decay regularization, AdamW (arXiv) arxiv.org
- Dive into Deep Learning: Adam d2l.ai
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Learning rate schedules and warmup
The learning rate is the setting most worth getting right, and it rarely should stay fixed. A short warmup ramps it up from near zero so early, badly scaled updates do not wreck the weights, especially with Adam and large batches; a decay, such as cosine or step, then lowers it so the model settles. To find a starting value, sweep it on a log scale over short runs and pick one somewhat below the point where the loss starts to blow up.
Reading
- PyTorch: how to adjust the learning rate docs.pytorch.org
- Google: Deep Learning Tuning Playbook github.com
- SGDR: stochastic gradient descent with warm restarts (arXiv) arxiv.org
- Accurate, large minibatch SGD (arXiv) arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Initialisation and normalisation
If activations grow or shrink a little at every layer, a deep network's signal explodes or vanishes before training even starts. Initialisation schemes such as Xavier and Kaiming scale the starting weights to keep the spread steady, normalisation layers rescale activations as training runs, and residual connections give gradients a direct path back. BatchNorm relies on batch statistics and suits large image batches; LayerNorm works per example, which is why transformers use it.
Reading
- PyTorch: torch.nn.init docs.pytorch.org
- Delving deep into rectifiers, Kaiming initialisation (arXiv) arxiv.org
- Batch normalization (arXiv) arxiv.org
- Layer normalization (arXiv) arxiv.org
- Deep residual learning for image recognition (arXiv) arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Convolutional networks
A convolution slides one small filter across an image, so the same weights detect an edge or a texture wherever it appears, with far fewer parameters than a dense layer. Stacking convolutions with downsampling grows each unit's view from pixels to parts to whole objects. In practice you rarely design one: start from a pretrained backbone such as a ResNet or ConvNeXt, and weigh vision transformers when data and compute are plentiful.
Reading
- Dive into Deep Learning: Convolutional neural networks d2l.ai
- Stanford CS231n: Convolutional networks notes cs231n.github.io
- torchvision: models and pretrained weights docs.pytorch.org
- A ConvNet for the 2020s, ConvNeXt (arXiv) arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Attention and the transformer
Attention lets every position in a sequence build its output from a weighted mix of all the others, with the weights set by how well that position's query matches each key. A transformer block stacks multi-head attention and a feed-forward layer, each wrapped in a residual connection and normalisation, and adds position information because attention alone ignores order. Attention's cost grows with the square of sequence length, which is why long inputs are expensive.
Reading
- Attention is all you need (arXiv) arxiv.org
- The Annotated Transformer (Harvard NLP) nlp.seas.harvard.edu
- Dive into Deep Learning: The transformer architecture d2l.ai
- PyTorch: scaled_dot_product_attention docs.pytorch.org
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Embeddings and learned representations
An embedding maps a discrete thing, such as a word, a user or a product id, to a dense vector learned in training, so things that behave alike end up close together. Embeddings replace huge one-hot inputs, let a model share what it learns across related items, and can be reused by other models as features. A table for millions of ids can dominate model size, and ids never seen in training need a shared fallback vector or hashing.
Reading
- PyTorch: torch.nn.Embedding docs.pytorch.org
- Google ML Crash Course: Embeddings developers.google.com
- Efficient estimation of word representations, word2vec (arXiv) arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
-
Phase 6 · Training models well
-
Choosing a model
Choose the model from the data and the constraints, not from fashion. On tabular data of moderate size, gradient-boosted trees are the strong default; deep networks earn their cost on images, audio, text and very large datasets, usually starting from a pretrained model. Latency budgets, hardware, the need to explain a decision and the amount of labelled data can each rule a model in or out before accuracy is even compared, so list them first.
Reading
- scikit-learn: choosing an estimator scikit-learn.org
- scikit-learn: ensemble methods scikit-learn.org
- Why do tree-based models still outperform deep learning on tabular data? (arXiv) arxiv.org
Start the 6 questionsTest yourself on this topic
6 graded questions · scored out of 100 with feedback · free
-
Transfer learning from pretrained models
Starting from weights trained on a large dataset lets you reach good accuracy with a fraction of the labelled data. With little data, freeze the backbone and train only a new head; with more, unfreeze and fine-tune everything at a lower learning rate than the head, so you adapt the features without erasing them. Match the preprocessing the pretrained model expects, such as its resizing, normalisation or tokenizer, or its features are worth far less.
Reading
- PyTorch: Transfer learning for computer vision docs.pytorch.org
- Hugging Face Transformers: Fine-tuning huggingface.co
- How transferable are features in deep neural networks? (arXiv) arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Data augmentation
Augmentation creates new training examples by changing inputs in ways that should not change the label: flips, crops and colour shifts for images, noise and time shifts for audio, paraphrases for text. It teaches the model which variations to ignore and acts as strong regularisation when data is scarce. Check every transform against the label, because a rotated 6 becomes a 9 and a tight crop can cut out the finding. Augment training data only, never the evaluation sets.
Reading
- torchvision: transforming and augmenting images docs.pytorch.org
- RandAugment (arXiv) arxiv.org
- mixup: beyond empirical risk minimization (arXiv) arxiv.org
- Albumentations documentation albumentations.ai
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Regularization
Regularisation trades a little bias for less variance. Penalties such as L2 and L1, weight decay, early stopping, dropout, shallower trees and subsampling all limit how closely a model can fit noise. Penalties assume features share a scale, so standardise first, and treat the strength as a hyperparameter: if the best value sits at the edge of the range you searched, widen the range before you trust it. More real data is still the strongest regulariser.
Reading
- scikit-learn: linear models (Lasso and Ridge) scikit-learn.org
- Google ML: Regularization for simplicity developers.google.com
- Dropout: a simple way to prevent overfitting (JMLR) jmlr.org
Start the 5 questionsTest yourself on this topic
5 graded questions · scored out of 100 with feedback · free
-
Hyperparameter tuning
Hyperparameters set a model's capacity and how it trains. Search them with random or Bayesian methods rather than a full grid, on scales that match them, such as a log scale for learning rate and regularisation strength, and judge every trial on validation folds, never on the test set. Read the loss curves as well as the final score: they show a learning rate that is too high or a run stopped too early. Tune the few settings that matter most first.
Reading
- scikit-learn: tuning hyperparameters scikit-learn.org
- Google: Deep Learning Tuning Playbook github.com
- Random search for hyper-parameter optimization (JMLR) jmlr.org
- Optuna documentation optuna.readthedocs.io
Start the 5 questionsTest yourself on this topic
5 graded questions · scored out of 100 with feedback · free
-
Debugging a training run
When a model will not learn, shrink the problem until it must. Look at a batch of inputs and labels after every transform, check the loss at step zero matches random guessing, then overfit one small batch: if the loss cannot reach near zero, the bug is in the code. A NaN loss points to the learning rate, bad inputs or an unstable operation; a flat loss points to broken labels, gradients that never reach the weights, or a learning rate far too low.
Reading
- Andrej Karpathy: A recipe for training neural networks karpathy.github.io
- Google ML: Testing and debugging developers.google.com
- Google: Deep Learning Tuning Playbook github.com
- PyTorch: autograd anomaly detection docs.pytorch.org
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Tracking and comparing runs
Within a week you will not remember which run used which data, so log everything from the first experiment: the code commit, data snapshot, full configuration, seeds, environment, metrics over time and the final artefact. A tracker such as MLflow or Weights and Biases makes runs searchable and comparable side by side. Only compare runs that differ in the one change you are testing, and keep failed runs too, because they record what did not work.
Reading
- MLflow: tracking mlflow.org
- Weights and Biases: experiments docs.wandb.ai
- TensorBoard: get started tensorflow.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
Chapter 6 lab
Instruct a coding agent to run an honest, bounded tuning study
A prompt lab that closes the chapter: you write the instruction, and it is graded on a rubric.
Start the lab -
-
Phase 7 · Evaluating models
-
Choosing the metric and threshold
A metric should price mistakes the way the business does. Ranking metrics like ROC-AUC say how well a model orders cases, not whether a predicted 0.3 means a 30 percent chance, so when a probability drives a price or a cost, check calibration too. Set the decision threshold from the cost of each kind of error and from capacity, such as how many cases a team can review a day, never by default at 0.5, and report the metric at that threshold.
Reading
- scikit-learn: classification metrics scikit-learn.org
- Google ML: Accuracy, precision, recall developers.google.com
- scikit-learn: tuning the decision threshold scikit-learn.org
Start the 6 questionsTest yourself on this topic
6 graded questions · scored out of 100 with feedback · free
-
Metrics for regression and forecasts
Each regression metric punishes a different error. RMSE squares errors and so is dominated by the biggest misses; MAE weighs every unit of error alike and is best served by predicting the median; MAPE divides by the actual value, so it explodes near zero and is lopsided between over and under forecasts. When shortfalls and surpluses cost different amounts, forecast a quantile and score it with pinball loss. Always report the metric beside a naive baseline.
Reading
- scikit-learn: regression metrics scikit-learn.org
- Forecasting: Principles and Practice, evaluating point forecast accuracy otexts.com
- scikit-learn: prediction intervals with quantile loss scikit-learn.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Calibration
A model is calibrated when, among cases it scores at 0.3, about 30 percent turn out positive. Boosted trees, deep networks and anything trained on resampled data are often miscalibrated even when they rank well. Measure it on held-out data with a reliability curve and the Brier score or expected calibration error, then fix it with Platt scaling, isotonic regression or temperature scaling, fitted on data the model never trained on. Recheck it after every retrain.
Reading
- scikit-learn: probability calibration scikit-learn.org
- On calibration of modern neural networks (arXiv) arxiv.org
- Predicting good probabilities with supervised learning (ICML 2005, PDF) cs.cornell.edu
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Is the improvement real
A small gain on one test set may be noise. Compare models on the same examples with a paired test or a bootstrap interval on the difference, and train each with several seeds so you know how far the score moves on its own. Fix the comparison before you look, so you do not keep slicing until something wins. An offline win is a hypothesis: confirm it online, and when offline and online disagree, look for a mismatch in metric, data or features.
Reading
- scikit-learn: statistical comparison of models scikit-learn.org
- Google ML: Testing and debugging developers.google.com
- Accounting for variance in machine learning benchmarks (arXiv) arxiv.org
Start the 6 questionsTest yourself on this topic
6 graded questions · scored out of 100 with feedback · free
-
Error analysis
One overall score hides where a model fails. Pull a sample of real mistakes, tag each with a cause and count the tags, so you know which fix could move the metric most and which would barely register. Slice metrics by segment, input type and data source to find groups that do far worse than average. Have people relabel a sample as well: if they disagree with each other as often as with the model, label noise sets a ceiling no model can pass.
Reading
- Google ML: Evaluating for bias (slicing) developers.google.com
- scikit-learn: confusion matrix scikit-learn.org
- Pervasive Label Errors in Test Sets (arXiv) arxiv.org
Start the 7 questionsTest yourself on this topic
7 graded questions · scored out of 100 with feedback · free
-
Behavioural tests for models
A held-out score tells you how often a model is right, not whether it learned the behaviour you need. Behavioural tests check it like software: minimum functionality tests on simple cases it must get right, invariance tests that a change which should not matter (a name, a typo, a brightness shift) leaves the prediction alone, and directional tests that a change which should matter moves it the right way. Run them on every retrain.
Reading
- Beyond accuracy: behavioral testing of NLP models with CheckList (arXiv) arxiv.org
- CheckList on GitHub github.com
- Google Research: The ML Test Score rubric research.google
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Online tests for model launches
An offline metric is a guess about what users will do; an online test checks it. In an A/B test, randomise by user rather than by request so each person's experience stays consistent, fix the success metric and guardrails such as latency, revenue and complaints before you start, and size the test to detect the effect you care about. For rankers, interleaving shows each user a mix of both models' results and finds a preference with far less traffic.
Reading
- Evan Miller: sample size calculator evanmiller.org
- Google: Rules of ML (launch and iterate) developers.google.com
- Microsoft Research: Experimentation Platform microsoft.com
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
Chapter 7 lab
Write the instruction for a ship or no-ship model comparison
A prompt lab that closes the chapter: you write the instruction, and it is graded on a rubric.
Start the lab -
-
Phase 8 · Training at scale
-
Where training memory goes
Training memory has four parts: the weights, a gradient for each weight, the optimizer's state and the activations saved for the backward pass. With Adam in mixed precision the first three come to about 16 bytes per parameter, so a 7 billion parameter model needs over 100 GB before a single activation. Activations grow with batch size and sequence length. Do this arithmetic before launching and you know which fix you need: sharding, offloading, checkpointing or a smaller batch.
Reading
- ZeRO: memory optimizations toward training trillion parameter models (arXiv) arxiv.org
- PyTorch: understanding CUDA memory usage docs.pytorch.org
- Hugging Face: The Ultra-Scale Playbook huggingface.co
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Mixed precision training
Mixed precision runs most matrix multiplies in 16-bit floats, which roughly halves activation memory and uses the GPU's fast tensor cores, while keeping sensitive steps such as reductions and the weight update in 32-bit. bf16 has the same range as fp32 and usually just works on recent GPUs; fp16 has a narrow range, so small gradients underflow unless the loss is scaled up first, which PyTorch's GradScaler does. Compare a short run against fp32 before you trust it.
Reading
- PyTorch: automatic mixed precision (torch.amp) docs.pytorch.org
- PyTorch: AMP recipe docs.pytorch.org
- Mixed precision training (arXiv) arxiv.org
- NVIDIA: Train with mixed precision docs.nvidia.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Gradient accumulation and activation checkpointing
Gradient accumulation runs several small batches, adds up their gradients and steps the optimizer once, so you get the effective batch size you want on a GPU that cannot hold it. Divide each loss by the number of steps, and remember batch normalisation still sees only the small batch. Activation checkpointing saves only some layers' outputs and recomputes the rest in the backward pass, trading roughly a third more compute for much less activation memory.
Reading
- PyTorch: torch.utils.checkpoint docs.pytorch.org
- Training deep nets with sublinear memory cost (arXiv) arxiv.org
- Hugging Face Accelerate: gradient accumulation huggingface.co
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Input pipeline throughput
If the GPU waits for the next batch, a faster model changes nothing. Check by timing the data loader alone against a full training step, or by looking for idle gaps in a profiler trace. The usual fixes are more DataLoader worker processes, pinned memory with non-blocking copies to the GPU, prefetching, moving heavy decoding out of the loop into a preprocessed format, and packing many small files into larger shards that read sequentially.
Reading
- PyTorch: torch.utils.data docs.pytorch.org
- PyTorch: performance tuning guide docs.pytorch.org
- PyTorch: pin_memory and non_blocking docs.pytorch.org
- WebDataset on GitHub github.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Profiling a training step
Before you optimise, find out where a step's time goes. The PyTorch Profiler records every operator and kernel on the CPU and GPU and lays them on a timeline: gaps on the GPU mean it waits on data, the CPU or a synchronisation; long communication kernels mean the network is the limit; many tiny kernels suggest fusion or compilation would help. Profile a few steps after warmup, change one thing, then profile again to confirm the gain.
Reading
- PyTorch: profiler recipe docs.pytorch.org
- PyTorch: torch.profiler docs.pytorch.org
- Horace He: Making deep learning go brrrr from first principles horace.io
- NVIDIA Nsight Systems developer.nvidia.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Compiling models with torch.compile
torch.compile captures your model's Python into graphs and generates fused kernels, so chains of small operations stop round-tripping through GPU memory, often a solid speed-up for one line of code. The first steps are slow while it compiles. Code it cannot trace, such as data-dependent Python branches or printing tensors, causes graph breaks that cost speed, and changing input shapes can force recompiles, so check its logs for both before you trust the gain.
Reading
- PyTorch: Introduction to torch.compile docs.pytorch.org
- PyTorch: torch.compiler docs.pytorch.org
- PyTorch: torch.compile troubleshooting docs.pytorch.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Data parallel training (DDP)
Distributed data parallel runs one full copy of the model per GPU, gives each a different slice of every batch, and averages gradients across the copies with an all-reduce during the backward pass, so every copy takes the same step. The code changes are small: launch with torchrun, wrap the model in DDP, give the DataLoader a DistributedSampler and save checkpoints from one rank only. The effective batch grows with the GPU count, so revisit the learning rate.
Reading
- PyTorch: Getting started with distributed data parallel docs.pytorch.org
- PyTorch: torchrun docs.pytorch.org
- PyTorch Distributed: experiences on accelerating data parallel training (arXiv) arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Sharded training (FSDP and ZeRO)
When a model's weights, gradients and optimizer state no longer fit on one GPU, sharded data parallel splits all three across the GPUs and gathers each layer's full weights only while that layer runs. PyTorch's FSDP and DeepSpeed's ZeRO stages implement the idea, and sharding per transformer block keeps each gathered piece small. You trade memory for extra communication; beyond that, tensor and pipeline parallelism split the layers themselves.
Reading
- PyTorch: Getting started with FSDP2 docs.pytorch.org
- PyTorch: torch.distributed.fsdp.fully_shard docs.pytorch.org
- DeepSpeed: ZeRO tutorial deepspeed.ai
- Hugging Face: The Ultra-Scale Playbook huggingface.co
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Scaling laws and compute budgets
Scaling laws describe how loss falls smoothly and predictably as parameters, data and compute grow, which lets you plan a large run from small ones. The Chinchilla study found that for a fixed compute budget, parameters and training tokens should grow together, roughly 20 tokens per parameter, though models meant for heavy traffic are often trained far longer because a smaller model is cheaper to serve. Fit the curve on small runs before committing to a big one.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
-
Phase 9 · Foundation models and fine-tuning
-
Self-supervised pretraining
Self-supervised learning makes its own labels from raw data: predict the next token, fill in a masked word or image patch, or tell matching views of the same thing from mismatched ones. Because nothing needs annotating, a model can learn from far more data than any labelled set, and what it learns transfers to many tasks. That is why most work now starts from a pretrained model, and why you fine-tune rather than train from scratch unless your data is unlike anything public.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Tokenizers
Language models read tokens, not characters: a tokenizer such as BPE or SentencePiece splits text into subword pieces from a fixed vocabulary learned on its training corpus. The vocabulary sets how many tokens a sentence costs, so languages, code or jargon it saw little of become long and expensive. A model only works with the exact tokenizer and special tokens it was trained with, and a mismatch rarely raises an error: it quietly degrades every output.
Reading
- Hugging Face: Summary of the tokenizers huggingface.co
- Neural machine translation of rare words with subword units, BPE (arXiv) arxiv.org
- SentencePiece (arXiv) arxiv.org
- Hugging Face LLM Course: Tokenizers huggingface.co
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Full fine-tuning or LoRA
Full fine-tuning updates every weight, which gives the most room to adapt but needs gradient and optimizer memory for all of them and a full model copy per task. LoRA freezes the base and trains small low-rank matrices added to chosen layers, cutting trainable parameters by orders of magnitude, and QLoRA also holds the frozen base in 4-bit. Adapters are small enough to keep one per task over a shared base. Start with LoRA and move to full tuning if it plateaus on your evals.
Reading
- LoRA: low-rank adaptation of large language models (arXiv) arxiv.org
- QLoRA: efficient finetuning of quantized LLMs (arXiv) arxiv.org
- Hugging Face PEFT documentation huggingface.co
- LoRA learns less and forgets less (arXiv) arxiv.org
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Supervised fine-tuning data
Supervised fine-tuning teaches a model to answer the way your examples do, so the data is the product. Format every example with the model's own chat template, compute the loss only on the response tokens so the model is not trained to write prompts, and when you pack short examples into full sequences, stop attention crossing between them. A few thousand clean, varied, correct examples usually beat a large noisy set; deduplicate them and keep evaluation prompts out.
Reading
- Hugging Face TRL: SFT Trainer huggingface.co
- Hugging Face Transformers: chat templates huggingface.co
- LIMA: less is more for alignment (arXiv) arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Preference tuning (DPO and RLHF)
Preference tuning learns from pairs: for one prompt, a response people preferred and one they rejected. RLHF trains a reward model on those pairs, then optimises the language model against it with reinforcement learning; DPO skips the reward model and raises the likelihood of preferred over rejected responses relative to a frozen reference model. In both, a penalty for drifting from the reference stops the model gaming the signal and losing general skill.
Reading
- Training language models to follow instructions, InstructGPT (arXiv) arxiv.org
- Direct Preference Optimization (arXiv) arxiv.org
- Hugging Face TRL: DPO Trainer huggingface.co
- Hugging Face: Illustrating RLHF huggingface.co
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Training embedding models
An embedding model is trained so that matching pairs, such as a query and the passage that answers it, land close together while everything else lands far apart. Contrastive losses use the other examples in a batch as negatives, so bigger batches help, and hard negatives, near misses that look relevant but are not, teach the fine distinctions. Fine-tuning a general embedder on a few thousand of your own pairs often lifts retrieval clearly; measure recall at k on held-out queries.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Knowledge distillation
Distillation trains a small student model to match a large teacher, usually on the teacher's full probability distribution rather than hard labels alone, because those soft targets show which wrong answers are nearly right. The student can approach the teacher's accuracy at a fraction of the serving cost. For language models you can also fine-tune the student on the teacher's generated outputs. Check the teacher's licence allows it, and evaluate the student on your task, not the teacher's benchmarks.
Reading
- Distilling the knowledge in a neural network (arXiv) arxiv.org
- DistilBERT (arXiv) arxiv.org
- Hugging Face TRL: GKD Trainer huggingface.co
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Evaluating fine-tuned language models
A fine-tune is only better if a held-out set built from your real task says so. Score outputs with exact checks where you can and with rubrics graded by people or a validated model judge where you cannot, and compare against the base model and a prompted baseline. Rerun a few general benchmarks too, since fine-tuning can erase skills you did not train for. Public benchmark scores may be inflated by test data that leaked into pretraining, so trust your own sets first.
Reading
- EleutherAI: lm-evaluation-harness github.com
- Judging LLM-as-a-judge with MT-Bench and Chatbot Arena (arXiv) arxiv.org
- Benchmark contamination with rephrased samples (arXiv) arxiv.org
- Stanford CRFM: HELM crfm.stanford.edu
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
-
Phase 10 · Ranking and recommendation
-
Retrieval, then ranking
You cannot run a heavy model on millions of items for every request, so recommendation and search systems work in stages. Cheap candidate generators, such as embedding lookup, popularity and co-occurrence, pull a few hundred items; a richer ranking model scores those with full features; a final pass applies business rules, diversity and filters. Each stage caps the next, because an item the retriever misses can never be ranked, so measure recall at the retrieval stage on its own.
Reading
- Google Research: Deep neural networks for YouTube recommendations research.google
- Google: Recommendation systems course developers.google.com
- Eugene Yan: System design for recommendations and search eugeneyan.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Two-tower retrieval models
A two-tower model encodes users (or queries) and items with separate networks into one vector space, and scores a pair by the dot product of their vectors. Because item vectors do not depend on the user, you precompute them all and find each user's best matches with approximate nearest neighbour search in milliseconds. Train with in-batch or sampled negatives, correct for popular items turning up as negatives far more often, and rebuild the item index whenever the item tower changes.
Reading
- Google: Sampling-bias-corrected neural modeling for recommendations research.google
- TensorFlow Recommenders: retrieval tutorial tensorflow.org
- Faiss on GitHub github.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Learning-to-rank losses
A ranker only needs to put items in the right order, and its loss can say so directly. Pointwise losses score each item alone, as regression or classification on a relevance label; pairwise losses penalise each pair placed in the wrong order; listwise losses such as LambdaRank weight those mistakes by how much they hurt a metric at the top of the list. Gradient-boosted rankers such as LambdaMART remain strong baselines for search with rich features.
Reading
- Microsoft Research: From RankNet to LambdaRank to LambdaMART microsoft.com
- XGBoost: learning to rank xgboost.readthedocs.io
- TensorFlow Ranking on GitHub github.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Ranking metrics
Ranking metrics weight the top of the list, because that is what people see. Recall at k asks whether the relevant items made the first k at all and suits the retrieval stage; MRR rewards putting the first relevant item high and suits tasks with one right answer; NDCG uses graded relevance discounted by position and suits feeds and search results. Set k to what the screen shows, and average per query or user so heavy users do not dominate.
Reading
- scikit-learn: ndcg_score scikit-learn.org
- Google: Recommendation systems course developers.google.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Position bias in implicit feedback
Clicks are the cheapest labels you have, and they are biased: people click top results more simply because they are on top, so a model trained on raw clicks learns to repeat the old ranking. Estimate how attention falls with position, from small randomised swaps or from logs where the same item appeared in different spots, then weight clicks by the inverse of that propensity, or feed position in as a training feature and fix it to one value at serving time.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Cold start
A new user or item has no interaction history, so a model that leans on learned id embeddings has nothing to say about it. Fill the gap with content: an item's text, images, category and price, or a new user's context and sign-up answers, encoded by a model that generalises from those features. Give new items some guaranteed exposure through exploration so they can earn data, and fall back to items popular in the user's context until history builds up.
Reading
- Google: Content-based filtering developers.google.com
- A contextual-bandit approach to news recommendation (arXiv) arxiv.org
- DropoutNet: addressing cold start in recommender systems (NeurIPS) papers.nips.cc
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Offline evaluation from logged data
Logs only show how users reacted to what the old system chose, so replaying them to score a new ranker is biased towards whatever the old one liked. Off-policy estimators weight each logged outcome by how likely the new policy is to make that choice compared with the old one, which means you must log the old policy's probability for every choice. Inverse propensity scoring is unbiased but noisy; doubly robust estimators add a model to cut the noise. Use the result to filter candidates before an online test.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
-
Phase 11 · Shipping and running models
-
Serving models
Serving puts a model behind a latency, throughput and cost budget. Decide first whether predictions can be computed in batch ahead of time or must be made per request, because batch is simpler, cheaper and easier to check. Ship the preprocessing, pinned library versions, feature schema and threshold with the model as one versioned artefact. Then profile the whole request path at p99, because feature lookups and network calls often cost more than the model itself.
Reading
- Google: MLOps continuous delivery cloud.google.com
- scikit-learn: model persistence scikit-learn.org
- NVIDIA Triton Inference Server user guide docs.nvidia.com
Start the 5 questionsTest yourself on this topic
5 graded questions · scored out of 100 with feedback · free
-
Exporting a model for inference
Training code is the wrong thing to ship: it drags in the training framework, Python control flow and pickled objects that can run arbitrary code when loaded. Export the trained network to a stable format instead, such as a torch.export program or ONNX for runtimes like ONNX Runtime and TensorRT, and store weights as safetensors. Then run the same inputs through the original and the export and check they agree within a tolerance, including at batch sizes you did not trace with.
Reading
- PyTorch: torch.export docs.pytorch.org
- PyTorch: export a model to ONNX docs.pytorch.org
- ONNX Runtime documentation onnxruntime.ai
- Hugging Face: safetensors huggingface.co
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Quantising your model
Quantisation stores weights, and sometimes activations, as 8-bit or smaller integers instead of 32-bit floats, cutting memory and often latency several times over. Post-training quantisation needs only a small calibration set to pick value ranges; if accuracy drops too far, quantisation-aware training simulates the rounding during training so the model learns around it. The loss is uneven across inputs, so rerun your full evaluation, worst slices included, on the quantised model before shipping.
Reading
- PyTorch: torchao documentation docs.pytorch.org
- ONNX Runtime: quantize ONNX models onnxruntime.ai
- Quantization and training for integer-arithmetic-only inference (arXiv) arxiv.org
- Integer quantization for deep learning inference (arXiv) arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Shadow and canary launches
In shadow mode the new model scores live traffic beside the old one, but only the old one's answers are used, so you compare predictions, latency and errors on real inputs at no risk to users. A canary then lets the new model decide for a small share of traffic, watched against guardrails, before you widen it step by step. Agree beforehand what difference counts as a problem and who can roll back, and keep the old model running until the new one has seen a full business cycle.
Reading
- Google SRE Workbook: Canarying releases sre.google
- Amazon SageMaker: shadow tests docs.aws.amazon.com
- Google: MLOps continuous delivery cloud.google.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Logging predictions
When someone asks why the model made a decision last Tuesday, you can only answer if you logged it. Record each prediction with a request id, timestamp, model version, the exact feature values the model saw (not values recomputed later), the output and the threshold, then join outcomes to it as they arrive. That log is your debugging tool, your monitoring source and your next training set, so keep it consistent, and protect personal data in it as carefully as in the source.
Reading
- Google: Rules of ML (log features at serving time) developers.google.com
- Chip Huyen: Real-time machine learning, challenges and solutions huyenchip.com
- Evidently: ML monitoring docs docs.evidentlyai.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Detecting data and concept drift
Production data changes. Covariate drift changes the inputs; concept drift changes what the inputs mean for the label, and only labels can confirm it. Since labels often arrive weeks late, watch data quality, feature distributions and the distribution of predictions as early signals, compared against a reference window from training. Alert on the features that matter most to the model, with thresholds tuned on past data, so a real problem is not lost in noise.
Reading
- Google: Rules of ML (monitoring) developers.google.com
- Evidently: ML monitoring docs docs.evidentlyai.com
- arXiv: Failing loudly, detecting dataset shift arxiv.org
Start the 5 questionsTest yourself on this topic
5 graded questions · scored out of 100 with feedback · free
-
Feedback loops
Once a model acts, it shapes the data it will later learn from. A fraud model that blocks a payment never learns whether it was fraud; a recommender that shows only what it already favours never learns about anything else; a model that directs inspections finds problems mainly where it already looks. Break the loop on purpose: keep a small random holdout the model does not control, log what the model decided, and train on data that records that decision.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Retraining
Retraining is a release, so make every run reproducible: record the code commit, data snapshot, configuration, seeds and environment. Retrain on a schedule matched to how fast the world changes, or on a trigger such as drift, but promote a candidate only when it beats the current model on a recent held-out window and on the slices you cannot afford to lose. Roll it out gradually, with the previous model kept ready as a fast way back.
Reading
- Google: MLOps automation pipelines cloud.google.com
- MLflow: model registry mlflow.org
- Google: Rules of ML developers.google.com
Start the 5 questionsTest yourself on this topic
5 graded questions · scored out of 100 with feedback · free
-
ML system design
Designing an ML system starts from the decision, not the model: what is predicted, how fast, how often, what a wrong answer costs and how success is measured. Then sketch the loop end to end: data sources and labels, features at training and serving time, the model and its baseline, the serving path, logging, monitoring and retraining. Most lasting cost lives in that glue rather than the model code, so prefer the simplest design that meets the need and say what you would add next.
Reading
- Chip Huyen: Machine learning systems design huyenchip.com
- Hidden Technical Debt in Machine Learning Systems (NeurIPS 2015) papers.nips.cc
- Google: Rules of ML developers.google.com
- Eugene Yan: applied-ml papers and write-ups github.com
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
Chapter 11 lab
Write the instruction for an on-call drift runbook with delayed labels
A prompt lab that closes the chapter: you write the instruction, and it is graded on a rubric.
Start the lab -
-
Phase 12 · Responsible ML
-
Fairness across groups
A model can be accurate overall and still fail one group badly, so measure performance per group whenever a decision affects people. Common criteria compare selection rates, error rates or calibration across groups, and when base rates differ they cannot all hold at once, so you must choose the one that fits the harm at stake. Check whether a proxy such as postcode stands in for a protected trait, and fix data and thresholds before adding constraints to training.
Reading
- Fairlearn user guide fairlearn.org
- Google ML Crash Course: Fairness developers.google.com
- Inherent trade-offs in the fair determination of risk scores (arXiv) arxiv.org
- Fairness and Machine Learning (free book) fairmlbook.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Explaining predictions
Explanation tools answer two questions: which features matter to the model overall, and why it made one prediction. Permutation importance measures how far the score drops when a feature is shuffled; SHAP splits one prediction into per-feature contributions; partial dependence shows how the output moves with one feature. All of them describe the model, not the world: high importance is not a cause, and correlated features share or swap credit, so check with domain experts before acting.
Reading
- scikit-learn: permutation feature importance scikit-learn.org
- SHAP documentation shap.readthedocs.io
- Interpretable Machine Learning (free book) christophm.github.io
- A unified approach to interpreting model predictions, SHAP (arXiv) arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Model cards and datasheets
A model card records what a model is for and not for, how it was trained and evaluated, how it performs on the slices that matter, and its known limits. A datasheet does the same for a dataset: where it came from, who is in it, how it was labelled and what it should not be used for. Write both while you build, when the facts are at hand, and update them on every retrain, because the next team, a reviewer or an auditor will read them before your code.
Reading
- Model cards for model reporting (arXiv) arxiv.org
- Datasheets for datasets (arXiv) arxiv.org
- Hugging Face: model cards huggingface.co
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Privacy and memorisation
Models can memorise rare training examples and repeat them: language models have reproduced names, phone numbers and addresses verbatim, and membership inference can reveal whether a person's record was in the training set. Remove personal data the task does not need before training, and deduplicate, which also cuts memorisation. When the risk is high, differentially private training such as DP-SGD bounds what any one record can change, at an accuracy cost you must measure.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Attacks on models
Models have attack surfaces of their own. Poisoning slips crafted examples into training data to plant a backdoor or skew decisions; evasion nudges an input just enough that the model gets it wrong; extraction queries a model until it can be copied or its training data recovered. Loading weights is a risk too, since pickle-based checkpoints can run code when opened, so prefer safetensors. Control who can write to training data, and rate-limit and watch prediction APIs.
Reading
- OWASP Machine Learning Security Top 10 owasp.org
- MITRE ATLAS atlas.mitre.org
- PyTorch: torch.load and weights_only docs.pytorch.org
- Hugging Face: safetensors huggingface.co
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Models in regulated decisions
When a model helps decide credit, hiring, insurance or care, regulators expect more than a good score. Model risk management, as in US banking guidance (SR 26-2, which replaced SR 11-7 in April 2026), asks for documented development, independent validation, ongoing monitoring and an inventory of models in use. Laws such as the EU AI Act add risk management, data governance, logging and human oversight for high-risk uses. Build that evidence as you go: it is far cheaper than reconstructing it for an audit.
Reading
- Federal Reserve: SR 26-2, revised model risk guidance federalreserve.gov
- European Commission: AI Act regulatory framework digital-strategy.ec.europa.eu
- European Commission: AI Act Service Desk ai-act-service-desk.ec.europa.eu
- NIST: AI Risk Management Framework nist.gov
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Practise the ML Engineer roadmap
314 questions, each graded on the server out of 100. Free · no card.
Other AI careers
- Agent Engineer
- AI Alignment Researcher
- AI Data Engineer
- AI Engineer
- AI Evals Engineer
- AI Governance Analyst
- AI Infrastructure Engineer
- AI Integration Engineer
- AI Product Manager
- AI Red Team Specialist
- AI Reliability Engineer
- AI Research Engineer
- AI Safety Engineer
- AI Security Engineer
- AI Solutions Architect
- AI Strategist
- Computer Vision Engineer
- Context Engineer
- Conversational AI Designer
- Forward-Deployed Engineer
- Inference Optimization Engineer
- Multimodal AI Engineer
- Post-Training Engineer