Advertisement

Twitter’s recommendation algorithm is now on GitHub

Elon Musk said he expects people to find "a lot of mistakes" in the code.

OLIVIER DOULIERY via Getty Images

Nearly a year after Elon Musk first floated the idea of making Twitter’s recommendation algorithm public, the company has posted the source code for its recommendation algorithm on GitHub. In a Twitter Space discussing the move, Musk said he hoped users would be able to find potential “issues” in the code and help make it better.

“Our initial release of the so-called algorithm is going to be quite embarrassing and people are gonna find a lot of mistakes but we're going to fix them very quickly,” Musk said.

Notably, the code released Friday only deals with how tweets are shown in Twitter's "For You" feed. The company didn't release the underlying code for its search algorithm or how content is displayed on other parts of Twitter, though Musk said the company would "for sure" open-source the search algorithm as well.

In a blog post outlining how Twitter’s recommendations work, the company explained the various steps of the algorithm, including ranking and filtering. But Twitter users have already been finding interesting details in the code itself. For example, Jane Manchun Wong noted that “Twitter’s algorithm specifically labels whether the Tweet author is Elon Musk.” That may offer yet another explanation for why Musk’s tweets appear so often. Wong also noted that the algorithm has labels indicating whether the tweet author is a “power user” as well as whether they are a Republican or Democrat.

When asked about that aspect of the algorithm in the Twitter Space, Musk said “I agree that shouldn’t be there … it definitely shouldn't be dividing people into Republicans and Democrats, that makes no sense.” A Twitter engineer later followed up to clarify that the categories were only for “stat tracking purposes and it has nothing to do with the algorithm.” He said the labels are meant “to make sure we don't bias towards one group versus another one” though he didn’t address why Musk had his own category.

“But isn’t it weird that you have four categories and one of them is Elon,” the questioner responded. “I think it’s weird,” Musk said. “This was the first time I’m learning this.” The Twitter engineer didn’t directly respond with an explanation. The Twitter Space ended less than a minute later.