X Algorithm Decoded: What Makes a Post Go Viral on X (Twitter)?
On May 15, 2026, Elon Musk and xAI open-sourced the complete recommendation algorithm of X (formerly Twitter) under the Apache 2.0 license. This is the most transparent move in the history of social media algorithms — for the first time, anyone can read the exact code that decides what you see in your "For You" feed.
Why This Matters: The Most Transparent Platform in Social Media History
For years, social media algorithms have been black boxes. Meta, TikTok, YouTube — all keep their recommendation systems secret. You can guess, theorize, and reverse-engineer, but you can never know.
X changed that.
On May 15, 2026, xAI pushed the complete source code of the X recommendation algorithm to GitHub. Not a summary, not a blog post describing the approach — the actual production code, written in Rust and Python, with Apache 2.0 license.
This is a watershed moment. Researchers, developers, and curious users can now read every line of code that determines which posts appear in billions of feeds. No more speculation. No more conspiracy theories. Just code.
We spent hours analyzing the repository. Here's what we found — both for everyday users who want to understand how to get seen, and for technical readers who want to understand the architecture.
Part 1: What the Algorithm Rewards (and Penalizes)
✅ Behaviors That Boost Your Reach
Based on the open-source code, here's what the X algorithm actively rewards:
1. Meaningful Replies and Conversations
The algorithm doesn't just count likes — it heavily weights reply chains. Posts that spark conversations (especially multi-turn threads) get significantly higher scores. The system tracks reply_score and quoted_reply_score as separate signals.
Practical tip: End your posts with a question or a thought-provoking statement. Encourage people to reply, not just like.
2. Video Watch Time (VQV — Video Quality View)
Not just "views" — the algorithm specifically tracks whether viewers watched a video past a minimum duration threshold. A 60-second video where people watch 3 seconds scores much lower than one where they watch 45 seconds.
Practical tip: Hook viewers in the first 3 seconds. Keep videos engaging throughout.
3. Shares (Especially via DM and Copy Link)
Shares are weighted more heavily than likes. The code tracks three types of shares separately:
- Direct shares (retweets)
- Shares via DM (private messages)
- Shares via copy link
Practical tip: Create content worth sharing privately — insights, humor, or useful information that people want to send to friends.
4. Dwell Time (Time Spent Reading)
The algorithm measures how long users spend on your post. Longer dwell time = higher score. This is tracked as dwell_score and cont_dwell_time_weight.
Practical tip: Write longer, more substantive threads. Carousels and multi-image posts naturally increase dwell time.
5. Follows Generated by Your Post
If someone follows you after reading your post, that's a strong positive signal: follow_author_score. The algorithm interprets this as "this content was so good, the reader wants more from this author."
Practical tip: Deliver consistent value. Make your profile worth following.
6. Quote Tweets
Quote tweets (quote_score) are weighted separately from simple retweets, suggesting the algorithm values adding your own perspective to someone else's content.
7. Posts from People You Follow
The Thunder module specifically retrieves posts from your social graph. Content from accounts you follow gets a natural boost.
❌ Behaviors That Hurt Your Reach
The algorithm has explicit negative signals that can severely reduce your visibility:
1. "Not Interested" Clicks
When users click "Not interested" on your posts (not_interested_score), the algorithm learns to show you less of that content. If many users do this, your reach drops dramatically.
2. Blocking and Muting
block_author_score and mute_author_score are strong negative signals. Being blocked or muted tells the algorithm your content is unwanted.
3. Reports
report_score is the strongest negative signal. Reported content gets deprioritized and may be filtered out entirely by the visibility filters.
4. Low Video Completion Rates
If people start watching your video but quickly scroll away, the VQV score drops. The algorithm interprets this as low-quality content.
5. Repetitive Content from the Same Author
The Author Diversity Scorer uses an exponential decay formula to prevent information cocoons. If you've already seen three posts from the same author, the fourth one gets a significantly reduced score.
Practical tip: Don't spam. Space out your posts and vary your content.
6. Content That Triggers Visibility Filters
The system has 17+ filters that can remove content entirely:
- Deleted posts
- Spam detection
- Violent/graphic content
- Sensitive media flags
- Rate limiting for new accounts
Part 2: Technical Deep Dive
Architecture Overview
The X recommendation system uses a Rust + Python hybrid architecture with five major modules:
1. Home Mixer (Rust — Orchestration Layer)
The central orchestrator that coordinates the entire pipeline. Provides two gRPC services:
ForYouFeedServer: Returns the final ranked feedScoredPostsServer: Returns scored posts for A/B testing
2. Thunder (Rust — Social Graph Retrieval)
Retrieves posts from your social connections (people you follow). Uses Kafka for real-time updates, ensuring you see new posts from followed accounts within seconds.
3. Phoenix (Python/JAX + Haiku — Interest Discovery)
The interest-based discovery engine with a two-tower architecture:
- Retrieval Tower: Finds potentially interesting posts from millions of candidates
- Scoring Tower: Uses a Grok-derived Transformer to predict engagement probability
This is the key innovation: replacing hand-crafted feature engineering with an end-to-end Transformer model.
4. Grox (Python — Multimodal Embeddings)
Generates 1024-dimensional embeddings for text, images, and videos in a unified space. This allows the system to understand and recommend content across all media types.
5. Candidate Pipeline (Rust — Trait-based Framework)
A flexible pipeline framework using Rust traits, supporting 11+ candidate sources including:
- Followed accounts
- Trending topics
- Explore recommendations
- Ad candidates
- Suggested accounts
The Scoring Algorithm: 19 Signals
The Phoenix Scorer predicts 19 engagement probabilities for each post:
Positive Signals (15):
- Like, Reply, Quote Reply, Retweet
- Video Quality View (VQV)
- Share, Share via DM, Share via Copy Link
- Dwell Score, Continuous Dwell Time
- Quote Tweet, Quoted Click
- Follow Author
Negative Signals (4):
- Not Interested
- Block Author
- Mute Author
- Report
Each signal is multiplied by a configurable weight, summed, and normalized. The weights are externally configurable, allowing X to adjust the algorithm without code changes.
Author Diversity: Preventing Information Cocoons
A critical design feature: the Author Diversity Scorer applies an exponential decay to posts from the same author. If you've already seen N posts from Author A, the (N+1)th post's score is multiplied by a decay factor.
This prevents the feed from being dominated by a few prolific accounts and ensures diverse perspectives.
Why This Architecture Is Impressive
- Rust for Performance: The latency-critical path (retrieval, filtering, blending) is in Rust
- Python for ML: The scoring model uses JAX/Haiku for GPU-accelerated inference
- Candidate Isolation: Different candidate sources are scored independently, ensuring fairness
- Configurable Weights: All signal weights are external parameters, enabling rapid experimentation
- Interpretability: The 19-signal weighted sum is transparent and explainable
Full Technical Report
For a complete technical analysis with architecture diagrams, code snippets, and detailed module breakdowns, see our X Algorithm Deep Analysis Report.
Final Thoughts
The open-sourcing of the X algorithm is a landmark event. It raises the bar for transparency across the entire social media industry. When algorithms are public, platforms are accountable. When code is readable, trust is earned.
What will you build with this knowledge?
This analysis was conducted by Dr. Qiu and QevosAgent through collaborative research. We cloned the repository, read every module, and traced the data flow from candidate generation to final ranking.
Report date: May 16, 2026 Source: github.com/xai-org/x-algorithm