Twitter has made good on its promise to release a portion of its source code, much to the surprise of many who thought it was an April Fool’s joke. Elon Musk, the owner of Twitter, announced that the company would share its recommendation algorithm’s source code. While it is only a small portion of the code, it offers a glimpse into how the algorithm works for recommending tweets.
The source code for Twitter’s recommendation algorithm has been shared on GitHub. Musk expressed his hope that users would identify any potential issues with the code and contribute to its improvement. He acknowledged that the initial release of the algorithm could be embarrassing, as it may contain mistakes, but assured users that they would be resolved quickly. Initially, only the code related to the display of tweets in the “For You” feed will be made public. However, Musk has plans to release more parts of the source code in the coming weeks, including everything that contributes to the recommendation algorithm. Additionally, Musk intends to open source Twitter’s search algorithm.
Twitter’s engineering blog explained how the “For You” feed operates. The recommendation pipeline runs billions of times each day, aiming to select the top 1,500 tweets from a vast pool of millions. Currently, the “For You” timeline consists of an equal distribution of tweets from both followed and non-followed users, although this can vary for individual users. To rank the tweets, a neural network with approximately 48 million parameters is employed. The network is continuously trained on tweet interactions to maximize positive engagement, such as likes, retweets, and replies.
There have been speculations about Twitter favoring high-profile users by boosting their tweets, including those of Elon Musk. Some clues in Twitter’s algorithm support this idea, as researcher Jane Manchun Wong noticed that tweets from Musk as well as “power users,” Republicans, and Democrats were labeled differently. A Twitter engineer clarified during the Spaces session that these labels were solely used for metrics. However, Musk, who claimed to be unaware of them, objected to their presence.
Numerous users have reported seeing more of Musk’s tweets on their feed despite not interacting with any of his tweets. It is believed that Musk instructed the engineering team to prioritize his tweets in February when he suspected a decline in his reach.