Twitter reveals some of its source code, including its recommendation algorithm | TechCrunch (2024)

As repeatedly promised by Twitter CEO Elon Musk, Twitter has opened a portion of its source code to public inspection, including the algorithm it uses to recommend tweets in users’ timelines.

On GitHub, Twitter published two repositories containing code for many parts that make the social network tick, including the mechanism Twitter uses to control the tweets users see on the For You timeline. In a blog post, Twitter characterized the move as a “first step to be[ing] more transparent” while at the same time “[preventing] risk” to Twitter itself and people on the platform.

On a Twitter Spaces session today, Musk clarified:

“Our initial release of the so-called algorithm is going to be quite embarrassing, and people are going to find a lot of mistakes, but we’re going to fix them very quickly,” Musk said. “Even if you don’t agree with something, at least you’ll know why it’s there, and that you’re not being secretly manipulated … The analog, here, that we’re aspiring to is the great example of Linux as an open source operating system … One can, in theory, discover many exploits for Linux. In reality, what happens is the community identifies and fixes those exploits.”

On that second point in the blog post about preventing risk, the open source releases don’t include the code that powers Twitter’s ad recommendations or the data used to train Twitter’s recommendation algorithm. Moreover, they include few instructions on how to inspect or actually use the code — reinforcing the idea that the releases are strictly developer-focused.

“[We excluded] any code that would compromise user safety and privacy or the ability to protect our platform from bad actors, including undermining our efforts at combating child sexual exploitation and manipulation,” Twitter wrote. It’s a bit of mixed messaging coming only weeks after Twitter fired much of its ethical AI and trust and safety staff, which was responsible for content moderation among other user security-related tasks. But the company nonetheless insists that it “[took] steps to ensure that user safety and privacy would be protected” with today’s code release.

Twitter reveals some of its source code, including its recommendation algorithm | TechCrunch (1)

Twitter says it’s working on tools to manage code suggestions from the community and sync changes to its internal repository. Presumably, those will be made available at a future date — there’s no sign of them at the present.

“We’re going to look for suggestions, not just on bugs but also on how the algorithm should work,” Musk said on the Spaces session. “It’s going to be an evolving process. I wouldn’t expect it to be a nonstop upward movement… but we’re very open to what would improve the user experience.”

At first glance, the algorithm is fairly complex — but not necessarily surprising in any way from a technical standpoint. It’s made up of multiple models, including a model for detecting “not safe for work” or abusive content, determining the likelihood of a Twitter user interacting with another user and calculating a Twitter user’s “reputation.” (It’s unclear what “reputation” refers to, exactly; the high-level documentation isn’t clear on that.) Several neural networks are responsible for ranking the tweets and recommending accounts to follow, while a filtering component hides tweets to — forgive the jargon — “support legal compliance, improve product quality, increase user trust, protect revenue through the use of hard-filtering, visible product treatments and coarse-grained downranking.”

Twitter reveals some of its source code, including its recommendation algorithm | TechCrunch (2)

In an engineering blog post, Twitter reveals more about the recommendation pipeline, which it claims runs approximately five billion times per day:

“We attempt to extract the best 1,500 tweets from a pool of hundreds of millions … Today, the For You timeline consists of 50% [tweets from people you don’t follow] and 50% [tweets from people you follow] on average, though this may vary from user to user,” Twitter wrote. “Ranking [tweets] is achieved with a ~48-million-parameter neural network that is continuously trained on tweet interactions to optimize for positive engagement (e.g. likes, retweets and replies).”

Twitter users don’t see the full 1,500 tweets, of course. They’re filtered according to content restrictions and other criteria and factors considered by the models, like if tweets have “negative feedback” and if they’re mainly from the same Twitter user, or from users who’ve been blocked or muted.

Gizmodo notes that one thing that doesn’t appear to have been made public is the list of VIPs that Twitter pushes to users. This week, Platformer reported that Twitter has a rotating list of noteworthy users, including YouTuber Mr. Beast and Daily Wire founder Ben Shapiro, that it uses to monitor changes to the recommendation algorithm by increasing the visibility of these “power users” seemingly at will.

There’s more evidence that the algorithm may treat tweets differently depending on the source. Researcher Jane Manchun Wong noted that Twitter’s algorithm specifically labels whether the tweet author is Elon Musk and has others labels indicating whether the author is a “power user” as well as whether they’re a Republican or Democrat.

During the Spaces session this afternoon, a Twitter engineer said that the labels were used only for metrics. But Musk — who said he wasn’t aware of the labels prior to today — said that they shouldn’t be there.

Twitter’s algorithm specifically labels whether the Tweet author is Elon Musk

“author_is_elon”

besides the Democrat, Republican and “Power User” labelshttps://t.co/fhpBjdfifX pic.twitter.com/orCPvfMTb9

— Jane Manchun Wong (@wongmjane) March 31, 2023

“It definitely shouldn’t be dividing people into Republicans and Democrats, that makes no sense,” Musk said.

The release of the source code comes after several controversies involving tweaks to Twitter’s recommendation algorithm in recent months. According to Platformer, in February, Musk called on Twitter’s engineers to reconfigure the algorithm so his tweets would be more widely viewed. (Twitter later walked back this change — at least somewhat.) In November, Twitter began showing users more tweets from people they don’t follow — a move the platform attempted prior to Musk’s acquisition but later reversed after a backlash from users.

