HireHireInterview Quizzes › Machine Learning Engineer

Machine Learning Engineer Interview Questions

Think you're ready? These are the questions that actually decide Machine Learning Engineer interviews. Warm up on Easy — then face the Hard round, where 95% of candidates crumble. 30 questions across 3 levels, instant score, completely free.

30Questions
3Difficulty levels
95%Fail the hard round
FreeInstant score
Easy
Warm-up · 10 Qs
Medium
Practical · 10 Qs
Hard
Brutal · 10 Qs
⚡ Take the Machine Learning Engineer quiz — get your score →

The Machine Learning Engineer interview questions

Below are the real questions, grouped by difficulty. Expand any one to reveal the correct answer and why — or take the timed quiz for a score you can share. Can you clear the Hard round?

Easy round 10 questions

In a classification problem with 95% of samples in the negative class, why is accuracy a poor evaluation metric?
  • A. It cannot be computed when classes are imbalanced
  • B. A model predicting the majority class always can score ~95% while missing all positives ✓
  • C. It always overweights the minority class
  • D. It requires probability outputs rather than labels
Correct answer: B. With severe imbalance, a trivial majority-class predictor achieves high accuracy while failing entirely on the rare class, so accuracy hides poor minority-class performance.
What does L2 (ridge) regularization do to a linear model's weights compared to no regularization?
  • A. Forces many weights to become exactly zero
  • B. Shrinks weights toward zero to reduce overfitting ✓
  • C. Increases weight magnitudes to fit training data better
  • D. Has no effect on weights, only on the bias term
Correct answer: B. L2 regularization penalizes the squared magnitude of weights, shrinking them toward zero to reduce variance and overfitting without forcing them to exactly zero.
During training, your model achieves 99% training accuracy but only 70% validation accuracy. This is a sign of:
  • A. Underfitting
  • B. Overfitting ✓
  • C. Data leakage into validation
  • D. Vanishing gradients
Correct answer: B. A large gap where training performance far exceeds validation performance indicates the model has memorized the training data and fails to generalize, i.e., overfitting.
Why should feature scaling (e.g., standardization) be fit only on the training set and then applied to the test set?
  • A. To make training faster
  • B. To prevent information from the test set leaking into the model ✓
  • C. Because test data has a different number of features
  • D. Scaling is not needed on test data at all
Correct answer: B. Fitting the scaler on training data only prevents test-set statistics from leaking into preprocessing, keeping the evaluation an honest estimate of generalization.
In gradient descent, what is the primary effect of setting the learning rate too high?
  • A. Training converges slowly but reliably
  • B. The loss may oscillate or diverge instead of converging ✓
  • C. The model always underfits
  • D. Gradients become exactly zero
Correct answer: B. An excessively high learning rate causes overshooting of the loss minimum, leading to oscillation or divergence rather than smooth convergence.
What is the main purpose of k-fold cross-validation?
  • A. To increase the size of the training dataset
  • B. To obtain a more reliable estimate of model performance using limited data ✓
  • C. To eliminate the need for a test set entirely
  • D. To speed up model training
Correct answer: B. K-fold cross-validation rotates the validation fold across the data so every sample is used for both training and validation, giving a lower-variance estimate of generalization performance.
Which activation function is most associated with the vanishing gradient problem in deep networks?
  • A. ReLU
  • B. Sigmoid ✓
  • C. Leaky ReLU
  • D. Linear
Correct answer: B. The sigmoid saturates for large-magnitude inputs, producing near-zero derivatives that shrink gradients as they backpropagate through many layers.
In the bias-variance tradeoff, a very deep decision tree grown without pruning typically has:
  • A. High bias and low variance
  • B. Low bias and high variance ✓
  • C. High bias and high variance
  • D. Low bias and low variance
Correct answer: B. An unpruned deep tree fits training data very closely (low bias) but is highly sensitive to the specific training sample (high variance), causing overfitting.
When deploying a real-time fraud-detection model as a REST API, which concern is MOST directly addressed by monitoring for data drift?
  • A. Reducing model file size on disk
  • B. Detecting when incoming feature distributions differ from training data, degrading accuracy ✓
  • C. Encrypting the API traffic
  • D. Lowering the model's training time
Correct answer: B. Data drift monitoring flags when production input distributions diverge from the training distribution, which silently degrades model accuracy over time.
What does the ROC-AUC of a binary classifier represent?
  • A. The fraction of predictions that are correct
  • B. The probability the model ranks a random positive higher than a random negative ✓
  • C. The model's training loss at convergence
  • D. The ratio of true positives to false positives at a fixed threshold
