X open-sources For You ranking pipeline with Phoenix transformer model
X published the code behind its For You feed algorithm on GitHub, exposing the Phoenix transformer model and the two-stage retrieval and ranking pipeline that powers recommendations.

X released the code behind its For You recommendation feed on GitHub this week, giving practitioners a rare look at how a major social platform assembles and ranks content at scale. The repository, xai-org/x-algorithm, includes the full pipeline from candidate selection through final ranking, with the Phoenix transformer model—built on Grok architecture—at the center of the scoring system.
The feed draws from two sources: posts from accounts a user follows and posts from the global corpus surfaced through machine-learning retrieval. Phoenix evaluates each candidate by predicting user actions—likes, replies, reposts, clicks, and other engagement signals—then combines those probabilities into a final score that determines what surfaces in the timeline.
What stands out
- 01Phoenix is a Grok-based transformer. The ranking model shares architecture with X's Grok LLM, adapted for engagement prediction rather than text generation. It outputs probabilities for multiple user actions simultaneously.
- 02Two-stage retrieval precedes ranking. The system first pulls candidates from the user's follow graph and a separate ML-powered global search, then Phoenix scores the merged set. This two-stage design is standard for large-scale recommendation but rarely documented in production code.
- 03Engagement signals are weighted explicitly. The repository exposes which actions contribute to the final score—likes, replies, reposts, clicks—and how they combine. Practitioners can trace exactly how a high-repost, low-like post might rank differently than the inverse.
- 04Content filtering happens before ranking. The pipeline includes pre-ranking filters that remove certain content categories before Phoenix ever sees them. The code shows where those filters sit in the stack, though it does not detail every filter rule.