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. 80 questions across 3 levels, instant score, completely free.

80Questions
3Difficulty levels
95%Fail the hard round
FreeInstant score
Easy
Warm-up · 20 Qs
Medium
Practical · 30 Qs
Hard
Brutal · 30 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 20 questions

You train a model and get 99% accuracy on training data but 62% on the test set. What is most likely happening?
  • A. Underfitting
  • B. Overfitting ✓
  • C. Data leakage into test set
  • D. The learning rate is too low
Correct answer: B. High train accuracy with much lower test accuracy is the classic signature of overfitting.
A fraud dataset has 99% legitimate and 1% fraudulent transactions. A model predicts 'legitimate' for everything. What is its accuracy and why is that misleading?
  • A. 1%, because it never catches fraud
  • B. 50%, because there are two classes
  • C. 99%, but it catches zero fraud cases ✓
  • D. 0%, because it ignores the minority class
Correct answer: C. Predicting the majority class gives 99% accuracy while being useless, which is why accuracy misleads on imbalanced data.
You apply StandardScaler by fitting it on the entire dataset before splitting into train/test. What problem does this cause?
  • A. The model trains slower
  • B. Data leakage from test into training statistics ✓
  • C. The features become non-numeric
  • D. Nothing, this is the correct order
Correct answer: B. Fitting the scaler before the split leaks test-set statistics into training, inflating evaluation results.
For a spam-vs-not-spam classifier where missing real spam is acceptable but flagging good email as spam is very costly, which metric should you prioritize?
  • A. Recall on the spam class
  • B. Precision on the spam class ✓
  • C. Training loss
  • D. F1 score on the spam class
Correct answer: B. To avoid false positives (good email marked spam), you maximize precision on the spam class.
You add L2 regularization to a linear model. What effect does increasing the regularization strength typically have?
  • A. Increases model variance
  • B. Shrinks coefficients toward zero, reducing variance ✓
  • C. Guarantees zero training error
  • D. Adds more features automatically
Correct answer: B. Stronger L2 penalizes large weights, shrinking coefficients and lowering variance at the cost of some bias.
During gradient descent your loss oscillates wildly and diverges instead of decreasing. What is the most likely cause?
  • A. Learning rate is too high ✓
  • B. Too many epochs
  • C. Batch size is too small
  • D. The weights were initialized to all zeros
Correct answer: A. A learning rate that is too high causes the updates to overshoot the minimum, making loss diverge.
You have a categorical feature 'city' with 3 unrelated values. Which encoding avoids implying a false numeric order?
  • A. Label encoding as 0, 1, 2
  • B. One-hot encoding ✓
  • C. Replacing with row index
  • D. Standard scaling
Correct answer: B. One-hot encoding creates independent binary columns, avoiding the false ordering label encoding would imply.
A dataset column has 30% missing values that are missing at random. Which approach is generally reasonable before training a linear model?
  • A. Drop every row that has any value
  • B. Impute with the column mean or median ✓
  • C. Set all missing values to zero always
  • D. Duplicate rows to fill gaps
Correct answer: B. Mean/median imputation is a standard, defensible way to handle random missingness without discarding most data.
You use k-fold cross-validation with k=5. What does this give you compared to a single train/test split?
  • A. A faster single training run
  • B. A more stable estimate of performance across 5 folds ✓
  • C. Guaranteed higher accuracy
  • D. Fewer training examples overall
Correct answer: B. K-fold averages performance over multiple splits, giving a more reliable estimate than one split.
In a neural network you use ReLU activations. What happens to the gradient for a neuron whose input is negative?
  • A. The gradient is very large
  • B. The gradient is zero for that neuron ✓
  • C. The gradient becomes negative infinity
  • D. The gradient equals the input
Correct answer: B. ReLU outputs 0 for negative inputs, so its derivative there is 0, which can cause 'dying' neurons.
You want to reduce a 100-feature dataset to 2 dimensions for visualization while preserving variance. Which technique fits?
  • A. PCA ✓
  • B. K-means
  • C. Logistic regression
  • D. Gradient boosting
