KatInterview

Design a Machine Learning System for Social Feed Ad Ranking

Machine LearningModel answer
HardModel answerMachine Learningsystem designrecommendation systemsclick-through rate

Last updated

Design an end-to-end ML architecture to optimize feed ad click-through rates, detailing metric trade-offs, multi-stage serving pipelines, graph/two-tower embeddings, and bias mitigation.

You lead the ad ranking engineering team for a major social networking platform. Your team is tasked with building a machine learning system to improve the Click-Through Rate (CTR) of sponsored posts interleaved within the primary user activity feed.

The business wants to increase user engagement with ads while preserving the quality of the organic feed experience and maintaining long-term user retention. The model predictions feed directly into an downstream ad auction where bids are weighted by expected action probabilities.

Walk through how you would frame, build, train, serve, and operate this ad recommendation system end to end. Be prepared to go into technical depth on:

  1. System Goals and Business Constraints: Balancing CTR optimization against user experience guardrails and auction integrity.
  2. Multi-Stage Serving Architecture: Designing a latency-constrained system from retrieval through ranking to auction.
  3. Training Data Pipeline: Designing log schemas, constructing positive/negative labels without data leakage, and preventing sampling bias.
  4. User & Ad Representation Learning: Implementing two-tower representations and graph-based embedding approaches (e.g., GNNs/PinSage).
  5. Operational Realities: Handling position bias, delayed feedback, cold-start items, model calibration, and explore-exploit trade-offs.

Hints

Hint 1

CTR cannot be optimized in a vacuum; raw CTR models will over-index on clickbait. Explain how probability calibration impacts auction scoring (eCPM = Bid × pCTR).

Hint 2

Pay close attention to negative sampling: using unclicked feed impressions is mandatory, but how do you handle unseen or filtered candidates without introducing selection bias?

Hint 3

For embeddings, contrast how two-tower networks (optimized for ANN low-latency retrieval) differ in structure and feature usage from graph-based architectures (optimized for structural similarity across heterogeneous graphs).