Cracking the Code: How the Twitter Algorithm Works

A deep analysis of how the Twitter algorithm works

Cracking the Code: How the Twitter Algorithm Works
Do not index
Do not index
Meta Desc
A deep analysis of how the Twitter algorithm works
Meta Title
Cracking the Code: How the Twitter Algorithm Works in 2023
Auto-generated image
https://ondemand.bannerbear.com/simpleurl/9MOpzJ843LWBnGWYvq/image/title/text/Cracking%20the%20Code:%20How%20the%20Twitter%20Algorithm%20Works

Part 1: How the algorithm works


The 2-Minute Explanation

Let’s say you’re an average Twitter user named Bill.
Twitter makes money when it shows you ads. The more ads you watch, the more money Twitter makes. It’s trying to get you to spend as much time on the app, so that you watch more ads.
The algorithm’s job is to show you content that will make you spend more time on the app.
To show you content that’ll make you spend more time on the app, it tries to guess:
“What type of content is Bill most likely to engage with?”
“What is trending among users that have similar tastes as Bill?”
The Algorithm is basically Twitter’s way of making an educated guess about these questions. It does so in 3 steps:
1) It guesses which 1500 tweets you will most like from the 100 million tweets on the platform.
2) It gives each tweet an ‘engagement probability score’ and ranks them from best to worst. The top tweets are the ones you’ll most likely engage with.
3) It cleans up the tweet list by removing misinformation, blocked accounts etc. shows you the tweets with the highest score first, and throws in an ad for every 2-3 tweets.
After going through these 3 steps, what Twitter shows you is called the Twitter Feed.
Understanding how it picks, ranks, and filters tweets can help you write content reaching millions of people.
 
Source: Twitter Blog
notion image
 
Boost Your Twitter Game with Tweet Hunter!
Harness the power of trending topics, insights, and our vast library of viral content to elevate your Twitter presence.

The 15-Minute In-Depth Explanation

We want to understand how the algorithm finds relevant tweets, ranks them and what it filters out. The technical terms for these steps are:
1) Candidate Sourcing (Picking Tweets)
2) Ranking System
3) Heuristics and Filtering
 
Let’s break this down.
notion image
 
Twitter uses three types of data points:
  1. The follower graph indicating who follows you
  1. Engagement data such as likes, retweets, and replies
  1. User data such as mutes, unfollows, and spam reports
 
This data is used to source relevant tweets, which is also called candidate sourcing.
notion image
 
 

Candidate Sourcing


Twitter attempts to extract the best 1500 Tweets from a pool of hundreds of millions of through candidate sources.
This includes:
  1. People you follow (In-Network) - (Roughly 50% or 750 tweets come from here)
      • In-Network source uses a complex logistic regression model to filter out irrelevant tweets and carefully curate the most important and timely messages from the users you follow.
      • This happens through is Real Graph. It predicts the likelihood of two users engaging. Higher the score, likely they are to be seen on your feed.
        • Twitter RealGraph Framework
          Twitter RealGraph Framework
      • The top tweets go to the next level.
       
  1. People you don’t follow (Out-of-Network) - (Roughly 50% or 750 tweets come from here)
    1. How can we tell if a certain Tweet will be relevant to you if you don’t follow the author?
       
      There are 2 approaches to this taken up by Twitter.
    2. Social graph
      1. These currently serve about 15% of Home Timeline Tweets.
        For this, 2 things are taken into consideration.
        What Tweets did the people I follow recently engaged with?
        Who likes similar Tweets to me, and what else have they recently liked?
        The tweets resulting to this are then ranked using a logistic regression model - GraphJet, a graph processing engine that maintains a real-time interaction graph between users and Tweets.
        Overall architecture of the “Who to Follow” user recommendation service
        Overall architecture of the “Who to Follow” user recommendation service
         
    3. Embedding spaces
      1. This works on content similarities.
        What Tweets and Users are similar to your interests?
        This is done with the help of embeddings. Embeddings work by generating numerical representations of users’ interests and Tweets’ content.
         
        We can then calculate the similarity between the above tweet and a users interest using the following:
         
      2. Any two users (In our example, Sam Altman’s followers seeing Elon Musk’s tweet)
      3. Any two tweets (Accounts following the news of company acquisitions seeing Elon Musk’s tweet)
      4. User-tweet pairs (People following Coca-Cola seeing this tweet)
      5.  
        One of Twitter’s most useful embedding spaces is SimClusters.
        SimClusters discover communities anchored by a cluster of influential users using a custom matrix factorization algorithm.
         
        • In simple words, the algorithm uses your content to categorize you with other similar users and creates clusters. This helps your tweets reach those who aren't already following you.
        • There are 145k communities, which are updated every three weeks. Users and Tweets are represented in the space of communities, and can belong to multiple communities. Communities range in size from a few thousand users for individual friend groups, to hundreds of millions of users for news or pop culture.
         
        notion image
         
         
        The more users from a community like a Tweet, the more that Tweet will be associated with that community. These tweets are ranked after this.
        At the sourcing stage, Twitter rewards great engagement with great reach and vice versa.
 

