Katkat

Design a Music Recommendation System with an LLM Agent

GoogleSoftware Engineer · Technical Screen

Last updated

Design a large-scale music recommendation system combining traditional multi-stage ranking with an LLM agent for natural language intent parsing and contextual explanations.

Scenario

You are tasked with designing the recommendation backend for a global music streaming service (e.g., Google Play Music / YouTube Music). In addition to standard passive discovery feeds, the product team wants to introduce a conversational assistant that allows users to ask for music using nuanced prompts (e.g., "upbeat 80s synth-pop for a rainy morning workout") and receive personalized playlists alongside explanations.

Requirements

Functional Requirements

  • Multi-Stage Recommendation Pipeline: Retrieve and rank tracks tailored to user history, current context, and real-time session feedback.
  • Conversational & Intent Layer: Support free-form natural language queries to extract user intent, constraints (genre, era, tempo), and mood.
  • Explanations: Provide concise, personalized rationales for why specific songs or playlists were recommended.
  • Catalog & Safety Guardrails: Guarantee that recommended items exist in the catalog, adhere to licensing/regional rights, and avoid explicit content if restricted.
  • Feedback Loops & Cold Start: Adapt dynamically to skips, likes, and completions, while addressing cold starts for new users and fresh track releases.

Non-Functional Requirements & Scale

  • Scale: 100M daily active users (DAU), 100M+ tracks in the catalog.
  • Latency:
    • Standard passive home feed: p99 latency < 100ms.
    • Conversational recommendation: p95 latency < 800ms (streaming text allowed).
  • Throughput: ~50,000 queries per second (QPS) at peak for feed recommendations; ~2,000 QPS for conversational requests.

Key Areas to Cover

  1. High-Level Architecture: Detail the separation of concerns between candidate generation, heavy ranking, re-ranking/diversity, and the LLM agent.
  2. LLM Integration Strategy: How to use the LLM for query understanding (semantic parsing to structured filters/embeddings) vs. direct generation, preventing hallucinated tracks.
  3. Cold-Start & Diversity: Techniques for handling cold users/items and preventing filter bubbles.
  4. Feedback Loops & Offline/Online Evaluation: Metrics for measuring ranking quality, conversation satisfaction, and system performance.

Hints

Hint 1

Avoid having the LLM generate track IDs directly; instead, treat the LLM as an intent parser that emits structured filters or query vectors into your existing retrieval service.

Hint 2

Decouple candidate retrieval (two-tower models, graph-based embeddings) from the conversational agent to maintain strict latency and license validity constraints.

Hint 3

Use a lightweight post-ranking explanation step or cached template-filling mechanism rather than running an LLM call per individual recommended track.

Follow-up questions

  • How would you prevent popular artists from dominating the recommendations while still honoring user intent?
  • If an LLM query requires rare or long-tail attributes (e.g., 'ambient drone with cello'), how do you index and retrieve songs that lack formal metadata tags?
  • How do you detect and mitigate negative feedback loops where a user accidentally trains the model into a hyper-narrow niche?