惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
The GitHub Blog
The GitHub Blog
博客园_首页
T
The Blog of Author Tim Ferriss
H
Hackread – Cybersecurity News, Data Breaches, AI and More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
腾讯CDC
I
InfoQ
量子位
J
Java Code Geeks
P
Proofpoint News Feed
有赞技术团队
有赞技术团队
Webroot Blog
Webroot Blog
Martin Fowler
Martin Fowler
D
Docker
F
Fortinet All Blogs
云风的 BLOG
云风的 BLOG
V
Vulnerabilities – Threatpost
罗磊的独立博客
P
Proofpoint News Feed
T
The Exploit Database - CXSecurity.com
Cyberwarzone
Cyberwarzone
P
Privacy & Cybersecurity Law Blog
Last Week in AI
Last Week in AI
爱范儿
爱范儿
The Hacker News
The Hacker News
S
SegmentFault 最新的问题
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
V
V2EX
Simon Willison's Weblog
Simon Willison's Weblog
AI
AI
Y
Y Combinator Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
GbyAI
GbyAI
V
Visual Studio Blog
H
Heimdal Security Blog
S
Secure Thoughts
B
Blog RSS Feed
雷峰网
雷峰网
T
Tenable Blog
C
Check Point Blog
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
A
About on SuperTechFans
Recent Commits to openclaw:main
Recent Commits to openclaw:main

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
X's Feed Ranking Algorithm: How Grok Ranks 500M Posts in 200ms
Ramsis Hamma · 2026-05-21 · via DEV Community

X's Feed Ranking Algorithm: How Grok Ranks 500M Posts in 200ms

TL;DR Summary

  • xAI open-sourced the full production code behind X's For You feed on GitHub — 22.5k stars, Apache 2.0, commercial use allowed
  • The system pulls from 500 million daily posts, narrows to candidates, and ranks them in under 200 milliseconds using a Grok-based transformer
  • Zero hand-engineered features — the Grok transformer predicts 14 engagement types (like, reply, repost, click, dwell, block, report) and combines them into a weighted score
  • Four components: Home Mixer (orchestration), Thunder (in-network, sub-ms lookups), Phoenix (Grok transformer retrieval + ranking), Candidate Pipeline (reusable framework)
  • A pre-trained mini Phoenix model ships with the repo — run inference without training anything

Direct Answer Block

X's For You feed algorithm is a four-component recommendation system: Home Mixer orchestrates the pipeline, Thunder serves in-network posts from followed accounts at sub-millisecond speed, Phoenix uses a Grok-based transformer to retrieve out-of-network posts and rank all candidates by predicting 14 engagement probabilities, and the Candidate Pipeline provides a reusable, composable framework for the entire system.

Introduction

Open-sourcing a recommendation algorithm that serves hundreds of millions of users isn't just a transparency gesture — it's an architecture masterclass. X's system processes 500 million daily posts, narrows them to roughly 1,500 candidates, and ranks everything in under 200ms. The Grok-based transformer does all the heavy lifting with zero hand-engineered features. Every heuristic eliminated. Every manual weight removed. Here's how the pipeline actually works, component by component.

How does the X For You feed rank 500 million posts in under 200 milliseconds?

The system achieves this speed through a layered pipeline that progressively narrows the candidate set:

  1. Thunder serves in-network posts instantly — an in-memory post store with sub-millisecond lookups. Posts from accounts you follow are already indexed and retrievable without hitting any external database. Thunder consumes post create/delete events from Kafka and automatically trims posts older than the retention period.

  2. Phoenix Retrieval finds out-of-network candidates — a two-tower model encodes users and posts into embeddings, then retrieves top-K candidates via dot product similarity across the global corpus. This ML-based search discovers content from accounts you don't follow.

  3. Pre-scoring filters eliminate ineligible candidates — duplicates, old posts, self-posts, blocked/muted accounts, previously seen/served posts, muted keywords, and paywalled content are removed before the expensive transformer inference runs.

  4. Phoenix Ranking scores remaining candidates — the Grok-based transformer predicts 14 engagement probabilities for each post. The Weighted Scorer combines them into a final score.

  5. Selection picks the top K — sorted by final score, with author diversity attenuation to prevent feed monopolization.

"We have eliminated every single hand-engineered feature and most heuristics from the system. The Grok-based transformer does all the heavy lifting." — xAI, from the repository README

The 200ms target is achieved because the expensive ML inference (transformer ranking) runs only on the already-filtered candidate set — roughly 1,500 posts — not on the 500 million raw corpus.