Correct answer: B. ROC-AUC equals the probability that a randomly chosen positive example receives a higher score than a randomly chosen negative example, a threshold-independent ranking measure.

Medium round 10 questions

You train a random forest classifier and get 99% accuracy on the training set but 72% on the validation set. What is the most likely problem and appropriate fix?
  • A. Underfitting; increase model complexity by adding more trees
  • B. Overfitting; reduce complexity via max_depth or min_samples_leaf constraints ✓
  • C. Data leakage; the validation set is contaminated with training rows
  • D. The learning rate is too high; lower it to stabilize training
Correct answer: B. A large train-validation gap with high train accuracy is the classic signature of overfitting, addressed by regularizing tree depth/leaf size.
You have a binary classification dataset where 98% of samples are the negative class. Which single metric is the LEAST informative for evaluating your model's performance here?
  • A. Precision
  • B. Recall
  • C. Plain accuracy ✓
  • D. F1 score
Correct answer: C. With severe class imbalance, plain accuracy is misleading because predicting the majority class alone yields ~98%, so precision/recall/F1 are far more informative.
In scikit-learn, you scale features with StandardScaler before training. What is the correct way to apply scaling to avoid data leakage?
  • A. Fit the scaler on the entire dataset, then split into train and test
  • B. Fit the scaler on the training set only, then transform both train and test ✓
  • C. Fit and transform the train and test sets independently
  • D. Fit the scaler on the test set to reflect production distribution
Correct answer: B. The scaler must learn parameters (mean/std) only from training data and then apply that same transform to test data, preventing test information from leaking into training.
Your gradient descent training loss oscillates wildly and sometimes diverges to NaN. Which change is the most direct first fix?
  • A. Increase the batch size to the full dataset
  • B. Add more layers to the network
  • C. Reduce the learning rate ✓
  • D. Switch the loss function from cross-entropy to MSE
Correct answer: C. Loss oscillation and divergence to NaN are the hallmark of a learning rate that is too high, so lowering it is the most direct remedy.
You want to choose hyperparameters and get an unbiased estimate of final model performance. Which setup is correct?
  • A. Tune on the test set, then report test accuracy
  • B. Use a separate validation set for tuning and a held-out test set only for the final report ✓
  • C. Use cross-validation for tuning and report the best cross-validation fold score as final performance
  • D. Tune on training accuracy and report test accuracy
Correct answer: B. Hyperparameters should be selected on a validation set (or CV), and the test set must remain untouched until the single final evaluation to keep the estimate unbiased.
In a pandas DataFrame, a numeric column has ~5% missing values that appear missing at random. Which is generally the most reasonable default handling for a downstream linear model?
  • A. Drop every row that has any missing value in any column
  • B. Impute the missing values with the column mean or median ✓
  • C. Replace missing values with 0 regardless of the column's distribution
  • D. Impute with a random number from a uniform distribution
Correct answer: B. For a small fraction of MAR numeric data, mean/median imputation is the standard, low-risk default that preserves rows without introducing arbitrary values.
You deploy a model that performed well offline, but after a few months its live accuracy steadily declines even though the code is unchanged. What is the most likely cause?
  • A. The model weights are gradually corrupting in memory
  • B. Data drift: the production input distribution has shifted from the training distribution ✓
  • C. The random seed changed between runs
  • D. Overfitting is increasing over time in production
Correct answer: B. Gradual performance decay on a static model in production is the classic symptom of data (or concept) drift, where the live distribution diverges from training.
When encoding a high-cardinality categorical feature (e.g., 10,000 unique zip codes) for a gradient-boosted tree model, which approach is usually the most practical?
  • A. One-hot encode into 10,000 binary columns
  • B. Use target/mean encoding or a learned embedding to keep dimensionality manageable ✓
  • C. Assign each category a random float and treat it as continuous
  • D. Drop the feature because trees cannot use categoricals at all
Correct answer: B. One-hot encoding a 10k-category feature explodes dimensionality, so target/mean encoding (or embeddings) is the practical way to retain signal compactly.
You use L2 regularization in a logistic regression. As you increase the regularization strength (decrease C in scikit-learn), what generally happens?
  • A. Model variance increases and it fits training noise more closely
  • B. Coefficients shrink toward zero, reducing variance at the cost of some bias ✓
  • C. Coefficients are forced to exactly zero, producing feature selection
  • D. Training accuracy always increases monotonically
Correct answer: B. Stronger L2 penalizes large weights, shrinking coefficients toward (but not exactly to) zero, which lowers variance while adding bias.
You are batching text sequences of varying length to feed an RNN/Transformer. What is the standard technique to form a rectangular batch tensor?
  • A. Truncate all sequences to length 1
  • B. Pad shorter sequences to a common length and use a mask to ignore padding ✓
  • C. Concatenate all sequences into one long sequence
  • D. Duplicate short sequences until they match the longest
