Bird
Raised Fist0

The Weekend Model Collapse

SYSTEM-DESIGNhardInterview freq: very_high
Choose your preparation mode6 modes available
🐛
The Weekend Model Collapse
Started last Friday evening, ongoing for 3 days.

A fraud detection system scoring 5 million transactions per day for a major e-commerce platform.

Symptom
Model achieves 0.92 AUC offline but drops to 0.75 AUC on live traffic. Real-time feature latency spiked from 50ms to 200ms.
📡
Signals
metric
Live AUC on production traffic
Dropped from 0.92 to 0.75
latency
Real-time feature extraction latency
Increased from 50ms to 200ms
distribution
Distribution of transaction amounts
Shifted significantly over the weekend
feature_importance
Feature importance for 'transaction_time_of_day'
Dropped from 0.15 to 0.03
log
Error logs from feature extraction service
Increased frequency of timeout errors
🔬
Hypotheses
Feature extraction service is causing latency spikes, affecting model performance.
latencylog
Verify: Check service logs for timeout errors and correlate with latency spikes.
import pandas as pd; df = pd.read_csv('service_logs.csv'); df['latency'].plot(); plt.show()
Distribution shift in transaction amounts is causing model performance degradation.
distributionmetric
Verify: Analyze transaction amount distribution pre and post-failure.
import seaborn as sns; import matplotlib.pyplot as plt; sns.histplot(df['transaction_amount'], kde=True); plt.show()
🎯
Root Cause
Feature extraction service latency spike due to increased load and inefficient query handling.

A sudden increase in weekend traffic exposed inefficiencies in the feature extraction service's query handling.

🔧
Fix Strategy
ImmediateRollback to the last known good model version.
Short-termOptimize the feature extraction service to handle increased load efficiently.
Long-termImplement load balancing and caching strategies for the feature extraction service.
🐍
Python Fix
Python
def optimize_service():
    # Add caching
    cache = {}
    def get_features(transaction):
        if transaction.id in cache:
            return cache[transaction.id]
        features = extract_features(transaction)
        cache[transaction.id] = features
        return features
    return get_features
✗
Common Wrong Diagnoses
▼ Show
The model is overfitting to the training data.
Why candidates think this: The offline AUC is high, but live AUC is low, suggesting overfitting.
Why wrong: The model performed well before the weekend, indicating the issue is not with overfitting.
A bug in the feature extraction code.
Why candidates think this: Increased error logs suggest a code issue.
Why wrong: The errors are due to latency, not a code bug.
📊
Monitoring to Add
  • Real-time monitoring of feature extraction latency.
  • Alerts for sudden drops in live AUC.
  • Traffic load monitoring on feature extraction service.
📋
Process Change

Implement a weekend-specific load testing protocol to anticipate traffic spikes.

🏗️
Architectural Change

Redesign feature extraction service to be more scalable and resilient to traffic spikes.

💡
Key Insight
Latency spikes in feature extraction can drastically affect real-time model performance, especially under increased load.

Practice

(1/5)
1. In a model registry, what is the primary purpose of model versioning?
easy
A. To improve model accuracy over time
B. To ensure models are always deployed
C. To track changes and updates to models
D. To automatically optimize hyperparameters

Solution

  1. Step 1: Understand model versioning purpose

    Model versioning is primarily about tracking changes and updates to models.
  2. Step 2: Eliminate wrong options

    To improve model accuracy over time is incorrect because versioning doesn't directly improve accuracy. To ensure models are always deployed is wrong because versioning doesn't ensure deployment. To automatically optimize hyperparameters is incorrect as versioning isn't about hyperparameter optimization.
  3. Final Answer:

    Option C -> Option C
  4. Quick Check:

    Versioning = Tracking changes [OK]
Hint: Versioning = Tracking changes [OK]
Common Mistakes:
2. When implementing a Guardrails System for LLMs, should you prioritize precision over recall, and why?
medium
A. Yes, because precision ensures the system is efficient and fast.
B. No, because recall is more important to ensure all inappropriate content is caught.
C. Yes, to minimize false positives and avoid blocking legitimate content.
D. No, because precision and recall are equally important in all cases.

Solution

  1. Step 1: Understand the trade-off

    Prioritizing precision minimizes false positives, crucial for user experience.
  2. Step 2: Eliminate wrong options

    Recall is important but can lead to over-blocking, efficiency isn't the main concern, and equal importance isn't practical in all cases.
  3. Final Answer:

    Option C -> Option C
  4. Quick Check:

    Prioritize precision to avoid blocking legitimate content. [OK]
Hint: Prioritize precision to avoid blocking legitimate content. [OK]
Common Mistakes:
3. When designing a session-based recommendation system, why might you choose a Transformer model over an RNN?
medium
A. RNNs require less data preprocessing.
B. Transformers are faster for small datasets.
C. RNNs are more interpretable.
D. Transformers handle long-range dependencies better.

Solution

  1. Step 1: Compare model capabilities

    Transformers are known for effectively capturing long-range dependencies due to their attention mechanism.
  2. Step 2: Eliminate incorrect reasons

    Transformers are not necessarily faster for small datasets; RNNs are not more interpretable or require less preprocessing.
  3. Final Answer:

    Option D -> Option D
  4. Quick Check:

    Transformers for long-range dependencies. [OK]
Hint: Transformers for long-range dependencies. [OK]
Common Mistakes:
4. A session-based recommendation model is underperforming. Which of the following is a likely failure mode specific to sequential modeling?
medium
A. Ignoring the order of interactions.
B. Data leakage from test to train set.
C. Using a too small learning rate.
D. Overfitting due to too many features.

Solution

  1. Step 1: Identify sequential modeling issues

    Ignoring the order of interactions can lead to poor performance in sequential models.
  2. Step 2: Eliminate generic issues

    Overfitting and data leakage are general issues; learning rate affects convergence speed, not sequence handling.
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    Order matters in sequences. [OK]
Hint: Order matters in sequences. [OK]
Common Mistakes:
5. In an HNSW-based vector search system, what is a likely failure mode if the graph's maximum layer is not properly maintained?
medium
A. Increased precision but decreased recall
B. Increased memory usage without affecting speed
C. Decreased search speed due to inefficient traversal
D. Decreased indexing speed but improved search accuracy

Solution

  1. Step 1: Understand the role of the maximum layer.

    The maximum layer affects traversal efficiency.
  2. Step 2: Eliminate wrong options.

    Precision, recall, and memory usage are not directly affected by the maximum layer.
  3. Final Answer:

    Option C -> Option C
  4. Quick Check:

    Max layer affects traversal speed. [OK]
Hint: Max layer affects traversal speed. [OK]
Common Mistakes:
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard