How Twitter Opened Up Its Code and What You Can Learn From It

Twitter is one of the most popular and influential social media platforms in the world, with over 300 million monthly active users and billions of tweets every day. But how does Twitter work behind the scenes? How does it decide what content to show you on your timeline, and how can you influence its recommendations?

Until recently, these questions were hard to answer, as Twitter kept most of its source code secret. However, on March 31, 2023, Twitter made a surprising announcement: it was making public parts of the computer code that powers its platform, including its recommendation algorithm. This means that anyone can now access, inspect, and modify the code that controls how Twitter operates.

Why did Twitter do this? According to its billionaire owner Elon Musk, who bought the company in 2022, the main reason was to increase trust and transparency among users and programmers. He also said that code openness would lead to faster and better improvements to the product, as users could suggest changes and fixes to the algorithm.

In this article, we will explore what Twitter open sourced, how you can access and use it, and what benefits and challenges it brings to the social media landscape.

What did Twitter open source?

Twitter uploaded the code in two repositories on Github, a popular code-sharing platform. The first repository contains the source code for many parts of Twitter, including:

  • The recommendation algorithm, which determines what tweets you see on your timeline based on your interests, preferences, and behavior.

  • The ranking algorithm, which orders the tweets on your timeline based on their relevance, popularity, and freshness.

  • The filtering algorithm, which removes spam, abusive, or low-quality tweets from your timeline.

  • The personalization algorithm, which tailors your experience based on your profile, location, language, and device.

  • The trending algorithm, which identifies and displays the most popular topics and hashtags on Twitter.

The second repository contains the code for Twitter’s machine learning models, which are used to power various features such as:

  • The image recognition model, which detects objects, faces, text, and emotions in images.

  • The natural language processing model, which analyzes text for sentiment, topics, entities, and intents.

  • The speech recognition model, which transcribes audio into text.

  • The text generation model, which creates tweets based on a given prompt or topic.

The repositories do not include the code that powers Twitter’s ad recommendations or its moderation system. Twitter also said it excluded code that would compromise user safety or privacy or undermine efforts to prevent child sexual abuse material on the platform.

How can you access and use Twitter’s open source code?

To access Twitter’s open source code, you need to have a Github account and follow these steps:

  1. Go to https://github.com/twitter

  2. Click on the repository you want to explore (e.g., twitter-recommendations or twitter-ml-models).

  3. Browse through the files and folders to see the code structure and documentation.

  4. Click on a file to see its content and history.

  5. If you want to download or clone the repository to your local machine, click on the green “Code” button and follow the instructions.

To use Twitter’s open source code, you need to have some programming skills and familiarity with Python (the main language used by Twitter) and TensorFlow (the main framework used by Twitter for machine learning). You also need to install some dependencies and libraries as specified in the README files of each repository.

Once you have everything set up, you can run the code locally or on a cloud service of your choice. You can also modify the code as you wish or suggest changes to Twitter via pull requests or issues.

Some examples of what you can do with Twitter’s open source code are:

  • Analyze how Twitter’s recommendation algorithm works and what factors influence its decisions.

  • Experiment with different ranking or filtering methods to see how they affect your timeline.

  • Customize your personalization settings or create your own profile based on your preferences.

  • Explore what topics or hashtags are trending on Twitter and why.

  • Train your own image recognition or natural language processing models using Twitter’s data or your own data.

  • Generate tweets based on a given prompt or topic using Twitter’s text generation model.

What are the benefits and challenges of Twitter’s open source initiative?

Twitter’s open source initiative brings many benefits to the company and the community, such as:

- Improving the quality and security of its software by exposing it to external feedback, review, testing, and auditing

- Accelerating the innovation and development of its software by leveraging the collective intelligence, creativity, and expertise of the open source community

- Reducing the cost and complexity of its software by reusing and adapting existing open source solutions instead of reinventing the wheel

- Enhancing its reputation and brand image by demonstrating its commitment to transparency, collaboration, and social good

- Attracting and retaining talent by offering a stimulating and rewarding work environment where developers can learn from and contribute to cutting-edge technologies

- Building trust and loyalty among its users by giving them more control, choice, and customization over their experience on the platform

- Creating positive network effects by increasing the adoption, interoperability, compatibility, and standardization of its software across different platforms, devices, and applications

What are the challenges of Twitter’s open source initiative?

Twitter’s open source initiative also faces some challenges in maintaining and growing its open source presence, such as:

- Balancing the trade-offs between openness and competitiveness by deciding what to share and what to keep proprietary

- Managing the complexity and diversity of its software portfolio by ensuring consistency, compatibility, quality, performance, documentation, support, and maintenance across different projects

- Coordinating the collaboration and communication among its internal teams and external contributors by establishing clear roles, responsibilities, guidelines, processes, tools, incentives, and feedback mechanisms

- Dealing with the legal and ethical issues related to licensing, compliance, ownership, liability, privacy, security, governance, diversity, inclusion, accessibility, sustainability, and social impact of its software

- Adapting to the changing needs and expectations of its users, customers, partners, regulators, competitors, and stakeholders by staying ahead of the trends.

Twitter has done something that few other social media platforms have dared to do: it has opened up some of its source code to the public. This means that you can now see and modify the code that determines what tweets you see on your timeline, as well as other parts of Twitter’s functionality. This is a huge step towards transparency and accountability, as Twitter’s owner Elon Musk claims. He says that by making the code public, he wants to build trust and collaboration with users and programmers, and also improve the product faster and better. But this also comes with some trade-offs and challenges, such as protecting user safety and privacy, preventing abuse and exploitation of the code, and balancing Twitter’s own interests and goals. Twitter’s open source experiment is a fascinating and risky venture that could have a significant impact on the social media landscape. Will it make Twitter more user-friendly, innovative and trustworthy? Or will it backfire and expose Twitter’s flaws, vulnerabilities and biases? Only time will tell. But one thing is certain: Twitter will never be the same again.