x-algorithm: The Death of the Feature Factory
How X replaced thousands of hand-engineered heuristics with a single Grok-based Transformer to power the global For You feed.
- X replaced thousands of manually defined heuristics with a single Grok-based Transformer to determine content relevance.
- The Phoenix component treats a user's engagement history as a sequence to predict the specific probability of actions like likes and retweets.
- A high-throughput Rust microservice orchestrates the entire recommendation funnel in under 200 milliseconds.
- The system uses an asynchronous feedback loop to train models on posts that users viewed but chose to ignore.
The End of the Heuristic
Traditional recommendation engines are factories. Thousands of engineers spend their days manually defining what matters. They write rules to check if a post contains a video, if the user likes sports, or if the author is verified. These hand-engineered features accumulate over years, creating a fragile web of technical debt.
The x-algorithm repository represents a radical departure from this model. By open-sourcing the engine behind the X timeline, the engineering team revealed that they deleted the human element. They replaced the manual labor force of heuristics with a single Grok-based Transformer.
We have eliminated every single hand-engineered feature and most heuristics from the system. The Grok-based transformer does all the heavy lifting by understanding your engagement history (what you liked, replied to, shared, etc.) and using that to determine what content is relevant to you.
| Architecture | The Feature Factory (Old) | The Raw Data Transformer (New) |
|---|---|---|
| Signal Generation | 1000+ manual heuristics | Zero manual signals |
| Core Tech Stack | Scala / JVM | Rust / JAX |
| Model Type | MaskNet / Gradient Boosted Trees | Grok-based Transformer |
| Maintenance | High manual tuning required | Self-learning via engagement logs |
200 Milliseconds to Relevance
The system orchestrates a massive funnel in under 200 milliseconds. It starts with millions of posts and ends with the 100 items on your screen. This orchestration is managed by the Home Mixer, a high-throughput microservice built entirely in Rust.
When a request arrives, the Home Mixer concurrently fetches candidates from two sources. Thunder provides in-network content from accounts you follow. Phoenix fetches out-of-network content using approximate nearest neighbor search. Both streams are merged, hydrated with metadata, and sent to the scoring engine.
Phoenix: The Grok-Powered Brain
The intelligence of the system lives in Phoenix. This component abandons the traditional Wide and Deep models for a JAX and Haiku implementation of the Grok-1 architecture. The system treats a user's engagement history as a sequence, much like an LLM treats a prompt.
The model outputs a granular vector of probabilities. It does not generate a single arbitrary score. Instead, it predicts the exact likelihood of specific actions: favorite, reply, retweet, and even dwell time. A weighted scorer then collapses these probabilities into a final ranking based on business logic.
The Rust Plumbing
X abandoned Scala for Rust to handle the sheer volume of concurrent network requests. The orchestration logic is built around a generic candidate pipeline framework. This uses Rust traits to define distinct stages: Source, Hydrate, Filter, Score, and Select.
This trait-based approach allows engineers to swap entirely different retrieval models without touching the core routing logic. It strictly separates the high-concurrency plumbing from the Python-based machine learning intelligence.
Closing the Loop
A recommendation engine is only as good as its feedback loop. The x-algorithm relies heavily on a decoupled side effect architecture. Once a feed is successfully served to a user, a background Rust worker logs the exact post IDs shown into a high-performance cache called Strato.
This ensures the model knows what you scrolled past without engaging. By capturing this residue asynchronously, the system trains tomorrow's model on today's implicit dismissals, all without adding a single millisecond of latency to the user's feed.