Slides · ML systems and interviews
The ML interview playbook: structure, answer method, debugging procedures, estimates and project defence
1 / 26
The ML interview playbook
Structure, answer method, debugging procedures, estimates and project defence.
Concept
Why delivery matters
- An interview grades what a listener can hear you work out, not only what you know.
- One practitioner reports that interviewers often care more about how you answer than about the answer’s correctness (Huyen, 2019). That is one author’s experience.
- Everything here is a common pattern, not a claim about any named company.
Five things you will be able to do:
- Map the round types to methods.
- Run the ten-step answer method and the explanation ladder.
- Debug by an ordered procedure.
- Estimate, sanity-check and state uncertainty.
- Defend a project and avoid the traps.
Diagram
An answer is a chain of decisions
Compare
Six round types, six methods
| Round | Method |
|---|---|
| Fundamentals | Ladder: intuition, maths, code, pitfall |
| ML coding | Clarify, simple version, edge cases, then speed |
| System design | The nine steps |
| Applied case | The ten-step method |
| Project deep dive | STAR with measured numbers |
| Behavioural | STAR, an owner, a lesson |
- A common pattern. Loops differ and rounds overlap. Ask the recruiter what each covers.
Check yourself
Check: the first minute of a coding round
You are asked to write the softmax of a list of numbers from scratch. What do you say and do before typing the final code?
Answer
Confirm the input (a list of floats? any length, empty?) and the output (a list summing to 1). Write the plain version first, then test large inputs, since the exponential can overflow. Subtract the largest value before exponentiating, which keeps the result the same. Offer to vectorise last.
Worked example
The ten steps
| Step | Say |
|---|---|
| 1 Clarify | Decision, users, scale, latency |
| 2 Assume | Write them down |
| 3 Baseline | Rule, majority class, linear model |
| 4 Metric | One primary, one guardrail |
| 5 Data | Labels, delay, leakage, split |
| 6 Model | Simplest that could work |
| 7 Evaluation | Error analysis, uncertainty |
| 8 Failure modes | Two or three, before asked |
| 9 Trade-offs | What you gave up |
| 10 Monitoring | Watch, and what triggers retraining |
- Baseline and metric come before the model. If time is short, say which steps you compress.
Source[2] Rules of Machine Learning: Best Practices for ML Engineering
Check yourself
Check: a vague prompt
“Predict which customers will cancel next month.” Give steps 1 to 4 in four sentences.
Answer
Who acts on the prediction and what do they do (a retention offer with a cost)? Assume monthly data and a label of “cancelled within 30 days”. Baseline: the cancel rate by plan, or last month’s usage drop. Metric: precision and recall at the number of customers the team can contact, with offer cost as the guardrail.
Compare
The ladder for fundamentals
| Rung | Test |
|---|---|
| Intuition | Could a friend repeat it? |
| Maths | Which symbols, what grows? |
| Code | Could you write it on a whiteboard? |
| Pitfall | A concrete failure |
- Example: precision is TP over TP plus FP, recall is TP over TP plus FN. Both need a rule when a denominator is zero.
- Example: dividing attention scores by the square root of d. With unit-variance independent components the dot product has variance d, which the original paper notes in a footnote.
Diagram
Debug in an order
Compare
First step by symptom
| Symptom | First step |
|---|---|
| NaN loss | First non-finite step, then data, then rate |
| Flat loss | Tiny batch, then pipeline or optimiser |
| Too good | Shuffle labels, shared ids, top feature |
| Offline up, online flat | Experiment first, then serving features |
| Train low, validation high | Learning curve, then data or regularisation |
| Train high | Bias: capacity, features |
- The homework function
first_stepfollows this order: the first four rows are its rules, the last two its fallback. - Pick the splitter that fits the data: KFold for independent rows, TimeSeriesSplit for time-ordered rows. The curve reading uses learning curves.
Sources[5] Validation curves: plotting scores to evaluate models[6] KFold[7] TimeSeriesSplit
Check yourself
Check: the tiny batch
You overfit five examples and the loss falls to nearly zero, but the full run is flat. What does that tell you, and what next?
Answer
The model, loss and labels can learn, so the pipeline code is probably right and the problem is tuning at scale. Look at the learning rate and schedule, initialisation, normalisation and whether the full-data batches are shuffled and labelled correctly.
Worked example
Too good to be true: the simulation
| Check | Result |
|---|---|
| Honest feature AUC | 0.718 |
| Proxy feature AUC | 1.000 |
| Chance baseline: honest feature, shuffled labels | 0.503 |
| Proxy feature, shuffled labels | 0.469 |
| Noise category target-encoded on all rows | 0.758 |
| Same, shuffled labels | 0.784 |
| Same, encoded out of fold | 0.443 |
| Random row split, patients on both sides | 0.950 of validation rows |
| Split by patient | 0.000 |
- Shuffled labels expose label-using preprocessing, not a proxy. Shared ids expose group leaks. The top-feature check exposes proxies.
- Split before preprocessing and never fit on test data.
Source[8] Common pitfalls and recommended practices (data leakage)
Math
Base rate by hand
PPV=πs+(1−π)fπs- 10,000 people, 1% sick, 99% sensitivity, 5% false-positive rate.
- 99 sick positives and 495 healthy positives: 99 / 594 = 0.1667.
- Fraud, 100 in 10,000: always predicting legitimate scores 0.9900, so a model at 0.9920 needs precision and recall (0.60 each) to be judged.
Source[9] DummyClassifier
Check yourself
Check: a rare event
A fraud alert fires on 3% of legitimate payments and catches 80% of frauds, and 0.1% of payments are fraud. Roughly what share of alerts are real?
Answer
Per 100,000 payments: 100 frauds, 80 caught, and 99,900 legitimate with 2,997 false alerts. Real share is 80 / (80 + 2,997), about 2.6%. A rare event makes most alerts false even with a modest false-alarm rate.
Worked example
Parameters and FLOPs
| Quantity | Widths 784, 256, 128, 10 |
|---|---|
| Parameters | 235,146 |
| fp32 memory | 0.94 MB |
| Forward FLOPs, 1 example | 469,504 |
| Forward FLOPs, batch of 64 | 30,048,256 |
| Time at an assumed 10 GFLOP/s | 3.0 ms |
- A layer has in x out weights plus out biases and costs 2 x batch x in x out operations.
- State the throughput assumption, then offer to measure.
Math
How sure is a score
1+nz2p+2nz2±znp(1−p)+4n2z2- 182 of 200: 0.862 to 0.942. 176 of 200: 0.828 to 0.918. They overlap, which does not by itself rule out a difference.
- A direct difference test (independent scores) gives z = 0.98 at 200 items each and 3.09 at 2,000.
- With 2,000 items: 0.897 to 0.922 and 0.865 to 0.894.
- Both models share the test items, so a paired test is the better tool.
Source[10] proportion_confint
Check yourself
Check: reading an interval
A teammate says “the interval for our accuracy is 0.862 to 0.942, so the true accuracy is certainly in there”. What do you add?
Answer
Not certainly: it is a 95% interval, built to contain the true value in about 95 of 100 repeated samples, and it covers sampling noise only. It says nothing about leakage or a test set that differs from production.
Diagram
Defend a project
Check yourself
Check: the weak spot
The interviewer asks “what would break in production?” about your project and you have not thought about it. What do you do?
Answer
Say so, then reason aloud from what you know: which features come from a batch job and could be stale, what happens if the data schema changes, how you would notice drift. Name what you would monitor. A reasoned answer with a stated gap beats a bluff.
Compare
Common traps
| Trap | Fix |
|---|---|
| Hand-waving | Name model, metric, reason |
| Metric without baseline | Quote the baseline |
| Ignoring leakage | State the split and why |
| Jumping to the model | Frame, baseline, metric first |
| False precision | Rounded number plus interval |
| Bluffing a formula | State the idea and the gap |
Worked example
A practice routine
| Cadence | What |
|---|---|
| Daily | 5 to 10 questions, 90 seconds each, aloud |
| Weekly | A suggested 45-minute split: 5 intro and project, 12 fundamentals, 25 design or coding, 3 your questions |
| After each mock | One-line rule per miss, re-answer cold in a few days |
- The time split is this course’s suggestion, not a rule. Do not memorise answers word for word.
Code
Homework: the sanity-check toolkit
Python
def auc_from_scores(y_true, scores):
"""Probability a random positive outscores a random negative, ties 0.5."""
def first_step(s):
"""First debugging step for a dict of symptoms; first matching rule wins."""
def wilson_interval(successes, n, z=1.96):
"""Wilson score interval, clipped into [0, 1]."""
def mlp_forward_flops(sizes, batch):
"""2 x batch x in x out, summed over layers."""- Also: confusion counts, precision, recall, F1, majority baseline, k-fold, forward chaining, leakage fraction, curve diagnosis, base rate, parameter count.
Summary
Recap
- Rounds are a common pattern: match the method to the round and ask what each covers.
- Ten steps: clarify, assume, baseline, metric, data, model, evaluation, failure modes, trade-offs, monitoring. Explain on the ladder.
- Debug in order: NaN, flat, too good, offline and online gap, then the learning curve.
- Sanity-check with base rates, the majority baseline, shuffled labels, parameters and FLOPs. Give intervals.
- Defend projects with a baseline, a split, a measured number and what you would change. Practise aloud on a routine.
References
References & Sources (1 of 3)
Update on Machine Learning Interviews Book (opens in a new tab)
Chip Huyen2019Article
https://huyenchip.com/2019/07/21/machine-learning-interviews.html
Used for The author's account that interviewers often care more about how you go about answering than about the objective correctness of the answer, that almost all companies she talked to ask at least one open-ended systems design question, and that some companies call these machine learning systems design questions.
Rules of Machine Learning: Best Practices for ML Engineering (opens in a new tab)
Google for Developers2026Article
https://developers.google.com/machine-learning/guides/rules-of-ml
Used for Rule 1 (do not be afraid to launch without ML), rule 4 (the first model does not need to be fancy), rule 29 (save features used at serving time and log them) and rule 37 (the three differences that make up training-serving skew).
Attention Is All You Need (opens in a new tab)
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, et al.2017Advances in Neural Information Processing Systems 30 (NIPS 2017)Paper
arXiv 1706.03762 (opens in a new tab)https://arxiv.org/abs/1706.03762
Used for The footnote on scaled dot-product attention that explains why dot products grow with the key dimension, assuming independent components with mean 0 and variance 1.
A Recipe for Training Neural Networks (opens in a new tab)
Andrej Karpathy2019Article
https://karpathy.github.io/2019/04/25/recipe/
Used for Neural net training fails silently; verify the loss at initialisation; overfit a single batch of a few examples; get dumb baselines from an end-to-end skeleton.
Validation curves: plotting scores to evaluate models (opens in a new tab)
scikit-learn2026Documentation
https://scikit-learn.org/stable/modules/learning_curve.html
Used for A learning curve shows how much a model benefits from more training data and whether it suffers more from variance or bias.
References
References & Sources (2 of 3)
scikit-learn2026Documentation
https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.KFold.html
Used for KFold makes consecutive folds without shuffling by default, and the first n_samples % n_splits folds have one extra sample.
TimeSeriesSplit (opens in a new tab)
scikit-learn2026Documentation
https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.TimeSeriesSplit.html
Used for TimeSeriesSplit is for time-ordered data where other methods would train on future data and evaluate on past data.
Common pitfalls and recommended practices (data leakage) (opens in a new tab)
scikit-learn2026Documentation
https://scikit-learn.org/stable/common_pitfalls.html
Used for Split the data before any preprocessing and never include test data when fitting, to avoid data leakage.
DummyClassifier (opens in a new tab)
scikit-learn2026Documentation
https://scikit-learn.org/stable/modules/generated/sklearn.dummy.DummyClassifier.html
Used for DummyClassifier as a simple baseline to compare against more complex classifiers.
proportion_confint (opens in a new tab)
statsmodels2026Documentation
https://www.statsmodels.org/stable/generated/statsmodels.stats.proportion.proportion_confint.html
Used for A confidence interval for a binomial proportion, with the Wilson score interval offered next to the normal approximation.
References
References & Sources (3 of 3)
STAR Method of Interviewing (opens in a new tab)
University of Washington Career & Internship Center2026Article
https://careers.uw.edu/resources/star-method-of-interviewing/
Used for STAR stands for Situation, Task, Action, Result, with a suggested split of about 20%, 10%, 60% and 10% of the answer, and the advice to include quantifiable results.
Keys: ← → move, Home End first and last, F full screen.