KatInterview

ML System Evaluation, Sequence Architectures, Distribution Drift, and Optimizers

Machine LearningModel answer
MediumModel answerMachine Learningevaluation metricssequence modelingdistribution shift

Last updated

A deep-dive technical interview covering model validation strategies, metrics, sequence model trade-offs (RNNs vs. Transformers), distribution shift detection, and optimizer selection.

In a senior machine learning technical interview, candidates are often expected to defend end-to-end design choices for ML systems—from data validation and metric selection to sequence modeling trade-offs, distribution drift detection, and optimization dynamics.

Answer the following four modules systematically, covering foundational theory, concrete mathematical formulations, and engineering trade-offs.


Module 1: Comprehensive Evaluation & Annotation Architecture

  1. Validation & Holdout Protocol: Detail an end-to-end evaluation pipeline that guards against data leakage across training, validation, and testing phases. Explain how data splitting strategies should adapt to different data properties (e.g., temporal, user-grouped).
  2. Metric Selection & Mathematical Formulations:
    • Provide exact mathematical definitions for Precision, Recall, $F_1$ Score, ROC-AUC, PR-AUC (Average Precision), Log Loss (Binary Cross-Entropy), and Expected Calibration Error (ECE).
    • Contrast ROC-AUC and PR-AUC in imbalanced settings, and discuss when probability calibration (e.g., ECE) takes priority over ranking metrics.
  3. Advanced Evaluation Workflows: Describe methods beyond a single holdout set (e.g., Stratified/Group K-Fold cross-validation, time-decayed rolling splits, paired bootstrap significance testing, and sliced evaluation) to produce robust performance estimates.
  4. Human-in-the-Loop Evaluation:
    • Outline a protocol for creating high-quality human-labeled evaluation sets (sampling schemes, annotation guidelines, gold-standard quality control).
    • Define Cohen’s Kappa ($\kappa$) and explain how inter-annotator agreement metrics guide task design.
  5. Unsupervised Output Comparison: When reference labels are absent, what is the simplest effective approach to measure semantic or structural similarity between two generated outputs?

Module 2: Sequence Architectures on Extended Contexts (RNNs vs. Transformers)

  1. Architectural Comparison: Contrast Recurrent Neural Networks (LSTMs/GRUs) and Transformer Attention architectures across:
    • Computational path length between arbitrary tokens $i$ and $j$.
    • Training parallelization bottlenecks.
    • Inference space and time complexities.
  2. Long-Range Dependencies & Gradient Dynamics:
    • Write out the backpropagation through time (BPTT) Jacobian product $\frac{\partial h_T}{\partial h_t}$ for a vanilla RNN and explain mathematically why gradients vanish or explode.
    • Explain how Self-Attention bypasses sequential gradient decay and describe why vanilla Transformers face quadratic computational memory scaling ($\mathcal{O}(N^2)$) on ultra-long sequences.

Module 3: Visual Distribution Shift & Two-Sample Testing

Given two unlabeled datasets of images, Dataset $A$ and Dataset $B$:

  1. Outline a multi-stage approach to test if Dataset $A$ and Dataset $B$ stem from the same underlying distribution $\mathcal{P}_A = \mathcal{P}_B$.
  2. Explain how to combine raw metadata checks, high-level statistical feature extraction, and formal statistical hypothesis testing (e.g., Classifier Two-Sample Tests or Maximum Mean Discrepancy).

Module 4: Optimization Algorithms & Weight Decay Dynamics

  1. Compare Stochastic Gradient Descent (with Momentum), RMSProp, Adam, and AdamW.
  2. Provide the explicit update equations showing how standard Adam with $L_2$ regularization differs from AdamW (decoupled weight decay), and explain why this distinction is critical when using adaptive learning rates.

Hints

Hint 1

For evaluation metrics, pay close attention to how class prevalence affects the baseline for PR-AUC versus ROC-AUC.

Hint 2

Recall that the gradient path in RNNs involves matrix multiplication over T timesteps, whereas Self-Attention creates a direct O(1) connection between any two tokens.

Hint 3

When decoupling weight decay in adaptive optimizers, consider how scaling the gradient by the second-moment estimator alters the effective decay rate of large weights.