Machine Learning Engineer Interview Questions, 24 Answered
24 Machine Learning Engineer interview questions by round, each with why it is asked, a strong answer outline, a weak answer to avoid and the follow-up.
Updated
Machine learning engineer interview questions fall into seven groups: past projects, ML fundamentals, deep learning, practical coding, ML system design, experimentation, and production reliability. Interviewers want to see you frame a problem, pick a label and metric, avoid leakage and keep a model healthy after launch. The ML system design round, usually a recommender or ranking problem, is the one that most often decides your level.
Each of the 24 questions below, written for this post, has a strong answer, a weak one and the follow-up. For the process, read the machine learning engineer interview guide.
How do machine learning engineer interview questions map to the interview loop?#
Loops vary by company, but a typical one at a large tech company is a recruiter call, one technical screen, then four to six onsite rounds: usually two coding, one ML system design, one behavioural, and sometimes an ML depth round.
Behavioural and past-project questions#
1. Walk me through a model you shipped, from problem to production#
Why it is asked: it is the fastest way to find your real level.
Strong answer: start with the business decision the model supported, then the label, baseline, offline metric, online result and what you owned. "Churn alerts for account managers. Label was cancellation within 60 days. A rules baseline scored 0.61 AUC and my model 0.74, but what mattered was precision in the top 200 accounts the team could call each week."
Weak answer: a tour of the architecture with no numbers and lots of "we".
Follow-up: "What would you remove if you rebuilt it?"
2. Tell me about a time offline and online results disagreed#
Why it is asked: the diagnosis shows whether you know how logged data and serving differ from a notebook.
Strong answer: name the gap and a concrete cause: position bias in logged clicks, a feature fresher in training than at serving time, or an offline metric (AUC on all impressions) that did not match the product goal (purchases from the top three slots). End with what changed: "We now log served features and replay them offline, and the offline-to-online gap fell from 4% to under 1%."
Weak answer: "the test was noisy, so we reran it".
Follow-up: "How would you catch that before an A/B test next time?"
3. Describe a time you argued against using machine learning#
Why it is asked: Martin Zinkevich's "Rules of Machine Learning" from Google opens with the advice not to be afraid to launch a product without machine learning, and interviewers check whether you act on it.
Strong answer: a heuristic that shipped first, how it generated training data, and the signal that ML was now worth the maintenance cost, such as the rules file passing 300 hand-tuned conditions.
Weak answer: a story where ML was obvious.
Follow-up: "How did you persuade the person who wanted the model?"
4. Tell me about a model you had to roll back or switch off#
Why it is asked: ownership and honesty under pressure.
Strong answer: detection, time to mitigate, who you told and the guard you added. "The score distribution shifted after an upstream schema change turned a price field from cents to dollars. A revenue dip caught it 9 hours later. I rolled back in 20 minutes, posted in the incident channel, then added a mean-score alert at three standard deviations and a schema contract test on that table."
Weak answer: blaming the data team.
Follow-up: "How would you shorten those 9 hours?"
Machine learning fundamentals questions#
5. Your validation score is far better than anything you expected. What do you check first?#
Why it is asked: leakage is the most common cause of an offline result that fails live, and interviewers want to see you check for it before you celebrate.
Strong answer: check for a random split on time-ordered data, a feature computed after prediction time (support tickets that follow a cancellation), duplicates across train and test, and target encoding fitted on the full data.
Weak answer: "great, ship it" or "add regularisation".
Follow-up: "How would you design the split to make that impossible?"
6. You downsampled negatives to train a click model. What happens to its probabilities?#
Why it is asked: downsampling is standard at scale, and forgetting the correction breaks any system that treats the score as a probability.
Strong answer: predictions are inflated because the model saw more positives than reality. With negatives kept at rate w, recalibrate with q = p / (p + (1 − p) / w), as described in "Practical Lessons from Predicting Clicks on Ads at Facebook" (He and colleagues, ADKDD 2014). Keeping 10% of negatives, a raw 0.5 becomes 0.5 / (0.5 + 5) ≈ 0.09. AUC is unchanged because the transform preserves order, so only log loss or a calibration check reveals the problem.
Weak answer: "AUC looks the same, so nothing changes".
Follow-up: "When would you optimise log loss rather than AUC?"
7. How do you handle a class imbalance of 1 in 1,000?#
Why it is asked: fraud, conversion and abuse problems all look like this.
Strong answer: pick a metric that reflects the cost first, such as precision at a fixed alert budget or PR-AUC rather than accuracy. Then class weights, negative downsampling with the correction above, and a threshold tied to the business cost of each error.
Weak answer: "use SMOTE" as the whole answer.
Follow-up: "The label arrives 45 days late. How does that change training?"
8. What is calibration and how do you measure it?#
Why it is asked: uncalibrated scores break auctions, pricing and any threshold set in probability terms.
Strong answer: describe a reliability diagram (bucket predictions, compare mean prediction with observed rate per bucket), name Platt scaling and isotonic regression as fixes, report expected calibration error (ECE) or the ratio of mean prediction to observed rate, and check both per key segment as well as overall.
Weak answer: confusing calibration with accuracy.
Follow-up: "Calibration is fine overall but poor for new users. Why?"
9. How do you choose a ranking metric for a recommender?#
Why it is asked: ranking metrics come up in almost every recommender design round.
Strong answer: recall at k for candidate generation (did the good items make the shortlist?), NDCG for final ranking (are the best items near the top?), and a note that logged data inherits the old model's exposure bias.
Weak answer: RMSE on ratings for an implicit-feedback product.
Follow-up: "How would you estimate a new ranker's value without an A/B test?" Expect inverse propensity scoring on logged data with some randomised exposure.
Deep learning and modern model questions#
Depth rounds increasingly include neural training questions; applied LLM work usually sits in a separate applied AI loop.
10. Your training loss goes to NaN after 2,000 steps. What do you check?#
Why it is asked: the usual causes form a short list, and the order you check them shows experience.
Strong answer: first, whether the loss spiked before the NaN, which points to the learning rate: lower it, add warmup, and clip gradients with torch.nn.utils.clip_grad_norm_. Then mixed precision: fp16 overflows above 65,504, so use dynamic loss scaling or bf16. Then the data: an infinite value in one batch, or log(0) in a custom loss. torch.autograd.detect_anomaly() finds the first operation that produced it.
Weak answer: restarting with a different random seed.
Follow-up: "It only happens on one worker out of eight. What does that suggest?"
11. Why does a transformer use layer norm rather than batch norm?#
Why it is asked: it tests whether you know what each normalisation depends on.
Strong answer: batch norm normalises each feature across the batch, so it depends on batch size and on running statistics that differ between training and inference, and padded variable-length sequences distort them. Layer norm (Ba, Kiros and Hinton, 2016) normalises across features within one token, so it behaves the same at any batch size. Many later transformers place it before each sublayer (pre-LN) for more stable training.
Weak answer: "layer norm is newer, so it is better".
Follow-up: "Where would you still choose batch norm?" Convolutional vision models with large batches.
12. When would you fine-tune a pretrained embedding model rather than train a two-tower model from scratch?#
Why it is asked: retrieval choices drive cost, latency and cold-start behaviour.
Strong answer: fine-tune a pretrained text or image encoder when items are content-rich, interaction data is thin or new items arrive constantly, because it can embed an item before anyone has clicked it. Train ID-based towers from scratch when you have hundreds of millions of interactions and behaviour matters more than content. Either way, train with in-batch negatives and serve through an approximate nearest neighbour index such as FAISS or ScaNN.
Weak answer: "always use the biggest pretrained model".
Follow-up: "The encoder adds 30 milliseconds per item. How do you keep it out of the request path?"
ML coding interview questions#
Practical rounds are often plain Python or NumPy, testing edge cases and numerical stability more than clever algorithms.
13. Write recall at k from a list of recommendations and a set of relevant items#
Why it is asked: it is short, but it exposes sloppy edge cases.
Strong answer: state definitions first, including what to do when a user has no relevant items, and de-duplicate.
def recall_at_k(recommended, relevant, k):
if not relevant:
return None # excluded from the average, by agreement
seen, top = set(), []
for item in recommended:
if item not in seen:
seen.add(item)
top.append(item)
if len(top) == k:
break
return sum(item in relevant for item in top) / len(relevant)Weak answer: dividing by k (that is precision), or returning 0 for users with nothing relevant, which drags the average down.
Follow-up: "Now average it across users from a raw event log with duplicate rows."
14. Implement NDCG at k with graded relevance#
Why it is asked: it checks the discount and the ideal ordering.
Strong answer: DCG sums each item's gain divided by log2 of its one-based position plus one. The ideal DCG applies the same sum to the true relevances sorted from highest to lowest, never to the model's scores, and NDCG returns 0 when the ideal is 0. Gains come in two forms: linear (rel) and exponential (2^rel − 1). The exponential form, common in learning-to-rank work such as LambdaMART, rewards a highly relevant item far more than a fairly relevant one.
Weak answer: building the ideal ordering from predicted scores.
Follow-up: "Which gain would you use for purchase versus click labels?"
15. Implement logistic regression trained with batch gradient descent in NumPy#
Why it is asked: writing it from scratch shows you understand the gradient, not just the API.
Strong answer: a stable sigmoid, the gradient X.T @ (p − y) / n, an L2 term and a convergence check.
import numpy as np
def sigmoid(z):
ez = np.exp(-np.abs(z))
return np.where(z >= 0, 1 / (1 + ez), ez / (1 + ez))
def fit(X, y, lr=0.1, l2=1e-3, tol=1e-6, max_iter=1000):
w, b = np.zeros(X.shape[1]), 0.0
for _ in range(max_iter):
err = sigmoid(X @ w + b) - y
gw = X.T @ err / len(y) + l2 * w
w, b = w - lr * gw, b - lr * err.mean()
if np.linalg.norm(gw) < tol:
break
return w, bFor softmax, mention the log-sum-exp trick: subtract the maximum logit before exponentiating.
Weak answer: 1 / (1 + np.exp(-z)) directly, which overflows for large negative z.
Follow-up: "Make it work on data that does not fit in memory." Expect mini-batch SGD over chunks read from disk.
16. Split an event log into train and test by time without leakage#
Why it is asked: it is the leakage question, turned into code.
Strong answer: sort by timestamp, pick a cut-off, leave a gap at least as long as the label window so no training label falls in the test period, and normalise time zones first.
Weak answer: random.shuffle followed by an 80/20 slice.
Follow-up: "Some users appear in both sets. Is that a problem?"
ML system design interview questions#
The design round rewards a fixed order: goal, label and metrics, data, then candidates, ranking, serving and monitoring. The two-stage pattern of candidate generation then ranking is described in "Deep Neural Networks for YouTube Recommendations" (Covington and colleagues, ACM RecSys 2016).
17. Design the recommendations for an online marketplace's home page#
Why it is asked: one prompt touches labels, retrieval, ranking, latency and business rules.
Strong answer: define success as purchases, not clicks, with a label such as purchase within seven days of an impression. Candidate sources (two-tower embeddings with an approximate nearest neighbour index, recently viewed, regional trending) narrowed to a few hundred, a ranker with point-in-time features, and re-ranking for diversity and business rules. Back-of-envelope: 2,000 requests per second times 500 candidates is a million scores a second, which decides whether a heavy model fits.
Weak answer: one model scoring the entire catalogue per request.
Follow-up: "Where does your 100 millisecond budget go?"
18. How would you handle cold start for new items and new users?#
Why it is asked: collaborative signals do not exist yet, and the fix trades exploration against short-term metrics.
Strong answer: separate the cases. For items, content embeddings plus a capped exploration slot, for example one position in the top ten allocated by Thompson sampling, with its cost measured against a holdout. For users, onboarding choices, context such as device and locale, and popular-in-segment fallbacks, updated in-session from the first few interactions.
Weak answer: "show the most popular items to everyone".
Follow-up: "How do you stop exploration hurting the main metric?"
19. Design a feature pipeline that is consistent between training and serving#
Why it is asked: training-serving skew, which Google's Machine Learning Crash Course describes as input data differing between training and serving, causes many silent failures.
Strong answer: define features once and reuse the code, use a feature store with an offline store for training and a low-latency online store for serving, build training sets with point-in-time joins, and log served features for comparison. See data engineer interview questions for backfills and late data.
Weak answer: "the data scientist writes it in pandas and we rewrite it for serving".
Follow-up: "A feature is three hours stale online but fresh in training. What do you see?"
Experimentation and statistics questions#
Ronny Kohavi, Diane Tang and Ya Xu's "Trustworthy Online Controlled Experiments" (2020) is the standard reference. For more A/B testing questions, see data scientist interview questions.
20. Your model improves NDCG offline but the A/B test is flat. List three causes#
Why it is asked: it tests whether you know the limits of offline evaluation.
Strong answer: first, logged data only contains items the old model showed, so the gains may sit where offline evaluation cannot score. Second, the offline label (clicks) may not drive the online metric (purchases or retention). Third, serving differs from training: skewed features, a stale model artefact, or extra latency cancelling the gain.
Weak answer: "the A/B test must be wrong".
Follow-up: "Which of those can you rule out in an hour?"
21. The test was meant to be 50/50 but you see 50.8/49.2 on two million users. Do you trust the result?#
Why it is asked: sample ratio mismatch, which has its own chapter in Kohavi's book, usually means broken assignment or logging.
Strong answer: run a chi-squared goodness-of-fit test. 1,016,000 versus 984,000 against an expected 1,000,000 each gives χ² = 2 × 16,000² / 1,000,000 = 512, a p-value far below 0.001, so the split is broken. Ignore the metric until you find the cause, such as bots filtered in one arm or a crash in the new code path.
Weak answer: "0.8% is small, carry on".
Follow-up: "Where in the stack would you look first?"
22. How would you size a test to detect a 1% relative change in conversion?#
Why it is asked: it shows you plan tests rather than running them until something is significant.
Strong answer: name the inputs, then work it. Baseline conversion 5%, so a 1% relative effect is 0.05 percentage points; alpha 0.05, power 80%. The rule of thumb n ≈ 16 × p(1 − p) / δ² gives 16 × 0.0475 / 0.00000025 ≈ 3.0 million users per arm. To shrink that, use CUPED, which reduces variance with pre-experiment data (Deng, Xu, Kohavi and Walker, WSDM 2013).
Weak answer: "run it for two weeks" with no reasoning.
Follow-up: "You only have a quarter of that traffic. What are your options?"
Production, monitoring and reliability questions#
D. Sculley and colleagues' 2015 paper "Hidden Technical Debt in Machine Learning Systems" (NIPS, now NeurIPS) and Chip Huyen's "Designing Machine Learning Systems" (O'Reilly, 2022), whose eighth chapter covers distribution shift and monitoring, are useful reading here.
23. A feature's null rate jumps from 2% to 30% overnight. What breaks and how do you guard it?#
Why it is asked: upstream data changes break models without raising a single error.
Strong answer: the model keeps serving, but it learned nulls as a rare case, so gradient-boosted trees send most traffic down the default-missing branch, or an imputed mean becomes the common value, and the score distribution shifts. Guard it with per-feature null-rate and range checks using a tool such as TensorFlow Data Validation or Great Expectations, an alert on the share of requests using default values, and a fallback to the last good snapshot of that feature.
Weak answer: "the model handles missing values, so nothing breaks".
Follow-up: "The upstream team says the change is intended. What now?"
24. What would you monitor for a model in production?#
Why it is asked: labels often arrive weeks late, so you need signals that move before accuracy can be measured.
Strong answer: four layers: service health (p99 latency, errors), data quality (missing values, schema changes, feature freshness), prediction distribution (score drift, share of default scores) and outcome metrics once labels arrive. Retrain on a schedule or drift trigger, behind a gate against the live model.
Weak answer: "accuracy", which may not be known for weeks.
Follow-up: "A retrained model passes every gate but performs worse live. Why?"
How to practise these questions out loud#
Pick three questions per group, answer each aloud in four minutes, then check you named a label, a metric and a number. Write the coding answers in a plain editor without autocomplete, and run the sigmoid on z values of ±1,000 to prove it holds.
The ML engineer interview prep plan turns this into a daily schedule, and things to know before applying for an ML engineer job covers the role itself, including certifications. When you are ready, practise a timed 30, 45 or 60 minute mock interview with ML fundamentals, live Python coding and system design, and get a scorecard that quotes what you said.
Frequently asked questions#
What are the most common machine learning engineer interview questions?#
The most common questions cover leakage and validation splits, metric choice for imbalanced or ranking problems, calibration, designing a recommender or ranking system, and a deep dive on a model you shipped. Most loops add practical Python coding and at least one question on monitoring or A/B testing, and depth rounds increasingly add neural training questions.
How should I answer an ML system design question?#
Start by clarifying the product goal, then define the label and offline and online metrics before choosing any model. Sketch the data and features, then candidate generation, ranking, serving and latency, and finish with monitoring and an A/B launch plan. Interviewers score the order and the trade-offs you name more than the specific architecture you pick.
Do ML engineer interviews include LeetCode-style coding?#
Many large companies still include one or two algorithm-style coding rounds, commonly around medium difficulty. Others prefer practical tasks such as computing ranking metrics from messy logs, writing a leak-free time split or implementing logistic regression in NumPy. Prepare for both: data structures fluency in Python, plus careful handling of duplicates, missing values, numerical overflow and boundary cases.
How many ML engineer interview questions should I prepare?#
Prepare two or three per group, about 15 in total, plus one shipped-project story with real numbers and one about something that went wrong. Depth beats breadth: be ready for two follow-ups on each, and work the sample-size and sample ratio mismatch arithmetic on paper until it takes under two minutes.
How much do machine learning engineers earn?#
The closest US government figure is a median of $140,300 a year (May 2025) for computer and information research scientists, with 22% projected growth from 2025 to 2035, according to the US Bureau of Labor Statistics' Occupational Outlook Handbook (May 2025 data). BLS has no separate machine learning engineer category, and its wage figures exclude equity, which is a large part of pay at big tech companies.