Building a Recommendation Engine for New Users and Fresh Content
Machine LearningModel answerLast updated
Design a video recommendation system that handles users with no history and videos with no engagement data while meeting strict latency requirements.
Problem: Recommendation System for New Users and Content
You're building a recommendation service for a short-form video platform entering a new market vertical. The system faces two fundamental challenges: a large fraction of users arrive with zero interaction history, and you continuously ingest fresh videos that have never been shown to anyone.
System Requirements
Functional goals:
- Deliver personalized video recommendations for each user session, regardless of historical data availability
- Support both brand-new users (no profile) and established users viewing new content
Performance constraints:
- Response time: under 200ms per request
- New videos must become recommendable within minutes of upload
- User feedback from the current session should influence recommendations immediately (next page load)
Scale parameters:
- 10 million daily active users
- 50,000 video uploads per day
- Typical user generates 5 sessions daily with ~10 recommendation requests per session
Design Components to Address
Your design should cover:
-
Candidate retrieval: How do you find relevant videos when you can't use "users who watched X also watched Y" signals?
-
Feature representation: What attributes can you extract from videos and users to measure relevance when interaction data is sparse or missing?
-
Scoring and ranking: How do you balance showing proven high-quality content against giving new uploads a chance to find their audience?
-
Real-time learning: How do you use the first few interactions in a session to adjust recommendations before the session ends?
Describe your architecture at a systems level and discuss the trade-offs between response speed, recommendation quality, and implementation complexity.
Hints
Hint 1
Consider what you can learn about a video from its content alone—visual features, audio, text metadata—before anyone watches it
Hint 2
For new users, think about what weak signals you have: device type, location, signup source, or topics they selected during onboarding
Hint 3
Exploration isn't random guessing—you can use content similarity to make educated guesses about what a new video's engagement rate will be
Hint 4
Session state can be maintained in a fast in-memory store and used to re-query your retrieval system without waiting for model retraining
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
Model Answer: Building a Cold-Start Recommendation System
Understanding the Scale
First, translate requirements into concrete numbers:
- Request volume: 10M users × 5 sessions × 10 requests = 500M requests/day, roughly 6,000 QPS average, peaking near 18,000 QPS
- Content ingestion: 50K videos/day ≈ 0.6 videos/second on average, with occasional bursts
- Active catalog: Keeping 30 days of content means ~1.5M videos in the active pool
- Latency breakdown: With a 200ms budget, allocate roughly 40ms for candidate retrieval, 25ms for feature loading, 80ms for ranking, 20ms for final re-ranking, and reserve the rest for network overhead
Primary objective: Maximize long-term engagement metrics (watch time, return rate). Secondary goals include giving new content fair exposure and maintaining diversity.
API Design
GET /recommendations
?user_id=<id>&session_id=<id>&page_token=<cursor>&limit=10
→ { request_id, videos: [...], next_page_token }
POST /track
body: [{ request_id, video_id, event_type, watch_duration_ms, timestamp }]
event_type: impression | start | skip | complete | like | share
The client prefetches the next page when scrolling reaches ~70% to hide latency.
Data Modeling
Video record:
- Identifiers and metadata: video_id, creator_id, upload_timestamp, duration, language
- Content representations: visual_embedding, audio_embedding, text_embedding (from title, captions, transcription)
- Derived scores: quality_score, safety_classification
- Engagement state: view_count, completion_rate, lifecycle_stage (cold/warming/established)
- Bandit parameters: prior_mean, posterior_alpha, posterior_beta
User record:
- Basic: user_id, registration_date
- Context: country, language, device_type, referral_source
- Cold-start signals: selected_interests (from onboarding), cohort_assignment
- Warm signals: user_embedding (null for new users), historical_preferences
Session state (in-memory cache, 90min TTL):
- session_embedding: aggregated representation of current interests
- interaction_history: recent video IDs and engagement signals
- seen_set: bloom filter to prevent repetition
Architecture Overview
Content ingestion pipeline:
- Uploaded video lands in object storage, triggers processing job
- Parallel feature extraction:
- Sample keyframes → visual encoder (CLIP-based model) → 512-dim embedding
- Audio extraction → audio encoder → 256-dim embedding
- Text extraction (title, description, speech-to-text) → language model → 384-dim embedding
- Safety classifier (NSFW, violence, etc.)
- Quality classifier (production value, clarity)
- Fusion network combines modality embeddings into unified 512-dim content vector
- Video metadata and embeddings written to feature store
- Content vector indexed in approximate nearest neighbor (ANN) service (HNSW algorithm supports incremental updates)
Serving pipeline:
- Request arrives with user_id and session_id
- Load user features and session state in parallel
- Run multiple candidate generators concurrently (see below), each returns 200-500 candidates
- Merge candidate pools to ~1,200 videos total
- Batch-fetch features for all candidates
- Ranking model scores all candidates
- Re-ranking layer applies exploration policy, diversity rules, deduplication
- Return top 10 with next-page cursor
Feedback loop:
- Client events stream to message queue (Kafka)
- Stream processor (Flink) performs multiple updates:
- Immediate (seconds): Update session state in cache
- Fast (1-2 minutes): Update per-video engagement counters and bandit posteriors in feature store
- Batch (hours/days): Write training samples for model retraining
Solving the Cold-Start Problem
Candidate generation without collaborative filtering:
Run these generators in parallel and allocate quota to each:
-
Content-based retrieval (40% quota): Use the session embedding or cohort centroid as query vector, retrieve nearest neighbors from video content embeddings via ANN search. The key: train a two-tower model on warm users, but apply embedding dropout during training—randomly zero out user/video ID embeddings to force the model to learn from content features alone.
-
Cohort popularity (25% quota): Maintain pre-computed "trending" lists segmented by (country, language, device_type, acquisition_channel). Refreshed every 5 minutes from recent engagement data. This provides strong baseline recommendations for brand-new users.
-
Interest-based retrieval (15% quota): If the user selected topics during onboarding, maintain topic→video mappings and retrieve top videos per selected topic.
-
Fresh content pool (10% quota): Stratified sample from videos uploaded in the last 24 hours that passed safety checks. Ensures new content gets initial exposure.
-
Creator expansion (10% quota): If the session shows interest in certain creators, retrieve content from similar creators based on creator embeddings (learned from follower overlap and content similarity).
Feature engineering:
Video features:
- Content embeddings (visual, audio, text)
- Metadata: duration, language, upload_timestamp, category
- Creator signals: creator's historical completion rate, follower count (warm signal attached to cold item)
- Quality and safety scores
- Age of video (hours since upload)
- Smoothed engagement metrics: use content-based prior with Bayesian updating
User features:
- Contextual: country, language, device, time_of_day, acquisition_source
- Onboarding selections: chosen topics/interests
- Cohort embedding: for new users, use a learned mapping from context features to typical user preferences (train on warm users)
- Session state: current session embedding, interaction sequence
- Historical embedding: long-term user vector (null for new users)
Interaction features:
- Cosine similarity: session_embedding × video_content_embedding
- Topic overlap: user interests ∩ video topics
- Creator familiarity: has user seen this creator in session?
- Freshness: is this a newly uploaded video?
Ranking Model
Use a multi-objective neural network with shared layers and task-specific heads:
Architecture:
- Input: concatenate user features, video features, and interaction features
- Shared layers: 3-layer MLP (512→256→128 units)
- Task heads predicting:
- P(watch > 3 seconds)
- Expected watch fraction (regression)
- P(like or share)
- P(quick skip < 2 seconds)
Final score: Weighted combination, e.g., score = 0.4 × watch_fraction + 0.3 × P(engagement) - 0.3 × P(skip)
Handling cold items in the model:
- Video ID embeddings are gated:
embedding = w × id_emb + (1-w) × content_emb, wherew = min(1, impression_count / 100) - Cold videos rely primarily on content features; the model gradually incorporates ID-specific patterns as data accumulates
Exploration strategy:
Reserve 10-15% of recommendation slots for exploration using Thompson Sampling:
- Each cold video maintains a Beta distribution posterior over its completion rate
- Prior parameters initialized from content-based prediction: if content model predicts 45% completion, set prior as Beta(α=9, β=11) (pseudo-count ~20)
- For each exploration slot: sample from each candidate's posterior, multiply by relevance score, select highest
- After each impression, update posterior: Beta(α + completions, β + non-completions)
Guardrails:
- Minimum relevance threshold (cosine similarity > 0.3)
- Minimum quality score
- Reduce exploration for brand-new users (first session: 5% exploration, established users: 15%)
In-Session Personalization
After each interaction event, the stream processor updates session state:
Session embedding update:
For each video interaction:
weight = engagement_score(event_type, watch_fraction)
# Positive for completions/likes, negative for fast skips
session_emb = normalize(0.7 × session_emb + 0.3 × weight × video_emb)
Topic and creator tracking:
- Maintain counters for engaged topics and creators
- Use these to boost similar content in next retrieval
Latency: Session update takes ~10ms, next /recommendations call includes updated state automatically. User sees personalization after 3-5 interactions without any model retraining.
Optional enhancement: Add a lightweight sequence model (small Transformer) in the ranker that encodes the last 15-20 interactions to capture temporal patterns and ordering effects.
Trade-off Discussion
Latency vs. accuracy:
- Deeper models and cross-attention mechanisms improve ranking but risk exceeding 200ms
- Mitigation: limit candidates to 800 for ranking stage, use GPU inference with batching, pre-compute and cache item-tower outputs
Freshness vs. cost:
- Multimodal feature extraction requires GPU compute (~2-3 seconds per video)
- At 50K videos/day, this is manageable with ~10 GPU workers
- Real-time ANN index updates add complexity vs. rebuilding index every 5 minutes
- Justification: minute-level freshness requirement makes incremental updates worthwhile
Exploration vs. user experience:
- More exploration accelerates learning about new content but risks showing irrelevant videos
- Mitigate with content-based priors (educated guesses) and adaptive exploration rate
- New users get less exploration to avoid poor first impressions
Cold-start depth:
- Zero-history users see generic popular content; single-digit interactions enable personalization
- Three-click rule: by third interaction, recommendations should feel personalized
- Balance: use cohort trends as backbone, layer in light personalization signals
Common Pitfalls
- Over-exploring on new users: Hurts retention. Start conservative.
- Ignoring creator reputation: Even cold videos from established creators have predictable quality.
- Stale cohort definitions: Demographics shift; retrain cohort models weekly.
- Position bias in training data: Videos shown first get more clicks. Use position-aware loss or inverse propensity weighting.
- Neglecting diversity: Content-based retrieval can create filter bubbles. Inject explicit diversity constraints (limit per-creator, per-topic).
This architecture delivers sub-200ms recommendations while handling both new users and new content through content-based representations, cohort signals, and principled exploration strategies.