
Meta products such as Facebook Feed, Instagram Feed, and Reels rely on recommendation systems to select and order content from a very large candidate set in real time. Interviewers ask this to assess whether you can translate a broad product problem into concrete algorithmic stages.
Walk through how a recommendation system for Facebook Feed might work from input signals to final ranked results. In your answer, address:
You do not need to derive a specific ML model, but you should explain the algorithmic pipeline clearly: retrieval, filtering, ranking, and post-processing. A strong answer connects data structures and algorithms—such as graph traversal, heaps for top-k selection, and sorting/reranking—to product goals and system constraints.
The system cannot score every possible post, so it first retrieves a manageable candidate set. This often uses graph-based expansion from friends, followed accounts, similar users, or similar content, plus lightweight heuristics to keep latency low.
candidates = set(friends_posts + followed_creator_posts + similar_user_posts)
Each candidate is represented by features such as user-author affinity, content freshness, predicted click probability, watch time, or likelihood of meaningful interaction. A ranking model combines these signals into a score used to order items.
score = 0.5 * affinity + 0.3 * engagement_prob + 0.2 * freshness
After scoring, the system usually needs only the best few items for the first screen. A heap is a common way to keep the top-k candidates efficiently without fully sorting a very large list.
import heapq
best = heapq.nlargest(k, scored_items, key=lambda x: x[1])
Pure score ordering is rarely enough because it can over-concentrate on one creator, topic, or content type. A reranking stage applies business and quality constraints such as diversity, integrity filters, and creator caps.
if creator_count[item.creator] < limit and item.safe:
result.append(item)
Recommendations improve by learning from impressions, clicks, likes, comments, hides, and dwell time. The system updates user representations and model features over time, balancing recent behavior with longer-term preferences.
user_profile[topic] += alpha * feedback_signal