The Candidate Generation Stage: How Social Media Feeds Filter Billions of Posts Down to Hundreds in Milliseconds
Before complex AI models rank a social media feed, a lightweight retrieval layer discards 99.9% of available posts in under 100 milliseconds. This candidate generation phase dictates what users ultimately see, trading deep personalization for raw computational speed.
By Tariq Nasser
- Platform Engineers
- Argue that strict latency budgets require lightweight candidate generation to keep systems responsive and online.
- Algorithmic Fairness Researchers
- Contend that early-stage filtering bakes in historical bias that downstream ranking models cannot fix.
- Infrastructure Architects
- Focus on the hardware and memory constraints that limit how much intelligence can be pushed into the retrieval layer.
Perspectives this story doesn't cover
- Independent Content Creators
- End Users
Common questions
What is candidate generation?
It is the first stage of a recommendation system that quickly filters billions of posts down to a few hundred using lightweight algorithms.
Why doesn't the system rank everything?
Evaluating billions of posts with heavy AI models would take too long, causing the app to lag and violating strict latency budgets.
How does this stage introduce bias?
Because it relies on simple historical data to operate quickly, it tends to retrieve already-popular content, ignoring niche or newer posts.
The short answer
- Candidate generation filters billions of posts down to hundreds in under 100 milliseconds.
- This initial layer discards over 99.9% of available content before heavy ranking models are applied.
- Strict latency budgets force platforms to use lightweight heuristics that favor historical engagement.
- Researchers warn that this speed-optimized retrieval stage bakes in dataset bias early in the funnel.
Platform engineers argue that filtering billions of daily posts down to a few hundred in under 100 milliseconds requires ruthless, lightweight heuristics that prioritize historical engagement to keep systems online. Conversely, algorithmic fairness researchers contend that this exact speed-optimized retrieval stage permanently narrows a user's worldview, baking in dataset bias before the heavily scrutinized ranking models even see the content.[7]
The tension centers on a phase of machine learning known as candidate generation. When a user opens an app like Instagram or TikTok, the platform does not evaluate every available piece of content. Instead, a fast, computationally cheap layer acts as a funnel, discarding over 99.9 percent of the inventory instantly.[5]
While public debate focuses on the heavy ranking algorithms that order the final feed, those models only score the 500 to 1,000 posts that survive the initial retrieval cut. The candidate generation stage is where the actual boundaries of a user's digital environment are drawn, operating entirely behind the scenes.[5]
To understand the scale, consider TikTok's architecture. The platform ingests millions of new videos daily. According to a 2023 architectural breakdown by the AiEdge Newsletter, TikTok's recommender system relies on a multi-funnel approach where the first layer relies on collaborative filtering and user tags rather than deep video analysis.[4]
This initial layer must operate within a strict latency budget. If the retrieval takes longer than a few hundred milliseconds, the user experiences lag and closes the app. Consequently, the system uses approximate nearest neighbor searches to find clusters of content similar to what the user previously liked, sacrificing precision for raw speed.[4]
Twitter's engineering team detailed this exact trade-off in their 2023 preprint on the TwERC (Twitter Ensembled Retrieval for Candidates) framework. The system was designed to handle ads recommendation by ensembling multiple lightweight models, ensuring that the candidate pool was generated without exceeding the strict latency constraints of real-time bidding.[1]
By using ensembled heuristics, Twitter's architecture could process massive query volumes, but it inherently favored candidates that matched established historical patterns over novel or niche content. The system prioritized surviving the throughput over deep contextual relevance.[1]
The system prioritized surviving the throughput over deep contextual relevance.
This reliance on historical patterns introduces the core vulnerability of the retrieval stage: dataset bias. A 2021 study by Twitter researchers on model-based candidate generation found that because these lightweight models are trained on past user interactions, they disproportionately retrieve items that were already popular or heavily promoted.[3]
The researchers discovered that addressing this bias at the ranking stage is mathematically impossible if the diverse candidates are never retrieved in the first place. If the candidate generator only passes forward viral posts, the most sophisticated ranking algorithm in the world can only choose the best among a biased sample.[3]
Instagram faces a similar architectural reality. A December 2025 analysis by Brainforge outlined how Instagram uses AI to rank feeds, noting that the platform actually runs multiple distinct candidate generation pipelines simultaneously—one for accounts the user follows, one for hashtags they engage with, and one for predictive discovery.[2]
These parallel pipelines attempt to inject diversity into the candidate pool before the heavy ranking model takes over. By sourcing 100 posts from followed accounts and 100 from exploratory clusters, Instagram's system forces the final ranking algorithm to evaluate a mixed batch, mitigating some of the echo-chamber effects inherent to pure collaborative filtering.[2]
However, the underlying mechanics remain bound by the 100-millisecond limit. Engineer Lee Han Chung's 2020 breakdown of the TikTok algorithm highlighted that the platform's early success stemmed from its aggressive tagging system, which allowed the candidate generator to match user profiles to video metadata almost instantly, bypassing the need for complex real-time inference.[6]
The industry is now attempting to push more intelligence down into the retrieval layer without breaking the latency budget. Two-tower neural networks, where user and item embeddings are pre-computed and stored in memory, allow platforms to perform complex matching via simple dot-product calculations during the actual retrieval request.[5]
Yet, as platforms deploy these two-tower models, they encounter the limits of hardware memory. Storing billions of high-dimensional embeddings requires massive distributed caching systems, shifting the bottleneck from compute latency to network bandwidth and memory capacity.[4]
The next verifiable checkpoint for recommender systems will emerge as hardware accelerators specifically designed for approximate nearest neighbor searches reach data centers. Until those chips deploy at scale, platforms will continue to balance the diversity of their feeds against the hard physics of retrieving a thousand posts in a tenth of a second.[7]
Jargon, explained
- Candidate Generation
- The initial filtering phase that retrieves a small subset of relevant items from a massive database.
- Latency Budget
- The strict time limit (usually milliseconds) a system has to return results before the user experiences lag.
- Two-Tower Model
- A neural network architecture that separately processes user data and item data to quickly calculate their similarity.
- Approximate Nearest Neighbor (ANN)
- A search algorithm that trades perfect accuracy for speed to quickly find similar items in large datasets.
Sources
[1]arXivAlgorithmic Fairness ResearchersTwERC: High Performance Ensembled Candidate Generation for Ads Recommendation at Twitter
Read on arXiv →
[2]Brainforge BlogInfrastructure ArchitectsHow Instagram Uses AI to Rank Your Feed
Read on Brainforge Blog →
[3]arXivAlgorithmic Fairness ResearchersLessons Learned Addressing Dataset Bias in Model-Based Candidate Generation at Twitter
Read on arXiv →
[4]SubstackPlatform EngineersDeep Dive: How to Build the TikTok Recommender System End-to-End!
Read on Substack →
[5]MediumPlatform EngineersDesigning a Newsfeed Ranking System: How Social Media Decides What You See
Read on Medium →
[6]Han, Not SoloInfrastructure ArchitectsHow Tik-Tok Wins The Social Media Recommendation System War
Read on Han, Not Solo →
[7]Factlen Editorial TeamAlgorithmic Fairness ResearchersSynthesis by Factlen editorial team
Read on Factlen Editorial Team →
Comments
More in Technology
See all →Cloud Economics
The Mechanics of Cloud Egress Fees: Why Data Gravity Traps Enterprise Workloads
6 sources
Differential Privacy
The Epsilon Parameter: How the Noise Budget Quantifies the Privacy-Utility Trade-off in Differential Privacy
8 sources
AI Alignment
The Orthogonality Thesis: Why Optimization Power Does Not Guarantee Moral Convergence in AI
8 sources
Engineering Metrics
How DORA Metrics Quantify Software Engineering Performance Without Tracking Individual Output
7 sources
Every angle. Every day.
Get Technology stories with full source coverage and perspective breakdowns delivered to your inbox.