Ranking System


notion image
 
At this point, we have 1500 candidates which are probably relevant. Scoring these directly predicts the relevance of each candidate Tweet and is the primary signal for ranking Tweets on the timeline.
 
💡
Reach = f (likes, retweets, replies, images, videos, profile tap, twitter blue, account reputation, new words, unknown language, links, misinformation, hashtags, type of writing, etc)
 
These variables contribute your tweet’s ranking positively and negatively and eventually decides wether your tweet will be chosen in the top 1500 tweets or not.
 
Actions
Sentiment
Weight
Likes
Positive
30x
Retweets
Positive
20x
Replies
Positive
1x
Image & video
Positive
2x
Twitter Blue verified
Positive
2x
Good account reputation (calculated by follower ratio, usage, verification, if you've been banned before
Positive
Boosted
New words or unknown language
Negative
0.01x
Links (Unless you have good engagement)
Negative
Negative ranking
Misinformation
Negative
Negative ranking
Multiple hashtags
Negative
Negative ranking
Type of writing
Negative
Negative ranking
Interacting with low quality account and blacklisted topics
Negative
Negative ranking
Request "show less often" on your Tweet/you, block/mute you, reports
Negative
You’re screwed
After this, in each user’s feed, based on the actions they are likely to take on that tweet, these tweets are served in an order that is most likely to maximise retention.
It calculates the probability of you taking a user action and assigns a weight to it. For eg: the probability of some replying to your tweet matters 54x times the the probability of someone liking it.
User Action
Sentiment
Weight
Like your tweet
Positive
0.5
Retweet your tweet
Positive
1
Click into your tweet & reply/like a tweet or stay there for >2 mins
Positive
11
Check out your profile and like/reply to a tweet
Positive
12
Reply to your tweet
Positive
27
Reply to your tweet and you engage with this reply
Positive
75
Request "show less often" on your Tweet/you, block or mute you
Negative
-74
Report your Tweet
Negative
-369
This means that,
  • When someone clicks on my tweet and stays there for more than two minutes, it is weighted 22 times more than if they had just liked my tweet.
  • If they click into my profile through my tweet and like or reply to a tweet, it is 24 times more than a like.
  • When they reply to my tweet, it is 54 times more than a like.
  • If they reply to my tweet and I respond to their reply, it is 150 times more than a like.
  • However, if someone reports my tweet, it has 738 times the effect of a like, meaning I'm basically screwed.
 

Filtering and Heuristics


After ranking tweets, Heuristics & Filters are used in order to create a balanced and diverse field.
Some examples:
  • Visibility Filtering: Customise your feed by hiding tweets from blocked or muted accounts.
  • Author Diversity: Prevent seeing too many tweets in a row from the same person.
  • Content Balance: Show a mix of tweets from people you follow and others outside your network.
  • Feedback-based Fatigue: Reduce visibility of tweets that have received negative feedback from you.
  • Social Proof: Only show tweets from outside your network if someone you follow has interacted with them.
  • Conversations: Add context to reply tweets by connecting them to the original tweet.
  • Edited Tweets: Keep your feed fresh by replacing outdated tweets with their updated versions.
notion image
 
At this point, Home Mixer has finished preparing a series of Tweets to be sent to your device.
The system also weaves in additional content like ads, follow recommendations, and onboarding prompts, creating a seamless user experience.
notion image
 
Once complete, this content is returned to your device for display.

Appendix: References from Source Code


Engagement
Likes > Retweets > Replies
Aim for likes, ask for retweets & keep replies as the last priority.
  • 1 like gives a 30x boost
  • 1 retweet gives a 20x boost
  • 1 reply gives 1x boost
 
💡
Retweets may be ranked lower than likes but it also multiplies your reach which may give better likes in return
notion image
 
User Actions that matter
User Action
Sentiment
Weight
Like your tweet
Positive
0.5
Retweet your tweet
Positive
1
Click into your tweet & reply/like a tweet or stay there for >2 mins
Positive
11
Check out your profile and like/reply to a tweet
Positive
12
Reply to your tweet
Positive
27
Reply to your tweet and you engage with this reply
Positive
75
Request "show less often" on your Tweet/you, block or mute you
Negative
-74
Report your Tweet
Negative
-369
notion image
 
Images & videos:
 
  • Adding images and videos gives a 2x boost
    • This means that if you want your tweets to reach a wider audience, it's essential to include visual content. But don't just add any image or video, make sure it is high-quality and relevant to your tweet.
notion image
 
Following to follower ratio make a difference?
  • Your account reach gets affected negatively if your following is more than 60% of your followers.
    • For instance, if you have 1000 followers and follow 800 people, try unfollowing 200 accounts to gain a better reach.
    • (Mass unfollowing people also gets you shadowbanned so don’t just go and unfollow everyone suddenly)
       
notion image
 
Does Twitter Blue matter?
  • Twitter blue extends your reach on top of other benefits given with it like ranking boost in replies and searches, half of the ads in your timeline, posting longer videos and 1080p videos, editing tweets, bookmark folders, and early access to new features.
 
notion image
 
How do you show up in ‘For you’ tab?
Increase your chances of getting on the "For You" tab by considering these factors:
  1. Tweet content that leads to likes/RTs
  1. Write tweets that get users to click, reply, and engage for >2 mins
  1. Build an engaging profile that makes people click.
 
Good account reputation
  • Boost, calculated by follower ratio, usage, verification, if you've been banned before
    • The final score, on a scale of 0 to 100, is the ’tweepcred’ score, which represents the user's reputation on Twitter.
    • This score is used to determine which users should be recommended to follow or which users should have their content highlighted.
  • Your "influence" on Twitter and in turn how likely your tweets are to be seen is heavily determined by the quality of users you interact with
notion image
 
Content quality
  • Currently, if your ’tweepcred’ is lesser than 65, the maximum number of tweets that will be considered by the ranking algorithm is limited to 3.
    • If your score is less than 65, your threads won’t be considered
  • However, if your ’tweepcred’ is greater than 65, this limit is lifted, which means that you can post as many tweets as you want, and the algorithm will consider all of them.
 
Your content not being marked as ‘low-quality’ will also make sure that your ‘tweepcred’ is high enough to be considered.
 
Interacting with low quality accounts
  • Interacting with low quality accounts get you penalised.
    • Account reputation is calculated by follower to following ratio, account age, device usage, if you've been restricted or suspended, and if you're verified.
  • Interact with low quality accounts with bad follower/following ratios and are marked as spam/nsfw/bots/toxic, you get penalised.
 
Interacting with blacklisted topics
  • Your tweet or account interacting with blacklisted topics (not in the code)
 
Tweets relevancy over time
Tweets have a half-life of 360 minutes, which means that a Tweet's relavancy score will decrease by 50% every 6 hours.
  • The overall rate at which the relavancy score of older tweets decrease is set at 0.003
  • The minimal age decay score a tweet can have is 0.6
 
Links
  • Links results in negative ranking.
    • External links mark you as spam (Unless you have good engagement)
      • Outbound links to non-news or media sites get clapped
    • Only posting URLs or only images (No text) also reduces your rank
    •  
notion image
 
Mutes & Unfollows
  • Mutes, unfollows (not as bad as the other 4), blocks, spam report, abuse report results in negative ranking
  • Reported tweet is reduced by 700x
 
notion image
 
New words or unknown language
Anything under point 1 in the algorithm is bad.
  • Unknown languages are downranked
  • Making up words or misspellings are given 0.01 which is really bad
 
notion image
notion image
 
Misinformation
  • Misinformation is downranked (eve Ukraine)
notion image
 
Multiple hashtags
  • Adding a lot of hashtags gets your post deboosted
notion image
 
Posting outside your cluster
  • On the flip side, posting content outside your cluster gives a penalty with out of network replies.
 
notion image
 
Type of writing
  • A score for the static quality of the text, computed in TweetTextScorer.java in the Ingester, based on the factors such as offensiveness, content entropy, "shout" score, length, and readability, affects your reach and engagement.
 
Reference Links

Part 2: What you should do to maximize reach


 
  1. Get Twitter Blue
    1. If you're a Twitter Blue subscriber, you get a 4x boost in the algorithm if you're in the same network as the author of the tweet, and a 2x boost if you're not. Source
       
  1. Maintain A High Follower-Following Ratio
    1. This method reduces the page rank of users who have a low number of followers but a high number of followings. It calculates a division factor based on the ratio of followings to followers, and reduces the user's page rank by dividing it by this factor. Source
       
  1. Keep your Tweepcred higher than 65
    1. Tweepcred is a score given to users based on the number & quality of interactions they have with others, account age, followers and device usage which determines if more than 3 of your tweets (including threads) should get featured or not. Having healthy engagement can help you keep it high and getting spam reports, blocks and mutes can hurt really badly. Source
       
  1. Niche down and become a trusted voice in one niche.
    1. Out of network replies get a penalty. Become popular within a specific community by engaging with prominent accounts in that niche. As more users from that community interact with your content, it becomes more associated with the niche, boosting visibility to their users. You can quickly build a strong relevance with your content if you niche down.
      Source
      notion image
       
  1. Engage the most in your tweets in the first 6 hours.
    1. Tweets have a half-life of 360 minutes, so a Tweet's relevancy score will decrease by 50% every 6 hours. Older Tweets become less relevant (and are shown less to others) over time. Engaging and replying to comments during this time can work in your favour. Source
       
  1. Add images & videos.
    1. In the current light ranking model (Earlybird), tweets with images & videos seem to get a nice 2x boost (source). However, this is an old model that Twitter is planning to rebuild completely, so things might change in the future. source
       
  1. Be less controversial. Getting blocked/muted/reported is bad. Really bad.
    1. Negative feedback loops reduce your "reputation score" on Twitter. Getting blocked, muted, abuse reports, spam reports and unfollows can cause a big hit on your tweepscore. Avoid having a score less than 65. Source
       
  1. Create a reason for people to engage.
    1. After getting ranked in the 1500 tweets, the likelihood of your tweet reaching someone’s feed is heavily based on factors such as time spent on the tweet, profile visit and replies. Content that makes users take these action can skyrocket your reach.
      User Action
      Sentiment
      Weight
      Like your tweet
      Positive
      0.5
      Retweet your tweet
      Positive
      1
      Click into your tweet & reply/like a tweet or stay there for >2 mins
      Positive
      11
      Check out your profile and like/reply to a tweet
      Positive
      12
      Reply to your tweet
      Positive
      27
      Reply to your tweet and you engage with this reply
      Positive
      75
      Request "show less often" on your Tweet/you, block or mute you
      Negative
      -74
      Report your Tweet
      Negative
      -369
  1. Reply to every reply on your account.
    1. If someone liking your tweet gives that tweet 1 point, you engaging with someone’s reply on your tweet gives you 150 points. Source
       
  1. Don’t add links unless you know it’s going to get engagement.
    1. External links mark you as spam and only posting URLs can reduce your rank drastically unless your tweet gets really good engagement in the first few hours.
      Source
      notion image
 

Get More Twitter Followers

Tweet Hunter helps you build, grow, and monetize your Twitter audience through tools that drive sales.

👉 Try Tweet Hunter for free!
Tibo

Written by

Tibo

Co-founder @ Tweet Hunter

Related posts

Twitter’s Algorithm Source Code ExplainedTwitter’s Algorithm Source Code Explained
How to Conquer Twitter Algorithm in 2023: 10 Hacks revealedHow to Conquer Twitter Algorithm in 2023: 10 Hacks revealed
Mastering Twitter Analytics: A Comprehensive GuideMastering Twitter Analytics: A Comprehensive Guide
Using Twitter's Algorithm to Your Advantage: Zero-Click TweetsUsing Twitter's Algorithm to Your Advantage: Zero-Click Tweets
Introducing Tweet Hunter’s Cool New Twitter FeaturesIntroducing Tweet Hunter’s Cool New Twitter Features
How to Develop a Realistic Social Media Workflow for TwitterHow to Develop a Realistic Social Media Workflow for Twitter
Understanding the X AlgorithmUnderstanding the X Algorithm