The Algorithm That Powers Your X (Twitter) Post

· Source: ByteByteGo Newsletter · Field: Technology & Digital — Artificial Intelligence & Machine Learning, Software Development & Engineering · Depth: Intermediate, medium

Summary

The xAI engineering team has open-sourced the algorithm powering the "For You" feed on X (formerly Twitter) under an Apache-2.0 license, revealing a real-time recommendation system built primarily on a Grok-based transformer model. This system replaces most hand-crafted rules with machine learning to minimize latency and enhance user satisfaction. The architecture comprises four core components: Mixer, Thunder, Phoenix, and the Candidate Pipeline. Mixer orchestrates the process, Thunder provides in-network content from an in-memory store, and Phoenix, the ML brain, handles out-of-network content retrieval via a two-tower model and ranks all candidates using a Grok-based transformer. The Candidate Pipeline offers a modular framework for managing the entire recommendation workflow, from fetching user context and candidate posts to filtering, scoring, and final selection, with the codebase written in Rust (62.9%) and Python (37.1%).

Key takeaway

For AI Engineers building high-scale, real-time recommendation systems, studying X's open-sourced algorithm offers valuable architectural insights. You should consider adopting a Grok-based transformer for nuanced multi-action prediction and a modular pipeline design to simplify future model and data source integrations, ensuring consistent scores and low latency at scale.

Key insights

X's open-sourced recommendation system uses a Grok-based transformer for real-time, ML-driven content ranking.

Principles

Method

The system retrieves in-network posts from an in-memory store and out-of-network posts via a two-tower embedding model, then ranks merged candidates using a Grok-based transformer that predicts multiple user engagement probabilities.

In practice

Topics

Code references

Best for: AI Engineer, Machine Learning Engineer, MLOps Engineer

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by ByteByteGo Newsletter.