KatInterview

Scoring Song Impressions: A Click Model for a Music Feed

Machine LearningModel answer
MediumModel answerMachine Learningctr-predictionrecommendationembeddings

Last updated

Design a model that estimates the chance a user clicks a recommended track, covering song representation, sparse feature handling, algorithm choice, calibration, and offline and online evaluation.

A music streaming app shows users recommended songs. You need to build a model that, for a given user, candidate song, and display context (time, device, surface, position), outputs the probability that this impression leads to a click.

Assumptions

  • Candidate retrieval is out of scope. Another component supplies the songs, and your model only scores them.
  • Training data is a log of impressions. Each one has a binary label: whether a click occurred within a fixed attribution window.
  • The attribution window, the serving latency budget, and the available song metadata are not given. Ask about them.

Your answer should cover

  1. Clarifying questions you would ask and how the answers change your design.
  2. How you build labels and features without leaking information that would not exist at display time.
  3. How you represent songs, including new songs and songs with little history.
  4. How you handle extremely sparse features (high-cardinality IDs, rare categories, mostly missing values).
  5. Which algorithm(s) you would try, with a simple baseline and a stronger model, and the trade-offs.
  6. How you evaluate the predictions offline (probability quality and ranking) and online, including guardrails so that optimizing clicks does not hurt listening quality.

Hints

Hint 1

Start from the label and the prediction moment: every feature must be computable using only data available when the impression was shown, and validation splits should respect time.

Hint 2

For songs, combine a learned ID embedding with content-based vectors (metadata, audio, text), and think about what to fall back on when a song has almost no impressions.

Hint 3

For sparse features, think hashing or frequency thresholds, embeddings with regularization, and explicit missing indicators. Then decide how a model captures user-song interactions (logistic regression with crosses vs. factorization or deep models vs. gradient-boosted trees).

Hint 4

Separate two goals: ranking quality (AUC, NDCG) and probability quality (log loss, calibration curves). Mention position bias and what you would monitor online beyond CTR.