Top 30 Advanced AI & ML Interview Questions and Answers
30 advanced multiple-choice AI & ML interview questions, the deep end: internals, failure modes, and the design calls a senior engineer is expected to defend. They come from 30 bites in the AI & ML library, the hardest slice of the 546 AI & ML interview questions in the library. Answer them here or read straight down. Every question carries the correct option, why it is correct, and a link to the bite it came from.
Artificial intelligence, machine learning, and data science
30 questions. Pick an answer, or open “Show the answer” to read it.
Answers are graded in your browser. Nothing is saved, and no XP or streak is earned here. The app keeps score.
Question 1 of 30
Why are positional encodings necessary before the first self-attention layer in a standard Transformer?
Show the answer
Answer: a · Because self-attention computes unordered pairwise dot products, leaving attention scores unchanged when tokens are permuted
Self-attention is permutation-invariant: swapping tokens does not change their dot-product attention scores, so the model receives no sequence-order signal without positional encodings. Distractor A represents the common misconception that feed-forward layers can learn implicit order, but they process each position independently and cannot recover shuffled order.
Read the full bite: Explain positional encodings in Transformers and their necessity
Question 2 of 30
When scoping an MLOps platform for a mid-sized company with 5-15 engineers, which approach best demonstrates mature build-vs-buy reasoning?
Show the answer
Answer: a · Prioritize data governance, feature store, model registry, CI/CD/CT, and monitoring before the serving layer; buy commodity tools like orchestration and monitoring while investing engineering effort only in proprietary feature engineering and model architectures.
This option correctly sequences foundational components before serving and applies the buy-commodity, build-differentiator rule. Option C is tempting because avoiding vendor lock-in feels engineering-savvy, but maintaining a custom feature store and registry would consume two to three full-time engineers and ignores total cost of ownership.
Question 3 of 30
Why is the correlation between profile completion and retention weak evidence that forcing completion will improve retention?
Show the answer
Answer: d · Engaged users self-select into completing profiles, confounding the relationship
Motivated users both complete profiles and retain, so engagement is a confounder making completion a marker rather than a proven cause. A randomized experiment is needed; the other options misstate the actual problem.
Read the full bite: Does forcing profile completion cause retention?
Question 4 of 30
Which promotion flow best reflects a robust automated testing strategy for a weekly retrained production model?
Show the answer
Answer: a · Offline per-slice thresholds and bias checks, data validation for training-serving skew and drift, shadow deployment comparing latency and prediction distributions, then canary gated on business metrics with automatic rollback
This option captures the four-layer strategy from the card: offline statistical validation, data validation, shadow deployment, and canary gated on business metrics with automatic rollback. Option D is the most tempting distractor because it uses correct terminology but reverses the order and incorrectly uses offline accuracy as the final promotion gate rather than live business metrics.
Read the full bite: Design a robust automated testing strategy for ML models before production
Question 5 of 30
What is the most important addition to a revenue metric when evaluating a change that may harm long-term satisfaction?
Show the answer
Answer: b · Long-horizon guardrail metrics like retention plus a sufficiently long experiment
Long-term harm surfaces as delayed churn, so guardrail metrics measured over a long-enough window are essential to weigh against the immediate revenue lift. More precise short-term revenue alone still misses the delayed retention cost.
Read the full bite: Framing ad-load tradeoffs: revenue versus retention
Question 6 of 30
When validating a composite burnout proxy, why test whether it predicts voluntary attrition six months later?
Show the answer
Answer: c · It establishes predictive validity by showing the proxy correlates with a meaningful future outcome
Testing future attrition establishes predictive validity, confirming the composite index captures a construct with real downstream consequences. The most tempting distractor confuses prediction with causation: a proxy that predicts attrition does not prove burnout causes it, since unobserved confounders may drive both.
Read the full bite: How would you build and validate a proxy target for employee burnout?
Question 7 of 30
Why does a fixed Euclidean distance threshold in RGB fail to produce consistent perceptual segmentation across light and dark image regions?
Show the answer
Answer: a · The same numerical RGB delta can correspond to a huge perceived shift in one region while being nearly invisible in another
RGB is linear with respect to light intensity but not human perception, so identical Euclidean deltas can look huge in one region and nearly invisible in another. HSV is a cylindrical transform of RGB and is not perceptually uniform, while CIELAB is designed for perceptual uniformity rather than linear physical intensity.
Read the full bite: Why is RGB Euclidean distance a poor measure of perceptual color difference?
Question 8 of 30
A model is trained on batch aggregates computed in Spark and served via a Python microservice using real-time streams. What is the most robust way to prevent training-serving skew?
Show the answer
Answer: b · Use a shared transformation library for both paths, serve from a versioned feature store, and log features at training time for replay validation
A shared transformation library and versioned feature store guarantee both paths execute identical logic from a single source of truth. Relying on manual code reviews is insufficient because separate implementations inevitably diverge under operational pressure.
Question 9 of 30
When photometric stereo assumes a Lambertian model but the surface is glossy, false geometry is reconstructed because the solver...
Show the answer
Answer: c · misinterprets view-dependent specular brightness as a tilted surface normal
Under a Lambertian assumption, the solver expects brightness to depend only on the light direction and surface normal, so view-dependent specular highlights are misread as changes in normal orientation. Option A describes a common conceptual error—treating the BRDF as a scalar albedo—but it does not explain the specific mechanism that creates phantom geometry in photometric stereo.
Read the full bite: Describe the BRDF, its advantage over Lambertian, and critical CV tasks
Question 10 of 30
Which statement accurately captures the computational and memory complexity of exact self-attention as sequence length grows?
Show the answer
Answer: a · FLOPs grow as O(n^2) from the QK^T attention score matrix, while activation memory can be reduced to O(n) by recomputing rather than storing the full matrix.
Exact self-attention must perform O(n^2) FLOPs to compute the attention score matrix, but activation memory is not fundamentally quadratic: by recomputing scores instead of materializing the full n×n matrix in HBM, memory can be reduced to O(n). Option C is tempting because standard implementations often do store the full matrix, leading many to assume that O(n^2) memory is unavoidable even without approximation.
Read the full bite: Why is self-attention O(n^2) and what are the implications?
Question 11 of 30
Why is layer normalization preferred over batch normalization inside Transformer blocks for NLP?
Show the answer
Answer: c · Layer norm normalizes per token over features, independent of batch size and sequence length
Layer norm uses per-token feature statistics, so variable sequence lengths and small or padded batches do not destabilize it, and it matches at train and inference. Batch norm's batch-wise statistics are exactly what makes it unreliable here.
Read the full bite: Layer Norm and Residuals in Transformer Blocks
Question 12 of 30
In PCA on mean-centered data, what does the eigenvalue associated with a principal component directly represent?
Show the answer
Answer: d · The variance of the data projected onto that component's direction
Each eigenvalue equals the variance captured along its eigenvector, which is why components are ranked by eigenvalue. Accuracy is a downstream model metric, not what the eigenvalue measures.
Read the full bite: Eigenvalues, eigenvectors, and their role in PCA
Question 13 of 30
When rotating an image, why is inverse mapping preferred over forward mapping of pixels?
Show the answer
Answer: b · It guarantees every output pixel gets exactly one interpolated value, avoiding holes and overlaps
Iterating over output pixels and sampling the source ensures full, single-valued coverage, while forward mapping leaves gaps and collisions. Inverse mapping still uses the inverse transform and interpolation to read fractional source coordinates.
Read the full bite: Image rotation: forward versus inverse mapping
Question 14 of 30
What is the primary reason a 2D Gaussian blur can be computed in O(N²K) rather than O(N²K²) for an N×N image and K×K kernel?
Show the answer
Answer: d · The Gaussian kernel is a rank-one matrix expressible as the outer product of two 1D vectors
The Gaussian kernel is separable because it equals the outer product of two 1D Gaussians (a rank-one matrix), so two O(N²K) 1D passes replace one O(N²K²) 2D convolution. Using FFT is a distinct optimization, and neither normalization nor circular symmetry implies that a kernel can be decomposed into 1D passes.
Read the full bite: How does filter separability optimize Gaussian blur and its complexity?
Question 15 of 30
Why is it architecturally necessary to keep batch historical features in a KV store while maintaining session-level streaming features in a separate in-memory cache?
Show the answer
Answer: a · The batch path produces terabyte-scale pre-aggregated profiles that are updated infrequently, while the streaming path handles high-velocity session events with natural TTL decay; a single storage system cannot optimize for both access patterns under the 50ms SLA.
The card states that batch and streaming data have fundamentally different latency, volume, and freshness requirements, so one storage system cannot handle both optimally without breaking the sub-50ms SLA. Distractor A sounds plausible because the follow-ups mention exactly-once semantics for billing, but the card never cites billing consistency as the reason for the dual-store split.
Read the full bite: Design a sub-50ms real-time bidding feature pipeline
Question 16 of 30
In a two-proportion conversion test, which change most directly explains why detecting a 2% relative lift requires roughly 390k users per variant instead of 63k for a 5% relative lift?
Show the answer
Answer: a · The absolute MDE shrinks from 0.5 to 0.2 percentage points, and sample size scales roughly with the inverse square of the absolute effect size.
The correct answer identifies that the absolute MDE falls from 0.5 to 0.2 percentage points, and because N is roughly proportional to the inverse square of the absolute MDE, required sample size balloons by about sixfold. Distractor D is tempting because it quotes the true p(1-p) variance formula from the card, but in this range variance barely changes and cannot explain the explosion in sample size.
Read the full bite: How do you determine sample size for a conversion lift experiment?
Question 17 of 30
An ML platform team still spends days debugging accuracy drops because they must manually cross-reference spreadsheets, data catalogs, and model registries across hundreds of models. Which architectural change most directly fixes this?
Show the answer
Answer: d · Building a unified lineage graph with automated hooks connecting raw sources, transformations, training runs, and deployments
A unified lineage graph with automated hooks treats lineage as a connected graph problem, enabling traversal from a deployed model back to raw data and transformations. Options A and B address only fragments of the pipeline, while D merges storage without guaranteeing the relationships or automated capture needed for root-cause analysis.
Read the full bite: How to establish data lineage and reproducibility for hundreds of ML models
Question 18 of 30
Under what condition does MAP estimation give essentially the same result as MLE?
Show the answer
Answer: a · When the prior is uniform or the dataset is very large
A uniform prior makes the posterior proportional to the likelihood, and with large data the likelihood overwhelms any prior, so MAP converges to MLE. A strong prior on small data does the opposite.
Read the full bite: MLE versus MAP estimation and the role of priors
Question 19 of 30
Why does Canny use gradient orientation during non-maximum suppression?
Show the answer
Answer: b · To determine which neighboring pixels to compare for ridge thinning
Gradient orientation tells NMS which neighbors lie along the edge direction so it can thin multi-pixel ridges to single-pixel width. Option C describes hysteresis, which uses spatial connectivity rather than gradient direction to link edges.
Read the full bite: Walk me through Canny edge detection and why it beats Sobel thresholding
Question 20 of 30
What is the core reason FlashAttention is faster than a naive attention implementation?
Show the answer
Answer: c · It is IO-aware: tiling and kernel fusion avoid writing the full attention matrix to slow HBM
FlashAttention computes exact attention but minimizes slow HBM traffic by tiling into SRAM and fusing kernels with an online softmax. It does not approximate, sparsify, or reduce the arithmetic complexity; it cuts memory movement.
Question 21 of 30
Why is deduplication a critical stage when preparing a massive dataset for foundation-model training?
Show the answer
Answer: b · Duplicates waste training compute and can skew the model toward over-represented samples
Duplicate and near-duplicate samples inflate compute and bias the model toward repeated content. Corruption detection and PII filtering are separate stages with their own purposes.
Read the full bite: Scalable multi-modal data quality pipeline
Question 22 of 30
When repurposing a pretrained CNN like VGG16 for image retrieval, why are deep-layer activations usually preferred over the final softmax output?
Show the answer
Answer: a · Deep activations encode rich semantic features, while softmax collapses the image to class probabilities
A late hidden layer yields a high-dimensional semantic descriptor ideal for similarity comparison, whereas the softmax discards detail by reducing the image to class scores. Earlier layers still carry useful low-level information, just less semantic content.
Question 23 of 30
Which design best avoids redundant demonstrations while keeping retrieval latency acceptable at scale?
Show the answer
Answer: a · Fetch a larger candidate set using ANN, apply a diversity reranker, then assemble a token-bounded prompt asynchronously.
Fetching a larger ANN candidate set and reranking for diversity prevents redundant examples while keeping latency low, and asynchronous assembly protects inference time. Option D is tempting but exact flat search is O(N) and too slow for online serving, and it lacks any diversity mechanism.
Read the full bite: Design dynamic few-shot example retrieval from a vector database
Question 24 of 30
Why is ORB typically preferred over SIFT for the front end of a real-time visual SLAM system on a mobile device?
Show the answer
Answer: d · ORB's cheap FAST keypoints and binary descriptors meet the per-frame latency and power budget
Real-time SLAM needs detection, description, and matching within milliseconds at low power, which ORB's FAST keypoints and Hamming-matched binary descriptors satisfy. SIFT is more robust but too slow; temporal continuity offsets ORB's weaker invariance.
Read the full bite: Feature choice for real-time mobile SLAM
Question 25 of 30
What is the central risk of using one model's embedding as a feature for a downstream model?
Show the answer
Answer: c · Updating the upstream model shifts the feature space, degrading the downstream model unless versions are pinned and coordinated
The downstream model is tied to a specific embedding version's geometry, so an unpinned upstream change causes silent skew and degradation. Dimensionality and feature type are not the core problem.
Question 26 of 30
When aggregating a 50GB CSV on a 16GB machine, which strategy keeps peak memory usage proportional to a small fragment rather than the entire file?
Show the answer
Answer: c · Iterate with read_csv(chunksize=...), aggregating each fragment and discarding it before reading the next
Streaming with chunksize processes only one fragment at a time, keeping memory bounded by that fragment instead of the full 50GB. Option A is tempting because filtering columns and downcasting dtypes are valid optimizations, but materializing the entire file in a single DataFrame still exhausts RAM.
Question 27 of 30
A transaction event at 08:50 must be joined to a user profile table where the user upgraded to premium at 09:00. Which join behavior preserves point-in-time correctness for the training row?
Show the answer
Answer: a · Match the most recent profile row with a timestamp less than or equal to 08:50.
An AS OF join retrieves the latest dimension record known at or before the event timestamp, so the 08:50 event correctly sees the pre-upgrade standard tier. Option D is the most tempting distractor because joining on user_id alone and taking the latest record silently leaks future state into the training set.
Read the full bite: Design system ensuring point-in-time correctness for training data joins
Question 28 of 30
You convert a 10-million-row DataFrame's string column with 6 million unique values to category. What is the likely effect on memory usage?
Show the answer
Answer: b · Memory increases because the category codes plus unique values list outweigh a simple object array.
When cardinality exceeds roughly fifty percent of row count, the storage cost of category codes plus the unique values list exceeds that of a plain object array. Option A is a common misconception that category dtype always reduces memory, but it is only beneficial for low-cardinality columns.
Read the full bite: How do you analyze and reduce large pandas DataFrame memory usage?
Question 29 of 30
A platform team advocates for a declarative feature platform to reduce boilerplate. Which risk best illustrates why this choice could fail without the right organizational maturity?
Show the answer
Answer: b · The team must own the opinionated abstractions for checkpointing, schema evolution, and exactly-once semantics, requiring deep infrastructure expertise.
Declarative platforms centralize ownership of checkpoints, schema evolution, and exactly-once semantics within the platform team, so adopting one without that infrastructure maturity fails; option A describes imperative platforms, and D wrongly assumes declarative means no-code.
Read the full bite: Argue for declarative or imperative feature platforms with trade-offs
Question 30 of 30
Which architecture best detects training-serving skew without impacting serving latency?
Show the answer
Answer: b · Versioned per-feature statistics in the model registry, asynchronous inference feature logging, and periodic statistical tests like PSI or KS against baselines
The correct design uses the model registry as a source of truth for immutable training statistics and asynchronously logs production feature vectors to compare distributions via PSI or KS without adding P99 latency. Option A is tempting because circuit breaking is a valid severe response, but performing distribution checks synchronously on every request would directly violate the latency constraint that the logging layer is meant to avoid.
Could you explain these out loud?
That is what an interview actually tests. Tezvyn gives you questions like these with what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.