What are the four components — Home Mixer, Thunder, Phoenix, and Candidate Pipeline — and how do they fit together?

Four cards describing each component: Home Mixer (orchestration, gRPC), Thunder (in-memory post store, Kafka ingestion), Phoenix (retrieval + ranking transformer), Candidate Pipeline (reusable framework).

Home Mixer (Orchestration Layer)

The entry point. Exposes a gRPC endpoint (ScoredPostsService) that returns ranked posts for a given user. It leverages the Candidate Pipeline framework with 8 stages: Query Hydrators → Sources → Hydrators → Filters → Scorers → Selector → Post-Selection Filters → Side Effects.

The May 15th, 2026 update added query hydrators for user context including followed topics, starter packs, impression bloom filters, IP, mutual follow graphs, and served history.

Thunder (In-Network Post Store)

An in-memory post store that tracks recent posts from all users. Written in Rust. It consumes post create/delete events from Kafka, maintains per-user stores for original posts, replies/reposts, and video posts, and serves in-network candidates from accounts the requesting user follows.

The key performance characteristic: sub-millisecond lookups without hitting an external database. Posts are trimmed automatically after the retention period. This design eliminates the database bottleneck that would make 200ms impossible at X's scale.

Phoenix (Grok Transformer — Retrieval + Ranking)

The ML component with two distinct functions:

Retrieval (Two-Tower Model): The User Tower encodes user features and engagement history into an embedding. The Candidate Tower encodes all posts into embeddings. Similarity search retrieves the top-K posts via dot product.

Ranking (Transformer with Candidate Isolation): Takes user context (engagement history) and candidate posts as input. Uses special attention masking so candidates cannot attend to each other — they can only attend to user context. This ensures a post's score doesn't depend on which other posts are in the batch, making scores consistent and cacheable.

Candidate Pipeline (Reusable Framework)

A Rust trait-based framework defining six traits: Source, Hydrator, Filter, Scorer, Selector, and SideEffect. Sources and hydrators run in parallel where possible, with configurable error handling. This makes the pipeline composable — new candidate sources, filters, or scorers can be added without modifying the framework.

How does the Grok-based Phoenix transformer predict 14 different engagement types and combine them into a single score?

Instead of predicting a single "relevance" score, Phoenix predicts probabilities for 14 distinct actions:

Action Type
favorite, reply, repost, quote, click, profile_click, video_view, photo_expand, share, dwell, follow_author Positive
not_interested, block_author, mute_author, report Negative

The Weighted Scorer combines these into:

Final Score = Σ (weight_i × P(action_i))

Enter fullscreen mode Exit fullscreen mode

Positive actions carry positive weights. Negative actions carry negative weights — pushing down content the user would likely dislike. This multi-action approach is more nuanced than a single relevance score because it captures how a user engages, not just whether they engage.

The transformer implementation is ported from the Grok-1 open source release by xAI, adapted for recommendation system use cases. It uses hash-based embeddings for both retrieval and ranking lookups.

"Rather than predicting a single 'relevance' score, the model predicts probabilities for many actions." — xAI, from the repository README

How does Phoenix's candidate isolation mechanism prevent posts from influencing each other's rankings?

Candidate isolation is one of the five key design decisions highlighted in the repository. During transformer inference, candidates use special attention masking so they cannot attend to each other — only to the user context.

This achieves two critical properties:

  1. Score consistency — a post's score doesn't change based on which other posts happen to be in the same batch. The same post gets the same score whether it's ranked against 10 candidates or 1,500.

  2. Score cacheability — because scores don't depend on batch composition, they can be pre-computed and cached. This is essential for the 200ms latency target at X's scale.

Without candidate isolation, the ranking would exhibit a listwise dependency — a post's score would shift depending on what else was in the ranking pool, making caching impossible and inference costs unpredictable.

The attention mask achieves this by allowing each candidate to attend to the user context sequence but blocking cross-attention between candidates. The transformer still encodes all candidates in a single forward pass (for efficiency), but the attention pattern is constrained to prevent batch composition effects.

Why did xAI eliminate every hand-engineered feature — and what does the transformer learn instead?

X New Approach: No hand-engineered features

Traditional recommendation systems rely heavily on hand-engineered features: text features, author popularity, recency boosts, content category matching, engagement velocity heuristics. Each feature requires engineering effort, A/B testing, and maintenance as user behavior shifts.

xAI's approach replaces all of that with a single principle: let the transformer learn relevance from user engagement sequences.

The transformer takes as input:

  • User's recent engagement history (what they liked, replied to, shared, clicked)
  • Candidate post content and metadata
  • User features (following list, preferences)

