KatInterview

Ranking Currently-Live Channels Under a 100 ms Budget

Machine LearningModel answer
HardModel answerMachine Learningrecommender-systemstwo-towercounterfactual-learning

Last updated

Design an end-to-end ML system that ranks live channels for viewers, covering labels, features, models, bias correction, evaluation, and low-latency serving as streams start and end.

You are asked to design a recommender that fills a "Live now" row on a video platform's home page. Each request returns about 20 channels that are broadcasting at that moment. The set of eligible items changes every minute as broadcasts begin and end, and a channel that has gone offline has no value.

Walk through the following parts in your answer.

  1. Objective and labels. Choose a primary objective, for example the probability that a viewer who sees a channel stays for at least 10 minutes. Explain how you would build training labels from a view_events log, including outcomes that arrive late and cases where the broadcast ends before the 10-minute mark is possible.
  2. Features. Describe user, creator, stream, and context features. Cover cold start for new creators and new users, and explain how short-term session behavior and long-term embeddings are combined.
  3. Model and loss. Pick a model family (for instance a two-tower retrieval stage followed by a re-ranker with calibrated probabilities). State the loss, the negative sampling plan (in-batch plus hard negatives), and how you handle strong class imbalance.
  4. Feedback loops and bias. Explain how you would reduce position bias and popularity bias, using counterfactual estimators (IPS or doubly robust) and/or randomized exploration. Describe the exploration policy (Thompson Sampling, UCB, etc.) and the safety limits around it.
  5. Evaluation. Name offline metrics (AUC, PR-AUC, calibration, NDCG@k) and online metrics (watch time per viewer, session length, bounce rate). Explain how replay evaluation and interleaving help offline results predict online results.
  6. Serving. Give an end-to-end latency budget under 100 ms at p95 covering retrieval, feature fetch, and ranking. Explain how you keep features fresh when a streamer goes live and how embeddings are updated in near-real time.

State your scale assumptions up front and call out the main trade-offs.

Hints

Hint 1

Factor the objective into P(click) times P(watch 10+ min | click), and decide explicitly whether a broadcast that ends early counts as a negative or as a censored example.

Hint 2

Separate what changes slowly (long-term user and creator embeddings, refreshed daily) from what must be live (viewer count velocity, category, session embedding), and place each in a store matching its freshness need.

Hint 3

Log the position and the probability with which each item was shown. Without logged propensities you cannot do IPS or doubly robust estimation, and exploration will not be evaluable.

Hint 4

Write the latency budget as a table of stages that sum to well under 100 ms, with the candidate set kept small enough (hundreds, not thousands) for the ranker to fit its slice.