Twitter reveals some of its source code, including its recommendation algorithm | TechCrunch (2024)

FAQs

Twitter reveals some of its source code, including its recommendation algorithm | TechCrunch? ›

Twitter reveals some of its source code, including its recommendation algorithm. As repeatedly promised by Twitter CEO Elon Musk, Twitter has opened a portion of its source code to public inspection, including the algorithm it uses to recommend tweets in users' timelines.

Did Twitter release its source code? ›

The company said in a blog post , opens new tab it had uploaded the code in two repositories on code-sharing platform Github. They include the source code for many parts of Twitter, including the recommendations algorithm which controls the tweets that users see on their timeline.

Did Twitter leak parts of its source code? ›

Twitter moved on Friday to have the leaked code taken down by sending a copyright infringement notice to GitHub, an online collaboration platform for software developers where the code was posted, according to the filing. GitHub complied and took down the code that day.

What is the Twitter suggestion algorithm? ›

According to Twitter, the recommendation pipeline consists of three main stages: candidate sourcing, candidate ranking, and using heuristics and filters for tweets the user doesn't engage with. The “For You” timeline is personalized for each user through Twitter's service known as the Home Mixer.

Does Twitter use a recommendation system? ›

The foundation of Twitter's recommendations is a set of core models and features that extract latent information from Tweet, user, and engagement data.

Did Elon Musk make the Twitter algorithm open source? ›

Musk framed his decision to make Twitter's algorithm open source as an effort to improve it, by enlisting the help of volunteers, and as an act of radical transparency — if you suspected Twitter was "shadowbanning" certain people, the conspiracy would finally be exposed.

What has Elon Musk done to the Twitter algorithm? ›

"Yes, Elon Musk created a special system for showing you all his tweets first," the Platformer headline read. "After his super bowl tweet did worse numbers than President Biden's, Twitter's CEO ordered major changes to the algorithm."

Did Twitter engineers ask to print out code? ›

Musk asked the Twitter engineers to print out their code for review on the first day of work. Musk is said to have asked the engineers to show him their most recent software code. Engineers were also instructed to print their codes.

What was the root cause of the Twitter data breach? ›

How was Twitter hacked? Hackers exploited an API vulnerability to gain unauthorized access to Twitter's user data, matching email addresses with profiles. This security flaw persisted from June 2021 to January 2022, ultimately leading to the exposure of email addresses, names, and usernames for millions of users.

What is leaked on Twitter? ›

The leaked data includes email addresses, names, and Twitter account details, leaving users vulnerable to phishing attacks, identity theft, and social engineering schemes. Malicious actors can exploit this data to compromise further accounts and systems linked to the affected email addresses.

How do I get rid of Twitter algorithm? ›

How To Reset Twitter Algorithm by Resetting Your Topics
  1. Launch the Twitter mobile App and log into your account.
  2. Tap on the profile icon. ...
  3. You will see a list of topics you are following. ...
  4. Select “Unfollow” to finalize.
  5. Next, scroll down to “Suggested Topics” or tap “More Topics” underneath it.
Jul 19, 2023

What happened to the Twitter algorithm? ›

Another big recent change to the Twitter (X) is the algorithm now puts more emphasis on highlighting content from smaller accounts. The goal is to create a more level playing field and expose users to a wider range of voices and perspectives on the platform.

How to fix Twitter algorithm? ›

So, the primary way to reset it is by altering your interests. There's no need to worry, as you can do this easily by changing the nature of your content. If you tweet and retweet more about certain topics, the system will interpret them as part of your interests.

Why is Twitter not a credible source? ›

Previous research has shown that most of the messages posted on Twitter are truthful, but the service is also used to spread misinformation and false rumors, often unintentionally.

Is Twitter source code open source? ›

Explore Projects

Twitter has been built on open source since the beginning. Openness is part of our DNA.

Does Twitter monitor you? ›

When you view Twitter content such as embedded Tweets, buttons, or timelines integrated into other websites using Twitter for Websites, Twitter may receive information, including the web page you visited, your IP address, browser type, operating system, and cookie information.

Is Twitter open source yet? ›

Explore Projects

Twitter has been built on open source since the beginning. Openness is part of our DNA. The projects you see here were born at Twitter, and patches are always welcome!

When did Twitter become open source? ›

In 2021, Twitter began the research phase of Bluesky, an open source decentralized social media protocol where users can choose which algorithmic curation they want.

What was Twitter coded with? ›

Twitter's codebase is massive, with millions of lines of code spread across various programming languages, including Java, Ruby, Scala, and JavaScript. The platform's frontend, which is what users interact with, is primarily built using React, a JavaScript library for building user interfaces.

Top Articles
Latest Posts
Article information

Author: Reed Wilderman

Last Updated:

Views: 6399

Rating: 4.1 / 5 (72 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Reed Wilderman

Birthday: 1992-06-14

Address: 998 Estell Village, Lake Oscarberg, SD 48713-6877

Phone: +21813267449721

Job: Technology Engineer

Hobby: Swimming, Do it yourself, Beekeeping, Lapidary, Cosplaying, Hiking, Graffiti

Introduction: My name is Reed Wilderman, I am a faithful, bright, lucky, adventurous, lively, rich, vast person who loves writing and wants to share my knowledge and understanding with you.