Katkat

Design a Sequential Personalized Playlist Recommender

SpotifyMachine Learning Engineer · Onsite

Last updated

This problem tests your ability to design a production-grade recommendation pipeline that balances immediate user intent (sequential context) with long-term personalization, while managing latency constraints at scale.

System Design: Sequential Playlist Recommender

Design a backend service that generates a personalized 10-track playlist for a user based on their recent listening session. The system must select 10 tracks from a candidate pool of 10,000.

Requirements

Functional Requirements:

  • Provide a list of 10 tracks that feel coherent as a sequence.
  • Update recommendations in real-time as the user skips or completes tracks.

Non-Functional Requirements:

  • Latency: P99 latency for retrieving the playlist should be under 200ms.
  • Scalability: Support 10 million daily active users.
  • Diversity: The playlist must not contain more than two tracks from the same artist.

Design Deliverables

  1. Candidate Retrieval & Ranking Architecture: Describe the stages of your pipeline (e.g., candidate generation, coarse ranking, sequential reranking).
  2. Feature Engineering: Discuss how you represent sequential context (e.g., last N songs played) and how you handle user-item interaction signals.
  3. Model Strategy: Propose a model architecture that captures sequential dependencies (e.g., Transformers, RNNs, or simple window-based features).
  4. Latency Strategy: Explain how you ensure the response stays within 200ms despite complex reranking logic.
  5. Evaluation: Define an offline metric (e.g., NDCG, Hit Rate) and an online metric (e.g., session duration, skip rate) for success.
  6. Bias & Fairness: How will you address popularity bias (giving every artist a fair chance) without sacrificing user experience?

Hints

Hint 1

Consider a multi-stage funnel: use a lightweight retrieval stage (e.g., approximate nearest neighbors) to reduce 10,000 items to 100, then a heavy reranker to order the final 10.

Hint 2

For sequence-awareness, incorporate stateful features like 'last 3 tracks' or 'current session duration' into your final reranking model.

Hint 3

To meet latency requirements, use a caching layer for popular candidate embeddings and pre-compute features for active users.

Follow-up questions

  • How would you handle a 'cold start' user who has no listening history?
  • If you detect the user is in a 'discovery' mode (skipping frequently), how would you adjust your ranking model's objective function?
  • How would you implement an A/B test to determine if your sequential reranking actually improves user retention?