X's Open-Sourced Recsys: A Production Blueprint for Multi-Objective Ranking
Why This Matters Now
xAI released X's complete For You feed recommendation system under Apache-2.0 — not a research demo, but the production system serving hundreds of millions of users. This is the most detailed open-source recommendation architecture since Twitter's 2023 release, and the key evolution is that a Grok-based transformer has replaced nearly all hand-crafted ranking rules with end-to-end ML.
Architecture Deep Dive
The system is organized into four components: Home Mixer (orchestration via gRPC), Thunder (in-memory post store with Kafka ingestion and sub-millisecond reads), Phoenix (ML retrieval + ranking), and a modular Candidate Pipeline framework. The codebase is 62.9% Rust, 37.1% Python — Rust handles serving and pipeline orchestration, Python handles model training.
The Multi-Objective Scoring Pattern
The ranking model predicts probabilities for 15+ distinct user actions — likes, replies, reposts, shares, follows, video watches, profile visits, plus negative signals like blocks, mutes, reports, and "not interested." The final score is a weighted linear combination: Score = Σ(weight_i × P(action_i)).
This decouples model training from product policy — you retrain to improve prediction accuracy, but tune weights to change feed character. Want less outrage? Increase the negative weight on "report" predictions. No retraining required.
The Attention Masking Trick
Each candidate post can only attend to the user's context — not to other candidates in the batch. This sacrifices cross-item modeling for two critical properties: deterministic scores (independent of batch composition) and cacheability per (user_context, candidate) pair. The diversity loss is compensated by a downstream Author Diversity Scorer. At X's scale, this is a massive latency and compute win.
Retrieval Architecture
Phoenix uses a two-tower model with dot-product similarity and multiple hash functions for embedding lookup. Thunder provides in-memory candidate sourcing with TTL-based retention and per-user partitions for posts, replies, reposts, and video.
What's Missing
There are no evaluation metrics, no A/B test results, no ablation studies, and no model size disclosures. We don't know the embedding dimensions, the actual weight values (arguably the most important parameters), or whether the Grok transformer outperforms a well-tuned gradient-boosted model. Treat this as an architecture reference, not a performance benchmark.
What to do
Clone the xAI recommendation repo and audit the Phoenix scoring module — specifically the multi-action prediction heads and weight configuration
Add 2-3 negative engagement prediction heads (block, mute, 'not interested') to your existing ranker by end of sprint
Implement attention masking in your transformer ranker to make scores independent of batch composition