Slides · ML systems and interviews

The ML interview playbook: structure, answer method, debugging procedures, estimates and project defence

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:

  1. Map the round types to methods.
  2. Run the ten-step answer method and the explanation ladder.
  3. Debug by an ordered procedure.
  4. Estimate, sanity-check and state uncertainty.
  5. Defend a project and avoid the traps.

Source1 Update on Machine Learning Interviews Book

Diagram

An answer is a chain of decisions

Diagram: Clarify, then baseline and metric, then data, model and evaluation, then failure modes and trade-offs, then monitoring.

interviewer redirects

Question

Clarify and
assume

Baseline and
metric

Data, model,
evaluation

Failure modes,
trade-offs

Monitor,
say what next

Diagram summary: Clarify, then baseline and metric, then data, model and evaluation, then failure modes and trade-offs, then monitoring. A redirect from the interviewer sends you back to clarifying, which is normal.

Compare

Six round types, six methods

RoundMethod
FundamentalsLadder: intuition, maths, code, pitfall
ML codingClarify, simple version, edge cases, then speed
System designThe nine steps
Applied caseThe ten-step method
Project deep diveSTAR with measured numbers
BehaviouralSTAR, 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

StepSay
1 ClarifyDecision, users, scale, latency
2 AssumeWrite them down
3 BaselineRule, majority class, linear model
4 MetricOne primary, one guardrail
5 DataLabels, delay, leakage, split
6 ModelSimplest that could work
7 EvaluationError analysis, uncertainty
8 Failure modesTwo or three, before asked
9 Trade-offsWhat you gave up
10 MonitoringWatch, and what triggers retraining
  • Baseline and metric come before the model. If time is short, say which steps you compress.

Source2 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

RungTest
IntuitionCould a friend repeat it?
MathsWhich symbols, what grows?
CodeCould you write it on a whiteboard?
PitfallA 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.

Source3 Attention Is All You Need

Diagram

Debug in an order

Diagram: Test the loudest symptoms first: NaN, flat loss, a score that is too good, an offline and online mismatch (experiment first, serving...

yes

no

yes

no

yes

no

yes

no

Symptom

Loss NaN?

Find the first non-finite step,
check data, then learning rate

Loss flat?

Overfit a tiny batch

Score too good,
or leakage suspected?

Audit the split and features

Offline up,
online flat?

Check the experiment,
then serving features

Read the learning curve:
bias or variance

Diagram summary: Test the loudest symptoms first: NaN, flat loss, a score that is too good, an offline and online mismatch (experiment first, serving features second), and only then the learning-curve reading of bias and variance.

Source4 A Recipe for Training Neural Networks

Compare

First step by symptom

SymptomFirst step
NaN lossFirst non-finite step, then data, then rate
Flat lossTiny batch, then pipeline or optimiser
Too goodShuffle labels, shared ids, top feature
Offline up, online flatExperiment first, then serving features
Train low, validation highLearning curve, then data or regularisation
Train highBias: capacity, features
  • The homework function first_step follows 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.

Sources5 Validation curves: plotting scores to evaluate models6 KFold7 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

CheckResult
Honest feature AUC0.718
Proxy feature AUC1.000
Chance baseline: honest feature, shuffled labels0.503
Proxy feature, shuffled labels0.469
Noise category target-encoded on all rows0.758
Same, shuffled labels0.784
Same, encoded out of fold0.443
Random row split, patients on both sides0.950 of validation rows
Split by patient0.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.

Source8 Common pitfalls and recommended practices (data leakage)

Math

Base rate by hand

PPV=πsπs+(1−π)f\mathrm{PPV}=\frac{\pi s}{\pi s+(1-\pi)f}
  • 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.

Source9 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

QuantityWidths 784, 256, 128, 10
Parameters235,146
fp32 memory0.94 MB
Forward FLOPs, 1 example469,504
Forward FLOPs, batch of 6430,048,256
Time at an assumed 10 GFLOP/s3.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

p+z22n±zp(1−p)n+z24n21+z2n\frac{p+\frac{z^2}{2n}\pm z\sqrt{\frac{p(1-p)}{n}+\frac{z^2}{4n^2}}}{1+\frac{z^2}{n}}
  • 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.

Source10 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

Diagram: From the problem through data, a baseline and the final model to the metrics, deployment and an honest account of what failed.

Problem and
why it mattered

Data, labels,
leakage risks

Baseline, then
final model

Metric and
honest numbers

Serving and
monitoring

What failed,
what I would change

Diagram summary: From the problem through data, a baseline and the final model to the metrics, deployment and an honest account of what failed. The UW career-centre guide suggests about 20%, 10%, 60% and 10% for situation, task, action and result.

Source11 STAR Method of Interviewing

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

TrapFix
Hand-wavingName model, metric, reason
Metric without baselineQuote the baseline
Ignoring leakageState the split and why
Jumping to the modelFrame, baseline, metric first
False precisionRounded number plus interval
Bluffing a formulaState the idea and the gap

Worked example

A practice routine

CadenceWhat
Daily5 to 10 questions, 90 seconds each, aloud
WeeklyA suggested 45-minute split: 5 intro and project, 12 fundamentals, 25 design or coding, 3 your questions
After each mockOne-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)

  1. Update on Machine Learning Interviews Book (opens in a new tab)

    Chip Huyen2019Article

    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.

  2. Rules of Machine Learning: Best Practices for ML Engineering (opens in a new tab)

    Google for Developers2026Article

    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).

  3. 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

    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.

  4. A Recipe for Training Neural Networks (opens in a new tab)

    Andrej Karpathy2019Article

    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.

  5. Validation curves: plotting scores to evaluate models (opens in a new tab)

    scikit-learn2026Documentation

    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)

  1. KFold (opens in a new tab)

    scikit-learn2026Documentation

    Used for KFold makes consecutive folds without shuffling by default, and the first n_samples % n_splits folds have one extra sample.

  2. TimeSeriesSplit (opens in a new tab)

    scikit-learn2026Documentation

    Used for TimeSeriesSplit is for time-ordered data where other methods would train on future data and evaluate on past data.

  3. Common pitfalls and recommended practices (data leakage) (opens in a new tab)

    scikit-learn2026Documentation

    Used for Split the data before any preprocessing and never include test data when fitting, to avoid data leakage.

  4. DummyClassifier (opens in a new tab)

    scikit-learn2026Documentation

    Used for DummyClassifier as a simple baseline to compare against more complex classifiers.

  5. proportion_confint (opens in a new tab)

    statsmodels2026Documentation

    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)

  1. STAR Method of Interviewing (opens in a new tab)

    University of Washington Career & Internship Center2026Article

    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.