From this raw data, it learns to predict the 14 engagement probabilities. No engineer needs to define a "recency weight" or "author popularity multiplier" — the model discovers these patterns from the data.

The benefit, according to the repository: "This significantly reduces the complexity in our data pipelines and serving infrastructure." Features that previously required dedicated data pipelines, feature stores, and serving infrastructure are now learned implicitly by the transformer.

The Author Diversity Scorer is one of the few post-transformer adjustments — it attenuates scores for repeated authors to prevent the feed from being dominated by a single account. This isn't a hand-engineered relevance feature; it's a diversity constraint applied after ML scoring.

What can developers learn from X's composable pipeline architecture and in-memory post store design?

Three architectural lessons stand out:

1. Trait-based pipeline composition

The Candidate Pipeline framework defines six traits (Source, Hydrator, Filter, Scorer, Selector, SideEffect) that new pipeline stages implement. This separates pipeline execution and monitoring from business logic. New candidate sources, filters, or scorers can be added by implementing the relevant trait — no pipeline code changes needed.

2. In-memory serving for latency-critical paths

Thunder demonstrates that at planet scale, the fastest database query is no database query. By keeping recent posts in memory, consuming from Kafka for updates, and trimming old data automatically, Thunder achieves sub-millisecond lookups without any external storage dependency. This pattern is applicable to any system where the working set fits in memory and freshness matters.

3. Parallel execution where independent

The framework runs sources and hydrators in parallel where possible. This isn't just about speed — it's about keeping the GPU pipeline fed during the expensive transformer inference step. If hydration is slow, the GPU sits idle. Parallel execution minimizes idle time.

The repository includes a pre-trained mini Phoenix model (256-dim embeddings, 4 attention heads, 2 transformer layers, ~3 GB) distributed via Git LFS, enabling out-of-the-box inference without training. This makes the system accessible for experimentation and learning — you can study how a production recommendation system works without needing X's training infrastructure.

Frequently Asked Questions

Q: Can I use X's ranking algorithm in a commercial product?

Yes. The repository is licensed under Apache 2.0, which permits commercial use, modification, and distribution. The Grok-1 model weights are separate and have their own license.

Q: What languages is the system written in?

The Candidate Pipeline, Thunder, and Home Mixer are written in Rust (57.4% of the repo). Phoenix (the ML component) is written in Python (42.6%). The Grok-based transformer was ported from xAI's Grok-1 open source release.

Q: Does the repo include training data or only inference code?

The repo includes the inference pipeline and a pre-trained mini Phoenix model. Training data and the full production model weights are not included. This is common for recommendation system open-source releases — you get the architecture and inference code, not user data.

Q: How does this compare to Twitter's 2023 algorithm release?

Twitter's 2023 release was the precursor. xAI's release is a major update: the transformer was ported from Grok-1 (replacing the earlier ML model), all hand-engineered features were eliminated, and the system now includes ads blending, Grox content understanding (spam, classification, policy enforcement), and an end-to-end inference pipeline.

Q: Can I run the mini Phoenix model on my laptop?

Yes. The pre-trained mini model is ~3 GB and distributed via Git LFS. The phoenix/run_pipeline.py script provides a single entry point for retrieval → ranking inference from exported checkpoints.

Q: How often is the codebase updated?

The repository's README states code updates are "promised roughly every four weeks." The May 15th, 2026 update was the most recent at time of analysis, adding the end-to-end inference pipeline, pre-trained model artifacts, Grox content understanding, ads blending, and expanded hydrators/sources.

Glossary

  • Home Mixer: The orchestration layer that assembles the For You feed — handles query hydration, candidate sourcing, filtering, scoring, and selection
  • Thunder: An in-memory post store serving in-network content (posts from followed accounts) at sub-millisecond speeds
  • Phoenix: The Grok-based ML component handling out-of-network retrieval (two-tower model) and candidate ranking (transformer with 14 engagement predictions)
  • Candidate Pipeline: A reusable Rust trait-based framework for building recommendation pipelines with Source, Hydrator, Filter, Scorer, Selector, and SideEffect traits
  • Candidate isolation: An attention masking technique ensuring candidates cannot attend to each other during transformer inference — only to user context — making scores consistent and cacheable
  • Multi-action prediction: Predicting 14 engagement probabilities (like, reply, repost, click, block, report, etc.) rather than a single relevance score

Author

Ramsis Hammadi — AI/ML engineer specializing in GenAI, LLM engineering, and automation. Full bio →