Correct answer: A. PCA projects data onto directions of maximum variance, ideal for dimensionality reduction and visualization.
A binary classifier outputs probabilities. You raise the decision threshold from 0.5 to 0.8. What generally happens?
  • A. Recall goes up, precision goes down
  • B. Precision goes up, recall goes down ✓
  • C. Both increase equally
  • D. Neither changes
Correct answer: B. A higher threshold flags fewer positives, typically raising precision while lowering recall.
You train a decision tree with no depth limit on a small dataset. What is the most likely outcome?
  • A. It underfits badly
  • B. It overfits by memorizing training points ✓
  • C. It cannot handle numeric features
  • D. It converges to a linear model
Correct answer: B. An unconstrained tree grows until it fits training points exactly, overfitting the data.
Given the confusion matrix TP=40, FP=10, FN=20, TN=30, what is the recall?
  • A. 40/50 = 0.80
  • B. 40/60 = 0.67 ✓
  • C. 40/70 = 0.57
  • D. 40/100 = 0.40
Correct answer: B. Recall = TP/(TP+FN) = 40/(40+20) = 0.67.
You deploy a model trained on 2023 data and its accuracy silently drops over 2024. The input distribution has shifted. This is best described as needing to monitor for what?
  • A. Vanishing gradients
  • B. Data/concept drift ✓
  • C. Overfitting on the test set
  • D. One-hot explosion
Correct answer: B. A shifting input or target distribution over time is data/concept drift, which degrades deployed models.
For a regression problem you care a lot about penalizing large errors more than small ones. Which loss reflects that?
  • A. Mean Absolute Error
  • B. Mean Squared Error ✓
  • C. Accuracy
  • D. Hinge loss
Correct answer: B. MSE squares errors, so large errors are penalized disproportionately more than small ones.
You use gradient boosting and increase the number of trees far beyond what's needed. Without early stopping, what risk grows?
  • A. Underfitting the training data
  • B. Overfitting to training data ✓
  • C. Model bias grows, worsening train and test error together
  • D. Each new tree contributes less until training halts early
Correct answer: B. Adding too many boosting rounds lets the ensemble fit noise, increasing overfitting.
A model performs well offline but you want to compare two versions on live traffic before full rollout. Which approach is standard?
  • A. Retrain on the test set
  • B. A/B test the two models on split traffic ✓
  • C. Increase the learning rate
  • D. Remove the validation set
Correct answer: B. A/B testing on split live traffic is the standard way to compare model versions in production.
You have very few labeled examples but a large model. Instead of training from scratch, what is a practical choice?
  • A. Transfer learning / fine-tuning a pretrained model ✓
  • B. Increase the batch size to millions
  • C. Drop all regularization
  • D. Use accuracy as the loss function
Correct answer: A. Fine-tuning a pretrained model leverages learned features and works well with limited labeled data.
In train/validation/test splits, what is the validation set primarily used for?
  • A. Final unbiased performance reporting
  • B. Tuning hyperparameters and model selection ✓
  • C. Increasing the training data size
  • D. Computing the loss gradient
Correct answer: B. The validation set guides hyperparameter tuning and model selection, keeping the test set for final unbiased evaluation.

Medium round 30 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.
Compared to L2 regularization, what distinctive effect does L1 (Lasso) regularization have?
  • A. It scales all weights by a constant factor
  • B. It drives some weights to exactly zero, producing sparsity ✓
  • C. It always improves test accuracy
  • D. It only penalizes the bias terms
Correct answer: B. L1's absolute-value penalty pushes many coefficients to exactly zero, performing implicit feature selection.
In k-fold cross-validation with k=5, how is the model evaluated?
  • A. Trained once on 80% and tested on the remaining 20%
  • B. Trained and validated 5 times, each fold used once as validation ✓
  • C. Trained on all data and tested on the same data
  • D. Trained 5 times on the full dataset with different seeds
Correct answer: B. k-fold rotates the validation fold so every sample is used for validation exactly once across k runs.
Which activation function most severely causes the vanishing gradient problem in deep networks?
  • A. ReLU
  • B. Sigmoid ✓
  • C. Leaky ReLU
  • D. GELU
