News

How the X algorithm works, according to its open-source code

X released the code that builds the For You feed in January 2026 and has kept updating it. You don't need to read Rust to use it: here is what the code and its documentation actually say, and what they don't.

Published 4 min readSources

On this page

What X published

On January 19, 2026, X published the code of its rebuilt recommendation system on GitHub, in the xai-org/x-algorithm repository under the Apache 2.0 license. The repository describes itself as "the core code that determines which posts a viewer sees in the For You feed on X." X has updated it several times since, adding configuration values, the model training code and the systems that decide whether a post can be shown at all.

Step 1: Finding candidate posts

Every time you open For You, the feed is assembled for you from two sources:

  • In-network: a system called Thunder keeps recent posts from accounts you follow.
  • Out-of-network: Phoenix retrieval and SimClusters find posts from accounts you don't follow that match your interests.

Before any scoring, filters remove duplicates, posts older than 48 hours, your own posts, accounts you've blocked or muted, muted keywords, posts you've already seen, and subscriber-only posts you can't access.

Step 2: Predicting what you'll do

A transformer model called Phoenix reads your recent activity and predicts, for each candidate post, how likely you are to take each of these actions:

GroupActions the model predicts
Engagementfavorite (like), reply, repost, quote, share, share via DM, share via copy link
Clickspost, profile, link, photo expand, video open, quoted post
Attentionvideo quality view, dwell, dwell time, click dwell time, active seconds
Authorfollow author
Negativenot interested, mute author, block author, report, not dwelled

Step 3: Turning predictions into a score

The ranking step combines the predictions into one number:

Final score = Σ (weight × predicted probability of each action)

Positive actions have positive weights and negative actions negative ones. X added a note in August 2026 because many people misread the weights: they "scale the predicted probabilities... they do not scale the raw engagement counts." A report having a much larger weight than a like doesn't mean one report cancels out hundreds of likes; it means the model's estimate that you would report a post matters a lot.

Three adjustments follow:

  • Author diversity: each additional post from the same author in your feed is multiplied by a decaying factor.
  • Out-of-network discount: posts from accounts you don't follow, and replies and reposts from accounts you do follow, are scored lower.
  • New-author boost: posts from authors whose impressions are below a threshold are lifted toward a target position.

Step 4: Visibility filtering

Ranking decides the order; a separate system called visibility filtering decides whether a post can be shown at all. It uses your own blocks and mutes plus labels that other systems attach to posts and accounts, from spam rules to models that score account behavior. Some rules apply only when a post is recommended to people who don't follow its author. X also launched an "Under the Hood" tool that shows creators aggregate statistics about labels on their own account and posts.

What this means for creators

  • Earn attention, not just clicks. Dwell time and "not dwelled" are both predicted, so posts people actually read score better.
  • Avoid annoying people. Predicted mutes, blocks, reports and "not interested" subtract from the score.
  • Quality over volume. Author diversity decay means ten posts in an hour compete with each other.
  • Your first 48 hours matter. Posts older than that drop out of For You.
  • Small accounts get a chance. The new-author boost exists, so consistent original posting pays off early.

Reach is only half the payout story: under Original Content Rewards, only views from Premium subscribers on original posts count. See verified and qualified impressions explained.

What the code doesn't tell you

X says a limited set of files isn't published, such as some LLM prompts and some rules, to make gaming harder. The actual weights are configuration values that X can change in experiments, and the repository shows production defaults rather than every test. Treat any "secret formula" post claiming exact numbers with caution, and check the repository itself.

Frequently asked questions

Is the X algorithm really open source?

The core code for the For You feed is public on GitHub at xai-org/x-algorithm under the Apache 2.0 license. X says a limited set of files, such as some LLM prompts and some rules, are not published to make gaming harder.

Does a report cancel out hundreds of likes?

No. X addressed this directly: the weights multiply the model's predicted probability that you will take an action, not raw engagement counts. A large weight on "report" does not mean one report cancels a fixed number of likes.

How long does a post stay in the For You feed?

The code filters out posts older than 48 hours before scoring.

Does the algorithm affect my payouts?

Indirectly. Payouts depend on qualified impressions from Premium users in the Home Timeline, and the For You algorithm decides how many people see your posts there.

Sources

Checked on September 28, 2026. X changes its programs often; the X Help Center is the final word.