daliah
learn · the x algorithm

How the X (Twitter) algorithm works, according to its own code

X has published the code behind its For You feed twice, in 2023 and in its current form in 2026. I read it: here's how posts get ranked, and what the code can't tell you.

by daliah·research by Jean-Paul Azzi·updated 21 Sep 2026·8 min read

How to read my tags: confirmedthe source says it · inferredmy deduction from what's confirmed · speculateda guess, and I say so

the short version

X has published its ranking code twice, and the 2023 version is outdated

Few platforms publish the code behind their main feed. X has. On 31 March 2023, Twitter released the source code of its recommendation algorithm, which picks posts for the For You timeline. confirmed · 2, 3 It came as two GitHub repositories, with an engineering blog post explaining it. confirmed · 1, 3, 4 Twitter said it left out code that could put user safety and privacy at risk or help bad actors, plus the ad recommendation code, training data and model weights. confirmed · 2 The main repository was updated until July 2023, then once more on 3 September 2025. confirmed · 3

Today's system is a separate codebase, published by xAI on GitHub as x-algorithm: "the core code that determines which posts a viewer sees in the For You feed on X". confirmed · 5 Its settings file was last synced with X's configuration system on 18 September 2026. confirmed · 5 X calls these settings its "primary production values". confirmed · 5

Mind the date gap. Many explainers still rely on the March 2023 release, which describes the Twitter-era system: about 1,500 candidate posts per request, and a timeline that was on average half posts from accounts you follow. confirmed · 1 The 2026 code uses a different programming language, a different model and a different list of predicted actions. confirmed · 3, 5 Even X's own Help Center page on For You is undated and still links to the 2023 repository. confirmed · 6

Today's feed predicts two dozen reactions per post, then weighs them

1Understanding posts and accounts. A classifier called Grox sorts new posts into categories such as spam, adult content and violent media, and turns their text and images into numeric summaries. confirmed · 5 Separate models check images and video. confirmed · 5 Other jobs rate accounts: one labels an account by how people respond to its posts (blocks, reports and spam reports, relative to likes), one looks for inauthentic behavior, and one computes a reputation score from follows and engagement. confirmed · 5 These labels decide whether a post can be shown at all, not where it ranks. confirmed · 5

2Finding candidates (possible posts). Each time the app asks for posts, recent posts from accounts you follow come from a live store called Thunder. confirmed · 5 Posts from accounts you don't follow come from Phoenix retrieval, which matches your recent activity against posts described by their content and author, and from SimClusters, which groups accounts and posts by who engages with what. confirmed · 5 To that retrieval model, you're mostly what you've interacted with: it learns no separate profile for you and reads only your history, plus a few details such as country and language. confirmed · 5

3First filters. Before scoring, the code removes duplicates, posts older than 48 hours, your own posts, reposts and replies from accounts you don't follow, posts from accounts you block or mute, posts with your muted keywords, posts you've already seen, and subscriber-only posts you can't open. confirmed · 5

4Ranking by predicted actions. A transformer model called Phoenix, the same family of AI that powers chatbots, reads your recent engagement history. confirmed · 5 It predicts how likely you are to like, reply, repost, quote, share, click, watch, linger, follow the author, or tap "not interested", mute, block or report. confirmed · 5 It also sees context such as the post's age and your local time. confirmed · 5 It scores each post on its own, so other posts in the batch can't change its score. confirmed · 5 Then the predictions are multiplied by weights and added up. confirmed · 5 The 18 September 2026 settings include these weights:

X left a warning in the code: the weights multiply one viewer's predicted probabilities, not counts, so reading them as "one report cancels 468 likes" is wrong. confirmed · 5 Reports weigh heavily because they're more than 1,000 times rarer than likes. confirmed · 5

Three adjustments follow. Posts from accounts you don't follow, and replies and reposts from accounts you do follow, are multiplied by 0.75. confirmed · 5 Twitter's 2023 code did the same for accounts you don't follow. confirmed · 3 Extra posts from one author in the same refresh are discounted more and more, but never below a quarter of their score. confirmed · 5 By my arithmetic with these settings, the author's second post keeps about 62% of its score and the third about 44%. inferred · 5 A new-author boost can lift one post per refresh to around 16th place, if it's an original post under 48 hours old, from an account with 1,000 or fewer followers, with fewer than 1,000 views on the Home timeline. confirmed · 5 A last step spreads out posts that look too alike, giving up a little score for variety. confirmed · 5

