KatInterview

Building a Low-Latency Ad Ranking Pipeline with ML

Machine LearningModel answer
HardModel answerMachine Learningctr-predictionrecommendationbandits

Last updated

Design an end-to-end ML system that picks personalized ads for millions of users within a tight latency budget, covering data, models, exploration, evaluation and scaling.

Context

An ad platform serves personalized ads to a very large user base. Each time a user opens a page or app, the system has a short window to decide which ads to show, and the choice should maximize expected value for the platform while respecting advertiser and user constraints.

Task

Design the machine-learning system behind this ad selection. Your answer should address:

  1. Data collection and labeling: which events you log, how labels are built, and what goes wrong with them.
  2. Feature engineering: feature groups, real-time versus historical signals, and how you keep training and serving consistent.
  3. Model choice: a baseline, how you would evolve it, and how predictions feed the ranking and auction.
  4. Exploration versus exploitation: how new or uncertain ads get a fair chance without hurting revenue too much.
  5. Evaluation: offline metrics, counterfactual evaluation of a new policy, and online experiments.
  6. Latency and scalability: serving architecture, a latency budget, and capacity assumptions.

State your assumptions with numbers (users, requests per second, number of ads, latency target) and call out the trade-offs and failure modes you would watch for.

Hints

Hint 1

Think in a funnel: a cheap retrieval step shrinks a huge ad pool to a small candidate set, and only then does a heavier model score candidates. Allocate a latency budget to each stage.

Hint 2

Clicks are rare and only observed for ads you actually showed. Consider what this does to class balance, calibration after downsampling, position effects and selection bias, and what you must log at impression time to fix them later.

Hint 3

Separate how you pick a policy from how you evaluate it: log the probability each shown ad was chosen so that inverse-propensity-style estimators can score a new policy offline before an A/B test.