Correct answer: B. Padding to a uniform length with an attention/loss mask is the standard way to batch variable-length sequences without letting padding affect computation.

Hard round 10 questions

You serve a 7B-parameter LLM (fp16 weights) with a fixed 24 GB GPU. Requests with ~500-token prompts work, but a batch with several 6,000-token prompts triggers CUDA OOM even though weights (~14 GB) plus KV cache seem to fit. What is the most accurate explanation of why long prompts specifically cause the failure?
  • A. fp16 weights silently upcast to fp32 during long-sequence prefill, doubling the 14 GB weight footprint
  • B. The self-attention score matrix and KV cache grow with sequence length (attention scores scale ~O(L^2) per layer during prefill), so long prompts inflate activation/cache memory far beyond the short-prompt case ✓
  • C. Longer prompts increase the parameter count of the model proportionally to the number of input tokens
  • D. The optimizer state for Adam is allocated at inference time and scales with prompt length
Correct answer: B. Prefill attention materializes score matrices that scale quadratically with sequence length and the KV cache grows linearly per token, so long prompts blow up transient activation/cache memory rather than the fixed weight size.
A ranking model shows offline NDCG@10 improving by 4% in the new candidate model, but the online A/B test shows flat or slightly negative engagement. Logs confirm no serving bug and identical feature values offline and online. Which is the MOST likely root cause of this offline-online divergence?
  • A. The offline evaluation was computed on logged data collected under the old model's policy, so it rewards agreement with past exposure rather than true improvement (presentation/feedback-loop bias) ✓
  • B. NDCG@10 is mathematically incapable of correlating with engagement metrics
  • C. The online model is using fp16 while offline used fp32, changing the ranking order
  • D. The A/B test lacked statistical power, which always fully explains a negative delta
Correct answer: A. Offline metrics computed on logs generated by the incumbent policy suffer exposure/selection bias, so higher offline NDCG can reflect fitting the old policy's choices rather than real online gains.
You must add drift detection to a fraud model with 40 features, several of which are strongly correlated (e.g., transaction_amount, rolling_avg_amount, amount_zscore). Running a per-feature KS test on each marginal shows no significant drift, yet the joint behavior has shifted. Which approach correctly catches this?
  • A. Apply a Bonferroni correction to the per-feature KS p-values, which will reveal the joint shift
  • B. Use a multivariate method such as Maximum Mean Discrepancy or a domain classifier on the joint feature vector, since shifts in the correlation structure can occur while every marginal looks stable ✓
  • C. Increase the KS test sample size until each per-feature test becomes significant
  • D. Switch each per-feature KS test to a chi-square test on binned marginals
Correct answer: B. A change in the joint/correlation structure can leave all marginals unchanged, so multivariate detectors (MMD, classifier two-sample tests) on the full vector are required to catch it.
A teammate proudly reports 0.997 validation AUC on a loan-default model, far above the ~0.82 the business expected. The pipeline: load table, StandardScaler.fit_transform on the FULL dataset, then train_test_split, then fit model. Beyond the scaler issue, which additional check most directly exposes classic target leakage here?
  • A. Verify the model uses L2 rather than L1 regularization, since L1 causes leakage
  • B. Inspect feature importances/SHAP for a feature that is a proxy or downstream artifact of the label (e.g., 'days_past_due' or 'recovery_amount' populated only after default is known) ✓
  • C. Confirm the random seed is fixed so the split is reproducible
  • D. Re-run with a larger validation set to see if AUC drops
Correct answer: B. Near-perfect AUC usually signals a feature that encodes the outcome; a feature populated only after the label is determined is textbook target leakage, and SHAP/importances that spotlight one such feature reveal it (the fit_transform-before-split is a separate, milder train/test contamination).
For a 70B model you want to reduce KV-cache memory and boost decode throughput without retraining a new attention scheme from scratch. The model uses standard multi-head attention with 64 query heads. Which change most directly targets KV-cache size while preserving most quality?
  • A. Grouped-Query Attention: keep 64 query heads but share a smaller number of key/value heads (e.g., 8), shrinking the KV cache proportionally to the number of KV heads ✓
  • B. Increase the number of attention heads to 128 so each head's KV projection is smaller
  • C. Replace sinusoidal positional encodings with RoPE, which removes the need for a KV cache
  • D. Switch from pre-norm to post-norm, which halves KV memory at inference