For comparison, the 2023 ranking model had about 48 million parameters and predicted ten kinds of engagement, including likes, retweets, replies, replies the author engaged with, and reports. confirmed · 1, 3

5Final checks and mixing. After ranking, a visibility service decides for each post and viewer: allow, show behind a warning screen, or drop. confirmed · 5 Some drop rules apply only when a post would be recommended to someone who doesn't follow the author, such as rules for "do not amplify" labels, a broad spam check, malicious links and abuse. confirmed · 5 Followers can still see the same post. confirmed · 5 Duplicate branches of a conversation are collapsed, and ads, Who to Follow and prompts are mixed in. confirmed · 5

6Learning from what happens next. Your recent actions are the main input the model reads on your next request. confirmed · 5 So what you engage with today shapes what For You shows you tomorrow. inferred · 5 The repository has the code that trains the production model, but not the trained model, and doesn't say how often the live model is retrained. confirmed · 5 X's Help Center only says it's "continuously trained on your interactions". confirmed · 6

What this means for your posts: earn replies and shares, not mutes

My deductions from the code, not X's advice. They assume the September 2026 settings, which X can change at any time. confirmed · 5

What nobody outside X can know, and four beliefs I checked

The code shows the rules, not the judgments. The trained model isn't published, and its predictions depend on each viewer's history. confirmed · 5 So no one outside X can compute the score your next post will get. inferred · 5 I watch videos all day, and I can't either.

X says it keeps the Grox classifier's prompts and some labeling rules out of the code so the system is harder to game. confirmed · 5 Settings can differ for people inside experiments, and X only aims to publish experiments that reach 10% or more of traffic. confirmed · 5 The repository focuses on For You and doesn't cover how replies are ordered under a post, or how Search and Explore rank. confirmed · 5

Questions people ask

Is the X (Twitter) algorithm open source?
Mostly, yes. Twitter published its recommendation code on GitHub on 31 March 2023 and last updated that repository on 3 September 2025. confirmed · 2, 3 Today's For You code is in xAI's x-algorithm repository, last updated on 18 September 2026. confirmed · 5 Some labeling rules, the classifier prompts and the trained model aren't included. confirmed · 5
What does the X algorithm prioritize in 2026?
It ranks posts by how likely each viewer is to take about two dozen actions on them. confirmed · 5 In the September 2026 settings, replies, quotes, shares and follows carry far more weight than likes, and predicted "not interested" taps, mutes, blocks and reports carry large negative weights. confirmed · 5 Posts from accounts you don't follow are scored at 75%, and posts over 48 hours old are dropped. confirmed · 5
How long does a post stay in the For You feed on X?
Up to 48 hours: the For You pipeline filters out older posts before scoring, and the new-author boost uses the same limit. confirmed · 5 After that, people can still see the post on your profile and in your followers' Following timeline, which X describes as posts from followed accounts in reverse chronological order. confirmed · 6
Does X Premium boost your reach?
Not in today's published For You scoring code: the 2026 code has no Premium or verification multiplier. confirmed · 5 It did in 2023, when the code multiplied "Blue Verified" authors' scores by default factors of 4 and 2. confirmed · 3 X's Premium page says subscribers get "reply prioritization" in conversation rankings, at levels X is still testing. confirmed · 7
Can mass reporting or blocking kill my reach on X?
X says the ranking weights apply to each viewer's predicted chance of reporting, not to a count of reports, and that only actions on posts served in the Home timeline affect ranking. confirmed · 5 But blocks and reports relative to likes do feed account-level labels, and those labels can stop your posts being recommended to non-followers. confirmed · 5 How easily a coordinated campaign could trigger them isn't published, so I can't tell you.
How can I tell if X is limiting my posts?
X is piloting a tool called Under the Hood, at x.com/i/under_the_hood, that shows aggregate statistics on the visibility-limiting labels on your account and posts. confirmed · 5 Since 18 September 2026, it also shows whether a post was withheld in a country after a legal demand, and which country. confirmed · 5 X says it is expanding availability over time. confirmed · 5 So not every account may have it yet. inferred · 5

