Ranking Systems
X’s recommendation pipeline uses a two-stage ranking architecture to efficiently score millions of candidates and select the most relevant content for users. This approach balances computational efficiency with prediction accuracy.Overview
The ranking system consists of two complementary models:Light Ranker
Fast, lightweight model that pre-filters candidates from the search index. Reduces millions of candidates to thousands.
Heavy Ranker
Sophisticated neural network that performs detailed scoring on the filtered candidates. Produces final ranking scores.
Two-Stage Ranking Architecture
Light Ranker
The light ranker is a lightweight ML model integrated directly into the Earlybird search index. It performs rapid scoring during candidate retrieval.Architecture
- Purpose
- Features
- Model
Objective: Pre-filter candidates from millions to thousands
- Runs in-index during search query execution
- Optimized for low latency (sub-millisecond per candidate)
- Uses limited features available in the search index
- Trained using TWML framework (TensorFlow v1)
Training Process
The light ranker is trained using the TWML framework:Feature Engineering
Extract features available in search index:
- Static tweet metadata
- Author statistics
- Early engagement metrics
- User-author graph signals
Integration with Earlybird
The light ranker runs inside the Earlybird search index:Performance Characteristics
Latency
Sub-millisecond scoring per candidate, enabling real-time search
Throughput
Scores millions of candidates per second across search fleet
Selectivity
Reduces ~1M candidates to ~2-5K for downstream processing
Accuracy
High recall (keeps most relevant candidates) with good precision
Heavy Ranker
The heavy ranker is a sophisticated neural network that performs detailed scoring on candidates that pass the light ranker.Architecture
- Purpose
- Features
- Model
Objective: Final ranking with maximum accuracy
- Runs out-of-index as a separate service
- Uses ~6000 features from multiple sources
- Employs deep neural networks for complex patterns
- Trained using PyTorch framework
- Multi-task learning for various engagement objectives
Training Process
The heavy ranker uses modern deep learning techniques:Integration with Home Mixer
The heavy ranker is called from Home Mixer’s scoring pipeline:Performance Characteristics
Latency
10-50ms per batch of candidates (depends on batch size)
Throughput
Thousands of candidates scored per second per instance
Accuracy
State-of-the-art engagement prediction with multi-task learning
Features
~6000 features from diverse sources for rich representation
Push Notifications Ranking
The push notification system uses a similar two-stage architecture:Light Ranker (Pushservice)
Pre-Rank Filtering
Located in:
pushservice/src/main/python/models/light_ranking/Purpose: Bridge candidate generation and heavy ranking by pre-selecting highly-relevant candidates- Lightweight RPC calls for filtering
- Reduces candidate pool before expensive heavy ranking
- Fast decision making for real-time notifications
Heavy Ranker (Pushservice)
Final Ranking
Located in:
pushservice/src/main/python/models/heavy_ranking/Purpose: Multi-task learning model for final notification selectionPredictions:- Probability user will open the notification
- Probability user will engage with the content
- Combined score for notification prioritization
Ranking Pipeline Comparison
| Aspect | Light Ranker | Heavy Ranker |
|---|---|---|
| Location | In-index (Earlybird) | Separate service (Navi) |
| Features | ~100-200 | ~6000 |
| Model Size | Small (MBs) | Large (GBs) |
| Latency | Under 1ms per candidate | 10-50ms per batch |
| Framework | TWML (TensorFlow v1) | PyTorch |
| Architecture | Shallow MLP | Deep multi-task network |
| Purpose | Candidate pre-filtering | Final ranking |
| Candidates In | ~Millions | ~Thousands |
| Candidates Out | ~Thousands | ~Hundreds |
Learn More
TWML Framework
Learn about the framework used to train light ranker models
Navi ML Serving
Understand how heavy ranker models are served in production
Candidate Generation
Explore how candidates are sourced before ranking
Product Mixer
See how ranking integrates into the full pipeline