- System Design Framework & Fundamentals
- Problem Formulation & Metrics
- Data Pipeline & Feature Engineering
- Model Design & Selection
- Scalability & Real-Time Serving
- System Monitoring & Maintenance
- End-to-End Case Studies
💡 Show Answer
- Clarify Requirements & Constraints:
- Functional goals (e.g., recommend products, detect fraud).
- Business metrics (e.g., CTR, conversion rate, latency budget < 100ms, throughput 10k QPS).
- Problem Formulation:
- Map business goal to ML task (Binary classification, Multi-class, Ranking, Regression).
- Define inputs, outputs, and offline/online evaluation metrics.
- Data Pipeline & Engineering:
- Data collection, labelling strategies, sampling techniques.
- Batch vs Streaming pipelines (Kafka, Flink, Spark), feature store design.
- Model Architecture & Training:
- Baseline models vs advanced architectures (Deep & Cross Networks, Two-Tower models).
- Training loss functions, hyperparameter tuning, distributed training strategy.
- Serving & Deployment:
- Real-time online serving vs batch pre-computation.
- Model compression (quantization, pruning, distillation), Caching layer (Redis).
- Monitoring, Failure Recovery & Retraining:
- Data drift & Concept drift monitoring, feedback loops, fallback mechanisms.
💡 Show Answer
| Criteria | Batch Inference | Real-Time Online Inference |
|---|---|---|
| Latency | Pre-computed (ms lookup) | On-demand computation (50-200ms) |
| Context Freshness | Low (updated hourly/daily) | High (uses real-time user context) |
| Cost & Complexity | Lower cost, simpler setup | Higher infrastructure cost & operational complexity |
| Best Used For | Daily movie recommendations, churn prediction | Search ranking, ad CTR prediction, fraud detection |
💡 Show Answer
-
Point-in-Time Correct Joins (Time-Travel): When constructing training sets from historical events, ensure features for event time
$t$ only include data recorded strictly before$t$ . - Centralized Feature Store: Use a Feature Store (e.g., Feast, Tecton) that guarantees feature definition parity between offline training and online serving key-value stores.
- Strict Pipeline Isolation: Fit all transformations (scalers, encoders, target imputation) strictly on training split folds before applying to validation/test splits.
💡 Show Answer
In systems with millions of items (e.g., YouTube, E-commerce):
-
User Tower: Deep Neural Network mapping user context/history features to a user embedding vector
$\vec{u} \in \mathbb{R}^d$ . -
Item Tower: Deep Neural Network mapping item features to an item embedding vector
$\vec{v} \in \mathbb{R}^d$ . -
Scoring & Approximate Nearest Neighbor (ANN):
- Similarity is dot product
$\langle \vec{u}, \vec{v} \rangle$ . - Item embeddings are pre-indexed offline in an ANN vector database (Faiss, HNSW).
- At runtime, query vector
$\vec{u}$ retrieves top-100 candidates in < 5ms.
- Similarity is dot product
💡 Show Answer
-
Quantization: Convert FP32 model weights to INT8 precision (up to
$4\times$ footprint reduction,$2-3\times$ speedup with minimal accuracy loss). - Knowledge Distillation: Train a compact "Student" network to mimic outputs of an ensemble "Teacher".
- Graph Optimizations & Engines: Use ONNX Runtime or TensorRT to fuse operations (e.g., Conv + ReLU fusion).
- Multi-Tier Caching: Cache top query results in Redis/Memcached.
💡 Show Answer
-
Covariate Shift:
$P(X)$ changes while$P(Y|X)$ remains constant.- Detection: Compare input feature distributions over time using Kolmogorov-Smirnov (KS) test or Population Stability Index (PSI).
-
Concept Drift:
$P(Y|X)$ changes (e.g., user preferences shift post-pandemic).- Detection: Monitor online metrics (CTR, conversion rate, precision@k) and compare prediction probability distributions vs true feedback.
-
Remediation:
- Automated continuous retraining pipelines (airflow/KubeFlow) triggered by PSI threshold breaches.
- Fallback to rule-based heuristics if model metrics degrade past critical guardrails.
💡 Show Answer
-
Stage 1: Retrieval (Candidate Generation)
- Input: User ID, recent views, location.
- Model: Two-Tower Neural Network / Matrix Factorization retrieving Top 500 items from 10M catalog in ~10ms via FAISS.
-
Stage 2: Ranking
- Model: Deep & Cross Network (DCN-v2) scoring candidate items using rich interactions (user-category history, price sensitivity).
- Loss: Multi-task learning (pCTR
$\times$ pCVR).
-
Stage 3: Re-ranking & Business Logic
- Diversity filtering, out-of-stock exclusion, freshness boosting, sponsored ad insertion.
-
Infrastructure:
- Kafka for clickstream streaming, Flink for real-time feature aggregation, Feast Feature Store, Triton Inference Server.