Machine Learning Engineer Interview Questions and Answers
Machine learning engineer interview questions with answers: ML fundamentals, model evaluation, deep learning, transformers and LLMs, feature pipelines, deployment, monitoring and ML system design.
Key takeaways
- ML engineer interviews combine ML theory, coding and production engineering.
- Expect evaluation and failure modes: leakage, imbalance, drift, offline vs online metrics.
- LLM and transformer questions are now common: attention, fine-tuning vs RAG, evaluation.
- Senior loops include ML system design: recommendation, search ranking or fraud detection end to end.
Contents
Machine learning engineer interviews test ML understanding, coding and production engineering: can you build models that work, evaluate them honestly and run them reliably? Below are 31 common questions grouped by topic and level.
What ML engineer interviews cover
Editorial estimate; research roles weigh theory more, applied roles weigh systems more.
- ML fundamentals and evaluation25%
- Coding25%
- ML system design20%
- Deep learning and LLMs15%
- MLOps and production15%
The ML lifecycle
See also data scientist, data engineer and Python interview questions.
ML fundamentals
1Supervised vs unsupervised vs reinforcement learning?
JuniorSupervised learns from labeled examples (classification, regression). Unsupervised finds structure without labels (clustering, dimensionality reduction). Reinforcement learning learns actions by maximizing reward through interaction. Self-supervised learning, used for LLMs, creates labels from the data itself.
2Explain the bias-variance trade-off.
JuniorBias is error from a model that is too simple; variance is error from sensitivity to the training data. Increasing complexity lowers bias and raises variance. Regularization, more data, ensembling and cross-validation help balance them.
3How does gradient descent work?
JuniorIt updates parameters in the direction that reduces the loss, by a step proportional to the learning rate times the gradient. Stochastic and mini-batch variants use subsets of data per step. Optimizers like Adam adapt the step size per parameter.
4Why do tree ensembles often win on tabular data?
MidGradient-boosted trees (XGBoost, LightGBM, CatBoost) handle mixed feature types, missing values, non-linear interactions and different scales with little preprocessing, and they are robust on medium-sized datasets where deep learning has less advantage.
5What is regularization? Name several kinds.
MidTechniques that discourage overfitting: L1 and L2 penalties on weights, dropout, early stopping, data augmentation, weight decay, and limiting model capacity (tree depth, number of layers).
6How do you handle class imbalance?
MidChoose appropriate metrics (precision, recall, PR AUC), use class weights or resampling, tune the decision threshold for the business cost, and collect more examples of the rare class if possible. Validate on the real class distribution.
Evaluation
7Why do you need train, validation and test sets?
JuniorTrain fits parameters, validation selects models and hyperparameters, and the test set gives an unbiased final estimate. If you tune on the test set, its score becomes optimistic. Cross-validation helps when data is limited.
8What is data leakage, and how do you prevent it?
MidUsing information at training time that won’t be available at prediction time, such as future data, target-derived features or preprocessing fitted on all data. Prevent it with time-based splits, pipelines that fit transforms only on training folds, and point-in-time correct feature generation.
9Offline metrics improved but the online A/B test didn’t. Why?
MidThe offline metric may not reflect the business goal, training data may differ from live traffic (distribution shift, position bias in logged data), there may be training-serving skew, latency may hurt user experience, or the effect may be too small to detect. Investigate each.
10How do you evaluate a ranking or recommendation model?
MidOffline with ranking metrics such as NDCG, MAP, recall@k and coverage, using time-based splits; online with A/B tests on engagement, conversion and long-term retention, plus guardrails such as diversity and latency.
Get Machine Learning answer points in real time during your interview
Sottena listens to the interviewer, detects each question and shows short answer points in about a second. 150 free credits, no card required.
Deep learning
11What is backpropagation?
MidAn efficient way to compute gradients of the loss with respect to every weight, by applying the chain rule from the output layer backward. The gradients are then used by an optimizer to update the weights.
12What causes vanishing or exploding gradients, and how are they handled?
MidRepeated multiplication of small or large values through many layers. Remedies: ReLU-family activations, careful initialization, normalization layers, residual connections, gradient clipping, and architectures like LSTMs or transformers.
13Batch normalization vs layer normalization?
MidBatch norm normalizes each feature across the batch, which works well for CNNs but depends on batch size. Layer norm normalizes across features for each example, independent of batch size, which is why transformers use it.
14What is transfer learning?
MidStarting from a model pre-trained on a large dataset and adapting it to your task, by fine-tuning all or some layers or training a small head on frozen features. It reduces data and compute requirements dramatically.
Transformers and LLMs
15How does self-attention work?
MidEach token is projected into query, key and value vectors. Attention weights are the softmax of query-key dot products (scaled by the square root of the dimension), and each output is a weighted sum of values. Multiple heads attend to different relationships; positional information is added separately.
16Fine-tuning vs retrieval-augmented generation (RAG)?
MidRAG retrieves relevant documents at query time and adds them to the prompt: best for knowledge that changes or must be cited. Fine-tuning changes model behavior, style or format and teaches narrow tasks. They are often combined; prompting and RAG are usually tried first because they are cheaper.
17How do you evaluate an LLM-based feature?
SeniorBuild a representative evaluation set with expected outputs or grading criteria, use automated checks (exact match, rubric-based grading by a model, groundedness against sources), add human review for a sample, track cost and latency, and monitor production with user feedback and regression tests on every prompt or model change.
18How do you reduce hallucinations in a RAG system?
SeniorImprove retrieval quality (chunking, hybrid search, reranking), instruct the model to answer only from provided context and to say when it doesn’t know, require citations, check answers against sources, and evaluate groundedness systematically.
19How would you reduce LLM inference cost and latency?
SeniorUse the smallest model that meets quality, cache repeated prompts and responses, shorten prompts, stream responses, batch requests, apply quantization or distillation for self-hosted models, and route easy queries to cheaper models.
Data and features
20What is a feature store?
MidA system that manages features for both training and serving: consistent definitions, point-in-time correct historical values for training, and low-latency access online. It reduces training-serving skew and duplicated feature code.
21What is training-serving skew?
MidA difference between how features are computed in training and in production, for example different code paths, data freshness or default values. It silently hurts model performance. Share feature code, log production features and compare distributions.
22How do you handle high-cardinality categorical features?
MidUse embeddings, target encoding with out-of-fold statistics, hashing, or grouping rare categories into “other”. Choose based on the model type and how much data each category has.
Production and MLOps
23Batch vs real-time inference?
MidBatch precomputes predictions on a schedule (daily recommendations, risk scores); simple and cheap. Real-time predicts per request with fresh features (fraud checks, search ranking); requires low-latency serving, feature availability and autoscaling.
24How do you deploy a new model safely?
MidVersion the model and its data, validate it offline against the current model, run a shadow deployment to compare predictions on live traffic, then a canary or A/B test with guardrail metrics, with a quick rollback path.
25What do you monitor for a model in production?
MidInput data drift and data quality, prediction distribution, latency and errors, and actual performance when labels arrive. Alert on significant changes and define a retraining policy.
26Data drift vs concept drift?
SeniorData drift: the distribution of inputs changes (new user segments). Concept drift: the relationship between inputs and the target changes (fraudsters change tactics). Concept drift requires labels to detect; both may require retraining or new features.
Coding
27Implement logistic regression training with NumPy.
Midimport numpy as np
def train_logreg(X, y, lr=0.1, epochs=1000, l2=0.0):
w, b = np.zeros(X.shape[1]), 0.0
for _ in range(epochs):
p = 1 / (1 + np.exp(-(X @ w + b)))
grad_w = X.T @ (p - y) / len(y) + l2 * w
grad_b = np.mean(p - y)
w -= lr * grad_w
b -= lr * grad_b
return w, b
28Implement k-means clustering.
Middef kmeans(X, k, iters=100, seed=0):
rng = np.random.default_rng(seed)
centers = X[rng.choice(len(X), k, replace=False)]
for _ in range(iters):
labels = np.argmin(((X[:, None] - centers) ** 2).sum(-1), axis=1)
new = np.array([X[labels == j].mean(0) if np.any(labels == j) else centers[j]
for j in range(k)])
if np.allclose(new, centers):
break
centers = new
return centers, labels
ML system design
29Design a recommendation system for an e-commerce site.
SeniorClarify the goal (clicks, purchases, long-term value) and constraints (latency, catalog size). Use a two-stage architecture: candidate generation (collaborative filtering, embeddings, popularity) and a ranking model with user, item and context features. Address cold start, diversity and feedback loops, then define offline metrics, an A/B test and monitoring.
30Design a fraud detection system for payments.
SeniorReal-time scoring within tight latency, features from transaction history and device data (with a feature store), a gradient boosting model plus rules for known patterns, thresholds set by the cost of fraud vs false declines, human review queues, delayed labels from chargebacks, and monitoring for adversarial drift.
31Design a semantic search system.
SeniorEmbed documents with a text embedding model and store them in a vector index; combine vector search with keyword search (hybrid) for exact terms; rerank top results with a cross-encoder; handle updates and permissions; evaluate with labeled queries (recall@k, NDCG) and click data.
How to prepare
- Explain trade-offs, not definitionsWhy this model, this metric, this architecture.
- Implement basics from scratchLogistic regression, k-means, train/test split, metrics.
- Prepare an end-to-end project storyProblem, data, model, evaluation, deployment and impact.
- Practice ML system designRecommendation, ranking, fraud, search; include monitoring.
- Know current LLM practiceAttention, RAG, fine-tuning, evaluation, cost and latency.
Get answer points in real time during your interview
Sottena listens to the interviewer, detects each question and shows short answer points in about a second. 150 free credits, no card required.