Machine Learning Engineer interview questions
100 real questions with model answers and explanations for Senior candidates.
See a Machine Learning Engineer resume example →Practice with flashcards
Spaced repetition · Hunter Pass
Questions
I would start with LightGBM because this is medium-width tabular data and the latency budget rewards a strong, cheap baseline.
- Use a time-based split, native missing-value handling, and categorical encodings fitted only on training folds; report PR-AUC and recall at the retention-team capacity.
- A 1,000-tree model can often score in 1 to 3 ms on CPU, leaving room for feature lookup inside the 10 ms budget.
- I would test a neural model only if error analysis shows learnable high-order interactions or embeddings improve PR-AUC by enough to justify higher latency and tuning cost.
Why interviewers ask this: The interviewer is checking whether the candidate matches model class to data shape, evaluation target, and a concrete serving constraint.
I would use two stages: retrieve a few hundred candidates cheaply, then rerank them with richer user and item context.
- Precompute item embeddings and use an ANN index such as ScaNN or FAISS to retrieve about 500 candidates in 20 ms.
- A compact ranking model scores those 500 in under 45 ms, with 20 ms for features and 35 ms reserved for network and tail variance.
- Evaluate retrieval recall@500, ranking NDCG@20, catalog coverage, and online click or conversion lift because a better reranker cannot recover missing candidates.
Why interviewers ask this: A strong answer decomposes recommendation quality and latency into measurable retrieval and ranking stages.
I would start with a MobileNetV3 or EfficientNet-Lite variant and optimize it on the target phone rather than shrink a server model blindly.
- Train at the smallest resolution that preserves the required classes, then export only operators supported by Core ML or TensorFlow Lite.
- Apply INT8 quantization with a representative calibration set and measure model size, top-1 accuracy, p95 latency, memory, and battery use on low-end devices.
- If INT8 loses more than 1 point, use quantization-aware training or distill from the larger teacher before increasing the architecture size.
Why interviewers ask this: The interviewer is evaluating whether architecture and compression are chosen against real device, quality, and size limits.
I would benchmark a TF-IDF linear model and a small distilled transformer before choosing full BERT.
- A linear baseline gives transparent per-label errors and can process well above 1 million tickets per day within 15 ms on CPU.
- DistilBERT or MiniLM is justified only if macro-F1 on rare intent labels improves materially, for example from 0.71 to at least 0.76.
- Full BERT is a poor default if it needs GPU serving for a gain the business cannot use; I would compare cost per million tickets as well as F1.
Why interviewers ask this: A strong answer resists defaulting to a transformer and defines the quality gain required to pay for it.
I would use a global model because shared seasonal and product signals give sparse series more statistical strength.
- Backtest with rolling origins over the latest 12 weeks and report weighted quantile loss by volume and cold-start cohort.
- Product ID embeddings, price, promotion, calendar, and stock status let one LightGBM, DeepAR, or Temporal Fusion Transformer share patterns across series.
- I would retain simple seasonal-naive forecasts as a fallback and reject the global model if it cannot beat them on low-history products and aggregate inventory cost.
Why interviewers ask this: The interviewer is checking whether sparse-series scale and business-weighted backtesting drive the global versus local choice.
I would let the fast model answer confident cases and send only uncertain examples to the slow model.
- Calibrate the fast model and choose two confidence thresholds on validation data so about 20% of traffic escalates.
- The expected model time is 2 ms plus 0.20 times 45 ms, or 11 ms, before routing overhead.
- Evaluate end-to-end accuracy, escalation by cohort, p99 latency, and cost; distillation may be simpler if the slow path creates unstable tails.
Why interviewers ask this: A strong answer turns a cascade into an explicit quality, route-rate, and latency calculation.
I would ship the ensemble only if the extra 4 recall points cover its cost and the models make genuinely different errors.
- Measure pairwise error correlation and recall at the same false-positive review capacity, not three headline AUC values.
- Benchmark parallel and sequential execution against the p99 budget and calculate dollars per additional prevented fraud case.
- If the ensemble is valuable but too expensive, distill its soft outputs into one student and require recall within 1 point of 82%.
Why interviewers ask this: The interviewer is evaluating whether ensemble diversity and marginal business value justify system cost.
I would test a shared encoder with task-specific heads because the small tasks may benefit from the 10-million-label task.
- Sample tasks explicitly so the largest dataset does not dominate every update, and tune loss weights from gradient scale and validation behavior.
- Compare each task with its single-task baseline, especially for negative transfer on labels whose semantics conflict.
- I would keep separate models if two tasks lose more than their agreed 1-point F1 guardrail or require incompatible serving cadences.
Why interviewers ask this: A strong answer treats multi-task learning as measurable transfer with sampling and negative-transfer risks.
I would use supervised learning only where failure labels cover the modes we need to catch, and anomaly detection for novel or unlabeled deviations.
- Build a time-based test set with all confirmed failures and representative normal operation, then report recall at a fixed daily alert budget rather than accuracy.
- Gradient-boosted trees can learn known failure modes with cost-sensitive loss, while an autoencoder or isolation forest proposes unfamiliar cases for review.
- A hybrid route sends high supervised risk or high anomaly score to inspection, but thresholds must be calibrated to the team's capacity, such as 200 alerts per day.
Why interviewers ask this: The interviewer is checking whether label coverage and review capacity determine the modeling strategy for rare failures.
I would rank by incremental treatment effect because high purchase probability does not mean the discount caused the purchase.
- Randomize an eligible holdout and train an uplift model on treatment, outcome, and pre-treatment features with no post-offer leakage.
- Evaluate uplift or Qini curves and incremental profit in the top 5%, including discount cost, rather than ROC-AUC.
- If overlap is weak or the experiment is too small, use the randomized policy directly instead of presenting an unstable observational estimate as causal.
Why interviewers ask this: A strong answer distinguishes prediction from intervention and connects evaluation to incremental profit.
The effective batch is 4,096 examples, so I would validate optimization at that batch before accepting the throughput gain.
- The calculation is 32 GPUs times 64 examples times 2 accumulated microbatches per optimizer step.
- DDP averages gradients across ranks, while loss normalization, clipping, and the learning-rate schedule must advance per optimizer step, not per microbatch.
- I would test linear learning-rate scaling with warm-up, then compare time to target validation score because 32x hardware rarely gives 32x useful convergence.
Why interviewers ask this: The interviewer is testing concrete batch arithmetic and its effect on optimization semantics.
Plain DDP is insufficient because each rank would hold roughly 208 GB of mixed-precision parameters, gradients, and AdamW state before activations.
- DDP replicates that state on every GPU, so activation checkpointing alone cannot fit it into 80 GB.
- PyTorch FSDP FULL_SHARD or ZeRO-3 distributes parameters, gradients, and optimizer state across 64 ranks.
- I would wrap transformer blocks, use BF16, and benchmark all-gather overhead and tokens per GPU-second rather than choosing maximum sharding without measurement.
Why interviewers ask this: A strong answer derives the parallelism choice from model-state memory and names the communication cost it introduces.
I would keep communication-heavy tensor parallelism within each eight-GPU NVLink node and use data or pipeline parallelism across nodes.
- An 8-way tensor-parallel group avoids sending every layer's collectives over the slower inter-node fabric.
- Pipeline stages are added only if one node cannot hold its layer group, with enough microbatches to keep the pipeline bubble below 10%.
- I would compare candidate layouts by peak memory, tokens per second, exposed collective time, and validation parity on the same global batch.
Why interviewers ask this: The interviewer is evaluating whether hardware topology and communication frequency determine the parallelism layout.
I would accumulate eight microbatches because 32 times 8 times 8 equals the required global batch of 2,048.
- Scale each microbatch loss by one eighth before backward or average the accumulated gradients exactly once.
- Gradient clipping, optimizer step, EMA, and learning-rate schedule run after the eighth microbatch, while DDP synchronization is skipped for the first seven.
- I would verify BatchNorm or stochastic-layer behavior because accumulation matches gradient size but not every operation of a physical 2,048-example batch.
Why interviewers ask this: A strong answer gets the accumulation math right and preserves optimizer and synchronization semantics.
I would treat linear scaling as a starting hypothesis and retune warm-up and total optimizer steps against validation quality.
- A 16x batch suggests up to a 16x learning-rate trial for SGD, but Adam often needs a smaller increase and explicit stability sweeps.
- Epoch-based schedules now contain 16x fewer optimizer steps, so warm-up, decay, EMA, and checkpoint intervals must be expressed in updates or tokens.
- Compare time and GPU-hours to the same validation target, because faster epochs are not useful if the large batch loses generalization or needs more data passes.
Why interviewers ask this: The interviewer is checking whether batch scaling accounts for optimizer behavior and the changed number of updates.
I would choose BF16 because its FP32-like exponent range removes most loss-scaling failures while retaining tensor-core throughput.
- Keep optimizer statistics, selected reductions, and numerically sensitive normalization in FP32.
- Compare step time, peak memory, non-finite gradients, and validation loss over at least one full schedule, not a 100-step speed sample.
- FP16 remains reasonable only if dynamic loss scaling removes the 0.4% failures without skipped updates or quality loss.
Why interviewers ask this: A strong answer connects numeric format to observed stability, hardware support, and selective FP32 operations.
I would reduce exposed communication and improve overlap before adding more GPUs.
- Profile gradient bucket readiness and NCCL link throughput to distinguish poor overlap, tiny collectives, topology placement, and a slow rank.
- Test larger microbatches, gradient accumulation, BF16 collectives, and tuned bucket sizes while overlapping reduction with backward.
- Accept a change only if tokens per GPU-second and time to target quality improve, with collective time ideally below 20% of the step.
Why interviewers ask this: The interviewer is evaluating whether all-reduce tuning is driven by timeline evidence and useful scaling efficiency.
I would reshape and cache the input path so storage sustains at least 50 GB/s with headroom before scaling compute further.
- Pack examples into immutable sequential shards of 1 to 4 GB instead of millions of small files, with enough shards for independent rank sampling.
- Prefetch shards to node-local NVMe and use parallel decoding, pinned memory, and asynchronous host-to-device copies.
- Measure remote throughput, cache hit rate, decode time, and dataloader wait, requiring wait below 10% of step time on the final dataset.
Why interviewers ask this: A strong answer matches file layout, cache, and preprocessing capacity to a numeric GPU input requirement.
I would write a sharded checkpoint asynchronously and publish it only after every required shard is durable.
- Save model, optimizer, scheduler, scaler, RNG, sampler position, and completed global step with checksums under one generation.
- Each rank stages to local NVMe and uploads multipart objects to S3 while training continues from an immutable state snapshot.
- A manifest becomes visible only after all shards finish, and restore is tested on the supported world sizes with subsequent loss and sample order checked.
Why interviewers ask this: The interviewer is checking whether distributed checkpointing covers full state, atomic publication, pause budget, and tested restore.
I would use an early-stopping search with a hard GPU-hour budget rather than fully train a fixed number of trials.
- Start with 40 to 80 random or Bayesian trials over conditional ranges and evaluate them at comparable token or step milestones.
- Ray Tune ASHA stops weak trials and promotes the best, while concurrency stays below the storage and dataloader saturation point.
- Reserve about 20% of the budget for repeated seeds and final retraining, then select once on an untouched test set.
Why interviewers ask this: A strong answer converts finite compute into reliable model selection rather than maximizing trial count.
Locked questions
- 21
A recommender trains on 2 billion interactions and 50 million items. How would you sample negatives without biasing evaluation?
- 22
A recommender has a 200 GB embedding table and 8 GPUs with 80 GB each. How would you place and update it?
nlp - 23
An FP32 vision model is 380 MB, runs in 42 ms, and scores 87.6% top-1. The target is under 120 MB and 25 ms with at most 0.5-point loss. What do you try first?
- 24
INT8 post-training quantization cuts latency from 28 ms to 16 ms but drops F1 from 0.91 to 0.86 on rare classes. What next?
latencymodel-compression - 25
A 1.2 billion-parameter teacher reaches 89% accuracy, but serving requires a model below 150 million parameters and 20 ms. How would you distill it?
model-serving - 26
Unstructured pruning removes 70% of weights, but latency changes from 24 ms to 23 ms. Why, and what would you do instead?
latencymodel-compression - 27
The same PyTorch model must serve on x86 CPU, NVIDIA GPU, and occasionally ARM. Would you standardize on ONNX Runtime or TensorRT?
serving-runtimeshardwarepytorch - 28
A transformer has 24 layers, but latency must fall 35% with no more than 1 F1 point lost. Would you remove layers or reduce hidden width?
nlplatency - 29
Torch compilation improves fixed-shape throughput 30%, but inputs range from 32 to 2,048 tokens. How would you retain the gain?
tokensthroughput - 30
You need a 4x smaller model and 2x lower latency while losing under 1 accuracy point. How would you combine compression methods?
latency - 31
An edge speech model must use under 40 MB RAM, process a 20 ms audio frame in real time, and work offline. How would you optimize it?
optimizationconcurrency - 32
Design synchronous inference for 50,000 RPS with a 60 ms p99 target when feature lookup takes 12 ms and model execution takes 18 ms p99.
designinferencelatency - 33
A GPU model must sustain 8,000 predictions per second below 40 ms p99. How would you tune dynamic batching?
latencyhardwarebatch - 34
An embedding endpoint receives 100,000 RPS, and 65% of normalized texts repeat within one hour. How would you cache it?
nlpendpointsnormalization - 35
A search system has 80 ms p99 to retrieve and rerank results from 200 million documents. How would you divide the budget?
system-designlatency - 36
A classifier runs at 7 ms on a $0.20/hour CPU replica and 2 ms on a $1.80/hour GPU replica. Traffic is 300 RPS. Which do you choose?
replicationhardware - 37
A conversational model can reuse 2 GB of session state per active user and must support 1,000 concurrent sessions. Would you keep it stateful?
sessionsconcurrency - 38
You serve 200 small models, each 500 MB, on 8 GPUs with 40 GB memory. How would you manage model residency?
memory - 39
Ten million users need daily risk scores, but 2% require request-time context under 100 ms. Would you use one serving mode?
model-serving - 40
You need 30-day rolling purchase features for 500 million users over 20 billion events. How would you compute them?
- 41
A categorical feature has 30 million values, and most appear fewer than five times. How would you encode it?
- 42
A ranking model needs click counts over 5 minutes, 1 hour, and 7 days at 60,000 RPS. How would you build the features?
- 43
You must re-embed 200 million documents with a new 768-dimensional model while search remains live. How would you version the change?
- 44
A fraud feature uses chargebacks that arrive 45 days after the transaction. How would you prevent target leakage?
feature-engineeringtransactionsleakage - 45
Fraud prevalence is 0.1%, reviewers can inspect 2,000 cases per day, and missing fraud costs ten times a false alert. What metrics and threshold do you use?
monitoringalertingthresholding - 46
A new recommender improves offline NDCG@20 by 4% but reduces catalog coverage from 38% to 21%. How would you evaluate it?
decision-makingcoverage - 47
You predict next-week demand from two years of data with strong yearly seasonality. How would you split train, validation, and test data?
validationtest-data - 48
Two classifiers have the same AUROC of 0.91, but one has Brier score 0.08 and the other 0.16. Which do you choose for pricing risk?
pricing - 49
An A/B test targets a 2% conversion lift from a 10% baseline. How would you design the model experiment?
ab-testingexperimentsdesign - 50
Model A has F1 0.84, 8 ms latency, and $3 per million predictions; Model B has F1 0.87, 42 ms, and $24 per million. The SLO is 30 ms. What do you ship?
slolatency - 51
A fraud model's recall at 2,000 daily reviews falls from 78% to 61% over three weeks. Serving metrics are healthy. What do you do?
model-servingmonitoring - 52
A vision model stays at 89% accuracy overall, but accuracy on Android 14 falls from 87% to 63% after an app release. How do you respond?
- 53
The positive prediction rate of a classifier jumps from 14% to 58% in two hours, but labels arrive after 30 days. How do you respond?
- 54
A parity job finds 3.8% train-serving feature mismatches after a preprocessing release; the limit is 0.1%. How do you debug it?
model-serving - 55
A label pipeline changes the definition of churn from 30 to 60 inactive days, and a retrained model gains 5 AUC points. Would you promote it?
evaluationci-cdchurn - 56
A credit model keeps AUROC at 0.90, but expected calibration error rises from 0.025 to 0.11. What action do you take?
calibration - 57
Feature PSI reaches 0.32, but seven-day labeled F1 remains within 0.3 points of baseline. Do you retrain?
retraining - 58
A fraud threshold sends 3,400 cases to a team that can review only 2,000 daily. Model ranking quality is unchanged. What do you change?
thresholding - 59
Transformer training loss becomes NaN at step 18,700 after scaling from 8 to 64 GPUs. How do you narrow it down?
nlpscaling - 60
Loss falls normally for 40,000 steps, then explodes 12x immediately after a learning-rate scheduler transition. What do you inspect?
- 61
An FP16 run skips 0.8% of optimizer steps because of overflow, while BF16 is 3% slower. Which path do you take?
optimizationprecision - 62
In a 32-GPU DDP run, rank 17 reports gradient norms 4x higher than every other rank before validation degrades. What do you check?
validationhardware - 63
A training job starts OOMing when p95 sequence length rises from 900 to 3,600 tokens. What do you change first?
tokens - 64
A 7B model fits during forward and backward but OOMs on the first AdamW step. Why, and how do you fix it?
- 65
GPU memory grows by 300 MB after every validation pass and the run OOMs after six epochs. How do you debug it?
memoryhardwarevalidation - 66
A 64-GPU run hangs at step 9,240 with no exception and all GPUs allocated. What is your debugging sequence?
hardwareerror-handling - 67
After switching to 64 data-loader workers, one epoch contains 0.6% duplicate examples and misses 0.6%. How do you fix it?
- 68
After restoring a checkpoint, loss jumps from 1.8 to 4.9 and never recovers. What state might be missing?
- 69
A replay of last quarter's experiment changes accuracy from 92.1% to 90.4%. How do you find the missing source of reproducibility?
experiments - 70
Hyperparameter search reports a 3-point validation gain, but the selected model loses 2 points on the untouched test set. What do you conclude?
hyperparametersvalidation - 71
At 12,000 RPS, inference p99 rises from 75 ms to 280 ms after a release while errors remain below 0.1%. What do you do?
inferencelatency - 72
Median inference stays 24 ms, but p99 grows from 90 ms to 410 ms for 1.5% of requests. What do you inspect?
inferencelatency - 73
Dynamic batching lifts throughput 35% but pushes p99 from 44 ms to 96 ms against a 70 ms SLO. Keep it?
batchslothroughput - 74
After an embedding-model release, cache hit rate remains 72% but search relevance falls 8%. What do you check?
nlpcaching - 75
A GPU endpoint fails over to CPU and output probabilities differ by up to 0.07, changing 6% of decisions. Is that acceptable?
hardwareendpoints - 76
A 14 GB model takes 95 seconds to load, causing 5% timeouts during a predictable peak. What can you change this week?
resilience - 77
A cascade should send 20% of requests to its large model, but production route rate rises to 47% and cost doubles. What do you inspect?
- 78
ANN recall@100 falls from 94% to 81% after the vector index is rebuilt, while query latency improves 20%. What do you do?
indexesquerieslatency - 79
Feature lookup p99 grows from 9 ms to 85 ms and consumes most of a 110 ms endpoint budget. How do you protect predictions?
latencyendpoints - 80
A slow dependency triggers three client retries and traffic rises from 18,000 to 46,000 RPS in 90 seconds. How do you stop the cascade?
dependencies - 81
An A/B test shows a statistically significant negative 3% revenue lift, although offline F1 improved from 0.81 to 0.85. What do you do?
ab-testingsignificance - 82
A model experiment reports 7% lift, but treatment receives 52.8% of traffic instead of 50%. How do you validate the result?
experimentsvalidation - 83
A recommender raises first-week clicks by 9% but lowers 30-day retention by 2%. Would you promote it?
retention - 84
A marketplace A/B test randomizes users, but sellers influence prices for both variants and conversion lift is unstable. How would you redesign it?
ab-testing - 85
Default labels mature after 90 days, but product wants weekly model releases. What promotion rules would you set?
- 86
A deployed model loses 4 F1 points, while a retrained candidate recovers only 2 and costs 3x more to serve. Retrain, roll back, or keep it?
deploymentrollbackretraining - 87
The training set grows from 10 to 12 million rows each month, but the last three retrains improved AUC by less than 0.001 and cost $4,000 each. Do you retrain again?
train-testevaluationzero-to-one - 88
An upstream service changes distance from kilometers to meters, but clipping keeps model inputs in range. How do you detect and contain it?
- 89
A new model raises monthly GPU cost from $40,000 to $95,000 for only a 0.6-point quality gain. What do you recommend?
hardware - 90
INT8 reduces latency from 35 ms to 18 ms, but recall for one 7% cohort falls from 74% to 59%. Do you ship it?
cohortslatency - 91
A canary passes latency and errors, but its business-quality proxy drops 5% at the 20% traffic stage. What do you do?
proxydeployment-strategieslatency - 92
You need to roll back model 28, but model 27 expects two features removed last week. How do you avoid downtime?
rollback - 93
At 03:00, a pricing model begins returning the maximum price for 68% of requests, but endpoint health is green. You are on call. What do you do?
pricingendpoints - 94
A model made 12,000 incorrect eligibility decisions before rollback. What must the postmortem produce?
incidentsrollback - 95
A mid-level engineer sees NaN loss and proposes lowering the learning rate tenfold immediately. How do you mentor the diagnosis?
optimizationmentoring - 96
A teammate reports 98% validation accuracy after randomly splitting rows from repeated users across train and validation. How do you handle it?
soft-skillsvalidation - 97
In code review, an engineer chooses accuracy for a 0.2% fraud problem and claims 99.8% performance. What feedback do you give?
feedbackcode-reviewperformance - 98
A product lead wants to launch in 48 hours, but the model misses the recall guardrail by 6 points. What do you permit?
guardrails - 99
Two senior engineers disagree between a 0.86-F1 neural model at 38 ms and a 0.84-F1 boosted tree at 6 ms for a 20 ms SLO. How do you resolve it?
conflictslo - 100
Three teams report incompatible metrics for the same model because they use different splits and label maturity. What standard do you introduce?
monitoring