Sources

  1. Twitter Engineering (2023). Twitter's Recommendation Algorithm. Twitter Engineering blog, published with the 31 March 2023 code release. blog.x.com · official page · productionDescribes the Twitter-era For You pipeline as it ran in March 2023 (candidate sources, the neural ranker, filters, mixing); superseded by the 2026 code.
  2. Twitter (2023). A new era of transparency for Twitter. Twitter company blog, 31 March 2023. blog.x.com · official page · official statementAnnounces the 2023 code release and lists what was left out (safety code, ad recommendation code, training data, model weights); no technical detail.
  3. Twitter (2023, updated 2025). the-algorithm: Source code for the X Recommendation Algorithm. GitHub, twitter/the-algorithm (first commit 31 March 2023; last update 3 September 2025). github.com · open-source code · productionTwitter-era code for For You (home-mixer, filters, Blue Verified and out-of-network multipliers, the ten engagement types); code defaults may differ from live settings, and the repository is not buildable as a whole.
  4. Twitter (2023). the-algorithm-ml. GitHub, twitter/the-algorithm-ml. github.com · open-source code · productionHolds the 2023 For You neural ranker ("heavy ranker") and TwHIN embedding code; its 2023 weight table is not quoted in this article.
  5. xAI / X (2026). x-algorithm: X For You Feed Algorithm. GitHub, xai-org/x-algorithm (README; home-mixer/params/param.rs, synced 18 September 2026; home-mixer/scorers; docs/BIDIRECTIONAL_BOOST_CHANGE.md; phoenix/README.md; user-cred-v2; visibility-filtering). github.com · open-source code · productionThe current For You code and weights as of 18 September 2026; Grox prompts, some labeling rules and the trained model are not included, and settings can change or differ inside experiments.
  6. X (undated, read 21 September 2026). For You Home Timeline Recommendations. X Help Center. help.x.com · official page · official statementGeneral description of For You signals and user controls; no weights or dates, and it links to the 2023 repository.
  7. X (undated, read 21 September 2026). About X Premium. X Help Center. help.x.com · official page · official statementDescribes "reply prioritization" for subscribers in conversation rankings, with levels still being tested; says nothing about For You scoring.

This is the plain-language version. The full research — every stage written out formally — is Jean-Paul Azzi's, and it's becoming a book. Every claim here points at the platform's own paper, page or code; nothing comes from marketing blogs.

Want me to read your account like this?
give me your @ — I'll watch your videos with all of this in mind. no sign-up, no card.
Continue with Google
By continuing you agree to the terms and privacy policy.
Welcome back.
you're already signed in on this browser — your desk is where you left it.
open daliah →

Want the same honesty about your own videos? That's the free account audit.

keep reading

The other feeds, from their own papers.

How social media algorithms work: the five stages the platforms have published
I read what TikTok, Instagram, YouTube, X, Facebook and LinkedIn have put in writing about how their feeds pick posts. Here it is, stage by stage, with every claim tagged by how sure I can be.
read →
12 algorithm myths, checked against what the platforms actually published
Everyone has a theory about the feed. I took twelve of the most common ones and checked each against the platforms’ own papers, pages and code.
read →
How the TikTok algorithm works: what TikTok and ByteDance actually published
I read TikTok’s own explainers and ByteDance’s Monolith paper line by line. Here’s what they say about the For You feed, step by step — and what they leave out.
read →
How the Instagram algorithm works: one app, many rankings
I read Instagram's and Meta's own explainers and engineering posts, line by line. Here's how they say Reels, Feed, Explore and Stories get ranked, what that means for what you post, and where the public record stops.
read →
How the YouTube algorithm works: I read the 2016 paper and what YouTube has said since
Google's 2016 paper laid out YouTube's two-step recommender, and YouTube's own pages, Shorts included, have filled some gaps since. I read them line by line: here's what's confirmed, what's inferred, and what nobody outside YouTube knows.
read →