Correct answer: A. GQA reduces the number of distinct K/V projections that must be cached (cache scales with KV-head count), cutting KV memory and bandwidth while retaining full query-head expressiveness and most quality.
A RAG assistant over policy PDFs returns confident but wrong answers on questions whose ground truth is not in the corpus, and it also occasionally leaks instructions when a document contains 'ignore previous instructions'. Which pair of mitigations targets these two failure modes respectively?
  • A. Increase the LLM temperature to reduce hallucination; and enable KV caching to block prompt injection
  • B. Add a retrieval-confidence/grounding gate that abstains or says 'not found' when top-k similarity is low; and treat retrieved document text as untrusted data (delimit it, and do not execute instructions found inside it) to blunt prompt injection ✓
  • C. Fine-tune on more Q&A pairs to eliminate hallucination; and lower top-k to 1 to prevent injection
  • D. Use a larger embedding dimension to eliminate hallucination; and raise the similarity threshold to prevent injection while ignoring the injected text problem
Correct answer: B. Hallucination on out-of-corpus questions is mitigated by grounding/abstention gates on retrieval confidence, while prompt injection is mitigated by treating retrieved content as untrusted data that the model must not obey as instructions.
You deploy a risky new pricing model. You want to catch regressions before they hit real users, then ramp safely with automatic rollback. Which sequence and trigger design is soundest?
  • A. Shadow mode (score live traffic, serve old model, compare) → canary to 1-5% real traffic with a guardrail metric and automatic rollback if the metric breaches a pre-set threshold with statistical significance → gradual ramp ✓
  • B. Immediately route 50% of traffic to the new model and roll back only if revenue drops for a full week
  • C. Canary at 100% traffic first, then shadow mode afterward to confirm
  • D. Blue-green swap all traffic at once, relying on users to file support tickets as the failure trigger
Correct answer: A. Shadow mode validates on live inputs with zero user risk, then a small canary with a pre-defined, significance-gated guardrail and automatic rollback limits blast radius before a gradual ramp.
A model retrained daily on the last 24h of clickstream keeps swinging in quality: some days great, some days poor, tracking short-lived promotions and outages. A model retrained monthly drifts too slowly during real seasonal shifts. Which strategy best addresses this retraining-cadence dilemma?
  • A. Always retrain as frequently as possible; more retraining strictly improves freshness
  • B. Use a longer, weighted training window (recency-weighted over weeks) plus retraining triggered by monitored drift/performance thresholds rather than a fixed daily clock, and validate each candidate before promotion ✓
  • C. Freeze the model permanently once it beats baseline to avoid any noise
  • D. Retrain daily but only on data from the single best-performing prior day
Correct answer: B. Daily windows overfit transient noise while monthly ones lag real shifts; a recency-weighted longer window with drift/performance-triggered retraining and validation gates balances stability against adaptation.
A binary classifier for a rare disease (0.5% positive rate) reports 99.4% accuracy and 0.97 ROC-AUC, but clinicians say it misses too many cases. Which evaluation change most honestly reflects performance on the minority class under this extreme imbalance?
  • A. Report accuracy at a 0.5 threshold, which is already the fairest summary
  • B. Report PR-AUC (precision-recall) and inspect precision/recall at operating thresholds, since ROC-AUC can look optimistic when negatives vastly outnumber positives ✓
  • C. Switch to R-squared to capture minority-class quality
  • D. Oversample positives in the test set until it is 50/50, then report accuracy on that balanced test set
Correct answer: B. Under severe imbalance ROC-AUC is inflated by the huge true-negative pool; PR-AUC and threshold-specific precision/recall better expose minority-class performance, and rebalancing the test set would distort the real operating conditions.
You are choosing between full fine-tuning, LoRA/PEFT, and pure in-context learning for adapting a 13B model to a specialized legal-summarization task where you have ~3,000 labeled examples, one 24 GB GPU, and a need to serve several different client-specific variants cheaply. Which choice is best justified?
  • A. Full fine-tuning per client, because it always generalizes best and storage of full weight copies is negligible
  • B. LoRA/PEFT, because low-rank adapters train within the memory budget, and small per-client adapter weights can be swapped over a shared frozen base to serve many variants cheaply ✓
  • C. In-context learning only, because 3,000 examples fit in the context window and no training is ever needed
  • D. Full fine-tuning once on all clients merged, since client-specific behavior is unnecessary
Correct answer: B. LoRA fits the memory budget, leverages the labeled data better than few-shot prompting, and its tiny swappable adapters over a shared base make multi-variant serving far cheaper than storing full fine-tuned copies per client.

Prep for another role

Questions are original, written and independently verified for HireHire's role interview quizzes. They reflect the kind of knowledge Machine Learning Engineer interviews test, not any specific company's questions. HireHire maps live tech & IT jobs across India, updated regularly. Last updated: July 2026.