Correct answer: B. Sigmoid saturates at both ends with near-zero derivatives, causing gradients to vanish in deep stacks.
For a heavily imbalanced fraud dataset (0.1% fraud), why is plain accuracy misleading?
  • A. Accuracy cannot be computed on imbalanced data
  • B. A model predicting 'no fraud' always scores ~99.9% accuracy while catching zero fraud ✓
  • C. Accuracy penalizes majority-class predictions too harshly
  • D. Accuracy requires balanced classes to be defined
Correct answer: B. With extreme imbalance a trivial majority-class predictor achieves high accuracy despite being useless.
What is the primary purpose of dropout during training?
  • A. To speed up matrix multiplication
  • B. To reduce overfitting by randomly deactivating neurons ✓
  • C. To normalize activations to unit variance
  • D. To increase the learning rate adaptively
Correct answer: B. Dropout randomly zeros units during training, preventing co-adaptation and acting as regularization.
A medical screening test should minimize missed positive cases. Which metric should you prioritize?
  • A. Precision
  • B. Recall ✓
  • C. Specificity
  • D. Log loss
Correct answer: B. Recall (sensitivity) measures the fraction of actual positives caught, key when missing positives is costly.
Which situation is a classic example of data leakage?
  • A. Using k-fold cross-validation
  • B. Scaling features using statistics computed over the entire dataset before the train/test split ✓
  • C. Using a validation set to tune hyperparameters
  • D. Applying dropout during training
Correct answer: B. Fitting the scaler on all data leaks test-set information into training, inflating performance estimates.
An ROC-AUC of 0.5 indicates what about a binary classifier?
  • A. Perfect classification
  • B. Performance no better than random guessing ✓
  • C. The model is overfitting
  • D. The classes are perfectly separable
Correct answer: B. An AUC of 0.5 means the model ranks positives and negatives no better than chance.
How does gradient boosting fundamentally differ from a random forest?
  • A. Boosting trains trees sequentially, each correcting the previous errors; forests train trees independently ✓
  • B. Boosting uses only one tree while forests use many
  • C. Forests always use deeper trees than boosting
  • D. Boosting cannot be used for regression
Correct answer: A. Gradient boosting builds trees sequentially to fit residuals; random forests build independent trees in parallel and average them.
Why is feature scaling important for k-nearest neighbors and SVMs but not for decision trees?
  • A. Trees require scaled inputs to split correctly
  • B. Distance/margin-based methods are sensitive to feature magnitudes, while tree splits are threshold-based ✓
  • C. Scaling changes the class labels
  • D. KNN cannot handle categorical features at all
Correct answer: B. Distance and margin computations are dominated by large-scale features, whereas tree splits depend only on ordering, not magnitude.
L1 (Lasso) regularization is often preferred over L2 because it...
  • A. Always trains faster
  • B. Prevents vanishing gradients
  • C. Drives some feature weights exactly to zero ✓
  • D. Normalizes input features
Correct answer: C. L1's penalty produces sparse solutions by pushing some coefficients to exactly zero.
For a highly imbalanced binary classification problem, which metric is most misleading?
  • A. Accuracy ✓
  • B. Precision
  • C. Recall
  • D. F1-score
Correct answer: A. Accuracy can look high by simply predicting the majority class on imbalanced data.
In 5-fold cross-validation, each data point is used for validation...
  • A. Five times
  • B. Exactly once ✓
  • C. Zero times
  • D. A random number of times
Correct answer: B. Each fold serves as validation once while the other four train the model.
Raising the decision threshold of a probabilistic classifier typically...
  • A. Increases both precision and recall
  • B. Decreases both precision and recall
  • C. Has no measurable effect
  • D. Increases precision and decreases recall ✓
Correct answer: D. A stricter threshold yields fewer but more confident positives, raising precision and lowering recall.
Which algorithm is generally NOT sensitive to feature scaling?
  • A. Decision trees ✓
  • B. K-nearest neighbors
  • C. SVM with an RBF kernel
  • D. Logistic regression trained by gradient descent
Correct answer: A. Tree splits are based on thresholds per feature, so they are invariant to monotonic scaling.
Batch normalization primarily helps training by...
  • A. Adding regularization noise only
  • B. Normalizing layer input distributions to speed and stabilize training ✓
  • C. Reducing the number of parameters
  • D. Replacing activation functions
