X Publishes AI-Powered Algorithm Code

Elon Musk has come through on his promise to publish the latest version of the X “For You” feed algorithm, which provides more insight into how X is looking to maximize user engagement, and ensure you’re seeing the most relevant posts every time you log into the app.
And considering that the average X user only sees 20-30 posts per day in the feed, that’s more important than ever, with X working to boost retention and interest in a relatively short space of time.
In order to do this, X is leaning on AI to do the heavy lifting, and ensure that each user’s individual preferences are being factored in. Musk says that the algorithm has been “purely AI’’ driven since November, and that, at least in theory, should now be driving better results.
But is it?
Well…
First off, on the algorithm code itself, which you can now view for yourself on GitHub. X first published its feed algorithm on GitHub back in 2023, when Musk also pledged to keep the code updated to show any tweaks to weighting. But X never updated the code, so while this was a significant development for transparency, X hasn’t lived up to its promises of ongoing transparency as yet.
Still, the fact that its publishing the algorithm code at all is a significant step, and it’ll be interesting to see whether it maintains the codebase this time around.
As noted, X’s latest “For You” algorithm is now managed by xAI’s servers, which aims to customize its predictions based on your personal preferences. But while AI is able to interpret signals, it still needs human guidance and rules to drive its decisions, and those rules are now what drives the algorithm, as opposed to complex code in previous iterations.
So what are the For You rules?
As you would expect, X’s algorithm looks to drive engagement by predicting how likely it is that you’ll engage with each candidate post in-stream. As you can see in the below diagram sample, candidate posts come from two sources: Posts from accounts that you follow (Thunder) and posts that are similar to your interests from outside of your network (Phoenix):

The first component, Thunder, ranks posts from your connections based on your past engagement history, and then shows you the candidates you’re most likely to engage with, in descending order.
Though there is a catch.
X is also looking to optimize for creator diversity, so that you don’t end up seeing posts from the same creators over and over again, which means that followers will only see a certain number of your posts each day within their “For You” feed.
The more you post, the less likely that your followers will see it, unless, of course, they switch over to the dedicated “Following” feed, though it is also worth noting that X recently made the “For You” feed the default timeline for all users. So basically, the chances of your followers seeing all of your updates every day are pretty slim.
Isn’t that a disincentive for building a following? Yes, it is, and the “For You” algorithmic approach, which was popularized by TikTok, essentially pushes people away from following entirely, in favor of highlighting more of the best content from across the app.
That’s the case here as well, with the latest algorithm update reducing the value of gaining followers, at least in this respect (gaining followers is still a positive algorithm signal).
The second component is the Grok-ranked Phoenix stream, which is X’s real focus.
Phoenix analyses the last 128 posts that you engaged with, then makes predictions on your interests based on that. The idea is that this will keep your feed fresh, by morphing into whatever you’ve been interested in most recently, with the machine learning system looking at what you’ve liked, watched, etc., then adapting to that.
The real value of this comes down to how X categorizes posts, and what it determines as related and/or similar, but X is hoping that its predictions based on your behaviors will provide a more valuable experience.
So, the main feed is a combination of the profiles you follow, along with AI recommendations, with the rankings based on your usual elements, including likes, replies, re-posts, etc.
Pretty straightforward, with certain actions weighted more than others, giving you a more aligned feed based on your preferences. Worth noting also that dwell time and video viewing have been boosted in the new system.
So what does that mean in terms of how you can boost your presence on X?
Well, aside from generating likes, replies, etc., you’re also looking to drive more dwell time, so videos and long-form content could help to boost your reach.
The only real note of change here is that posting too much too quickly is penalized in this new system (which looks to diversify your feed), so you may want to space out your posts, while X is also looking to remove duplication, so don’t re-post the same thing.
Other best practice notes include replying to post comments, while you should avoid posting links, as X continues to penalize the reach of external link posts. There are also post age penalties that will reduce reach, so keeping your updates fresh is also advised.
In terms of what not to do, getting muted or blocked are clear negative indicators, which can also reduce your reach to other accounts. Some X users have complained about this element, noting that there have long been block list going around which target certain posters, and the fact that this is considered in the algorithm could see reduced reach for these users.
So, is this new algorithm driving more engagement?
Well, X’s head of product Nikita Bier says that time spent by new users is increasing, which is a positive. Though Elon himself seems less enthused by the current state.
In response to criticisms of the algorithm code, Musk stated simply that:
“Yes, the algorithm sucks”
Musk further explained that they are trying to make the X algorithm “less dumb,” which he hopes will be reflected in future iterations of the code. But clearly, there are problems with the current ranking approach, and despite Elon’s promises of improvements, for years now, he remains dissatisfied with the state of the app.
Essentially, it’s hard to say whether X’s approach is improving, because while X claims that various indicators suggest it’s on the right track, external measures show that usage of X is declining, as Meta’s Threads continues to gain ground.
The algorithm plays a big role in this, and based on the immediate feedback on the latest code, it seems that X has a way to go on this front.
Maybe AI is the answer here, and Grok will soon be so advanced that X’s “For You” feed will become much more compelling for each user. But X needs to maintain engagement as best it can, in order to keep its AI projects humming, and it’ll be interesting to see how it looks to update and refine its systems.



