KatInterview

Design a Short-Video Feed Ad Ranking System

Machine LearningModel answer
HardModel answerMachine Learningads rankingmulti-task learningposition bias

Last updated

Design an end-to-end ML pipeline that selects, scores, and ranks ads in a short-video feed under strict latency, handling position bias and multiple competing objectives.

Scenario

A short-video platform serves a continuous feed mixing organic content with sponsored ads. The ad inventory holds roughly one million active creatives, but only a handful of slots per session are available. Your task is to design the ML system that decides which ads to show and in what order.

What You Need to Design

1. Architecture overview Describe a multi-stage pipeline that fits within a 100 ms end-to-end latency budget. Explain what each stage does, how many candidates it processes, and why the pipeline is structured that way.

2. Multi-objective ranking model The platform cares about at least three things simultaneously: whether the user engages with the ad (click-through rate), how much revenue the ad generates (expected CPM), and whether the feed stays healthy over time (avoiding fatigue and reports). Propose a modeling approach that balances these goals, and explain the final scoring formula used to rank and price ads.

3. Position bias An ad shown in the first slot is far more likely to be clicked than an identical ad in slot five, purely because of its position. If you train naively on logged data, the model learns to associate high position with quality rather than learning true ad relevance. Describe a concrete strategy to remove this bias at training time without sacrificing serving-time performance.

4. Delayed conversions A user may click an ad now but complete a purchase hours or days later. Explain the problem this creates for training and propose a practical solution.

5. Real-time adaptation If a user just interacted with three ads in a row, the system should adapt immediately — without waiting for the next daily model retrain. Describe your data pipeline and feature strategy to make this happen.

6. Evaluation Define the offline metrics you would track before pushing a new model, and the online metrics you would use to decide whether to roll it out fully.

Constraints and Assumptions

  • ~300 M daily active users, ~15 ad slots served per user per day → roughly 200 K QPS at peak.
  • Inventory: ~1 M active ads; after targeting and budget filters, a few thousand are eligible per request.
  • Latency budget: < 100 ms p99 end-to-end.
  • Billing types include CPM, CPC, and CPA; ranking must output calibrated probabilities, not just a relative ordering.
  • The platform runs a second-price auction, so miscalibrated scores directly mis-price inventory.

What a Strong Answer Covers

  • A justified two-stage retrieval → ranking split and latency allocation per stage.
  • A multi-task model architecture (e.g., MMoE) with clear reasoning about task conflict and negative transfer.
  • A position bias solution that is practical at serving time (not just theoretically correct).
  • A concrete approach to delayed conversions — either fake-negative correction, a delay-distribution model, or a hybrid.
  • A streaming feature pipeline that keeps session context fresh with no model retraining.
  • Offline metrics (AUC, calibration, GAUC) and online metrics (CTR, RPM, hide rate, long-term retention) with explicit trade-off awareness.

Hints

Hint 1

Before scoring, you need to shrink 1 M ads to a manageable set. Think about what cheap signals let you cut 99% of candidates before the expensive model ever runs — and what you'd lose by doing that aggressively versus conservatively.

Hint 2

Position bias creates a feedback loop: the model favors high-position ads, so they keep getting shown in high positions, which makes them look even better. A separate shallow tower trained only on position signals — and dropped at inference — breaks that loop cleanly. Think about why you'd drop it at inference rather than just set position = 1.

Hint 3

For delayed conversions, consider what label you assign to a click that has no conversion yet. Treating it as a negative immediately will train the model to underestimate conversion rate. One clean fix is to ingest the click as a negative first, then re-ingest a positive when (and if) the conversion arrives, with importance weights to keep the expected gradient unbiased.