Correct answer: B. Batch norm normalizes activations, reducing internal covariate shift and allowing higher learning rates.
Dropout reduces overfitting by...
  • A. Removing layers permanently
  • B. Scaling the learning rate over time
  • C. Randomly deactivating neurons during training ✓
  • D. Pruning weights after training completes
Correct answer: C. Dropout randomly zeroes activations each step, preventing co-adaptation of neurons.
An ROC-AUC of 0.5 indicates the classifier...
  • A. Performs no better than random ✓
  • B. Is perfect
  • C. Has fully inverted predictions
  • D. Is overfit
Correct answer: A. AUC of 0.5 corresponds to the diagonal of the ROC curve, i.e., random ranking.
Data leakage most commonly occurs when...
  • A. The dataset is too small
  • B. Features are scaled before splitting
  • C. Classes are perfectly balanced
  • D. Features contain information unavailable at prediction time ✓
Correct answer: D. Leakage happens when training features encode future or target information the model won't have at inference.
The vanishing gradient problem is most associated with...
  • A. Shallow linear models
  • B. Deep networks using saturating activations like sigmoid ✓
  • C. Decision trees
  • D. K-means clustering
Correct answer: B. Saturating activations produce tiny derivatives that shrink gradients across deep layers.

Hard round 30 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.
During inference (test time), how does batch normalization compute the mean and variance it uses to normalize?
  • A. From the current test mini-batch statistics
  • B. From running (moving-average) statistics accumulated during training ✓
  • C. It is disabled entirely at inference
  • D. From the validation set recomputed each step
Correct answer: B. At inference BatchNorm uses the running mean/variance estimated during training, not batch statistics, for deterministic outputs.
What does the Adam optimizer maintain in addition to the standard gradient to adapt learning rates?
  • A. Only a global momentum term
  • B. Exponential moving averages of both the first moment (mean) and second moment (uncentered variance) of gradients ✓
  • C. The full Hessian matrix of second derivatives
  • D. A running average of the loss values
Correct answer: B. Adam tracks bias-corrected first and second moment estimates per parameter to scale each update adaptively.
What is the time and memory complexity of vanilla self-attention with respect to sequence length n?
  • A. O(n log n)
  • B. O(n^2) ✓
  • C. O(n)
  • D. O(n^3)
Correct answer: B. Self-attention computes an n×n score matrix, giving quadratic O(n^2) complexity in sequence length.
A known drawback of using SMOTE to oversample a minority class is that it can:
  • A. Only work on image data
  • B. Generate synthetic points that blur class boundaries and cause overfitting to noisy regions ✓
  • C. Guarantee improved test recall in all cases
  • D. Remove the majority class entirely
Correct answer: B. SMOTE interpolates between minority neighbors and can create ambiguous points near boundaries or amplify noise, harming generalization.
Why is gradient clipping commonly applied when training RNNs/LSTMs?
  • A. To prevent the vanishing gradient problem
  • B. To prevent exploding gradients from destabilizing weight updates ✓
  • C. To enforce weight sparsity
  • D. To increase model capacity
Correct answer: B. RNNs are prone to exploding gradients over long sequences; clipping caps gradient norm to keep updates stable.
In XGBoost, the regularization term in the objective penalizes which quantity to control tree complexity?
  • A. The learning rate only
  • B. The number of leaves and the L2 norm of the leaf output weights ✓
  • C. The depth of the input features
  • D. The batch size used for training
Correct answer: B. XGBoost's regularization adds a term over the number of leaves (gamma) and the squared leaf weights (lambda) to penalize complex trees.
What is the main advantage of Bayesian optimization over grid search for hyperparameter tuning?
  • A. It guarantees finding the global optimum
  • B. It uses a probabilistic surrogate model to choose promising points, needing far fewer expensive evaluations ✓
  • C. It requires no objective function
  • D. It only works for discrete hyperparameters
Correct answer: B. Bayesian optimization builds a surrogate (e.g., Gaussian process) and an acquisition function to sample efficiently, reducing costly trials.
Why is a learning-rate warmup often used at the start of training large transformers?
  • A. To immediately reach the maximum learning rate for speed
  • B. To avoid large, unstable updates while adaptive optimizer moment estimates are still poorly conditioned ✓
  • C. To disable regularization early
  • D. To reduce the model's parameter count
Correct answer: B. Early on, adaptive-optimizer statistics are unreliable; ramping the LR up gradually prevents destabilizing early updates.
In knowledge distillation, what does the student model primarily learn from the teacher?
  • A. Only the hard one-hot labels
  • B. The teacher's softened probability distribution (soft targets) over classes ✓
  • C. The teacher's raw weight matrices copied directly
  • D. The teacher's training data order
Correct answer: B. Distillation trains the student on the teacher's temperature-softened soft labels, transferring inter-class 'dark knowledge'.
Post-training INT8 quantization of a neural network primarily trades off what?
  • A. Larger model size for faster training
  • B. Reduced memory/latency for a small potential loss in numerical precision and accuracy ✓
  • C. Higher accuracy for slower inference
  • D. More parameters for less memory
Correct answer: B. INT8 quantization shrinks and speeds up the model by using lower-precision weights/activations, at the cost of some accuracy.
The Adam optimizer combines which two ideas?
  • A. L1 and L2 regularization
  • B. Dropout and batch normalization
  • C. Momentum and per-parameter adaptive learning rates ✓
  • D. Bagging and boosting
Correct answer: C. Adam uses first-moment (momentum) and second-moment (RMSProp-style) estimates for adaptive step sizes.
A 'dead ReLU' neuron occurs when...
  • A. A neuron's input stays negative so its gradient is always zero ✓
  • B. Its weights grow without bound
  • C. The learning rate is too small
  • D. The batch size is too large
Correct answer: A. If a ReLU always outputs zero, its gradient is zero and the neuron stops learning.
Compared to Random Forest, gradient-boosted trees (e.g., XGBoost)...
  • A. Build trees fully independently in parallel
  • B. Build trees sequentially to correct prior residuals ✓
  • C. Can never overfit
  • D. Require no learning rate
Correct answer: B. Boosting fits each new tree to the residual errors of the current ensemble, sequentially.
In softmax, dividing the logits by a temperature T > 1 produces...
  • A. A sharper, lower-entropy distribution
  • B. Identical outputs
  • C. Negative probabilities
  • D. A softer, higher-entropy distribution ✓
Correct answer: D. Higher temperature flattens the distribution, spreading probability mass more evenly.
At inference time, batch normalization uses...
  • A. Running moving-average statistics from training ✓
  • B. The current batch's mean and variance
  • C. No normalization at all
  • D. Per-layer weight statistics
Correct answer: A. Inference uses the accumulated running mean/variance so outputs don't depend on batch composition.
Standard self-attention has a computational complexity in sequence length n of...
  • A. O(n)
  • B. O(n^2) ✓
  • C. O(n log n)
  • D. O(1)
Correct answer: B. Each token attends to every other token, producing an n-by-n attention matrix.
Gradient clipping is primarily used to mitigate...
  • A. Vanishing gradients
  • B. Overfitting
  • C. Exploding gradients ✓
  • D. Class imbalance
Correct answer: C. Clipping bounds gradient norms to prevent the instability of exploding gradients, common in RNNs.
Transformers typically use Layer Normalization rather than Batch Normalization because...
  • A. It normalizes across features per token, independent of batch size and padding ✓
  • B. It is faster only on GPUs
  • C. It removes the need for residual connections
  • D. It requires very large batches
Correct answer: A. Layer norm operates per-token over features, making it robust to variable sequence lengths and small batches.
In the bias-variance decomposition of expected squared error, the irreducible error term represents...
  • A. The model's bias
  • B. The model's variance
  • C. The regularization strength
  • D. Noise inherent in the data that no model can remove ✓
Correct answer: D. Irreducible error is the intrinsic noise floor independent of the chosen model.
For an extremely imbalanced dataset, using class weights in the loss versus random oversampling differs in that class weighting...
  • A. Duplicates minority samples
  • B. Reweights gradient contributions without duplicating data ✓
  • C. Removes majority samples
  • D. Changes the model architecture
Correct answer: B. Class weights scale each class's loss contribution rather than physically resampling the data.

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: August 2026.