DEV Community

Devansh Bataan
Devansh Bataan

Posted on

BDSM - Behavioural Detection Sequence Model

What did you thought ? 😈

I want to share an intresting take about X (Twitter). Recently twitter was facing a lot of backlash about the impressions and visibility any post was getting. People were calling out on it that this algorithm is rigged & even racist.

BDSM is an algorithm from Twitter to manage feeds and reach for anything that we post on Twitter. Due to this backlash they open sourced an algorithm for how they rank posts.

This algorithm rank tweets, how impressions are generated, which tweet will go viral and which wont. All these things are open sourced now to increase transparency.

This is the repository opensourced by twitter : https://github.com/xai-org/x-algorithm This is not the exact algorithm for obvious reasons but it contains all the things that we need to know.

Home Mixer
This repo has many different services exposed like "Home Mixer" : this service manages the user feeds, what the end user sees how the tweets are visible and ranked on his Twitter home or feed screen. It manages feeds using a mix of current trends, with people you've followed, some recommendations and some more things like new related accounts or advertisements.

The Home Mixer mixes up things and shows on your feed, trying to make a perfect balance of everything.

It also uses another service "Thunder Client" that runs aggregation pipelines for your feed.

Home mixer uses 'Hydraters', to decide if you want to pre compute tweets or fetch them on demand.

How are tweets scored:
This image shows you how does each tweet gets scored, better the score better goes the reach.

As we can see here, the highest score goes to the tweet when someone clicks on the copy link to share your tweet across other apps, this signifies that your tweet is so good that people from other apps want to join twitter due to content of your tweet. So nice! And in the bottom we can see penalties also if someone reported your tweet you loose 234 points ! that's it done for the day. Be careful when and what you tweet.

BDSM - Behavioural Detection Sequence Model :
Now lets talk about my favourite BDSM (just cant stop laughing), this is a simple service, made in python, that is used to detect if you are a bot or an real user, it has a very simple architecture. All the things sent to spam are done using this service. The intresting part here is this service never reads a single words in your tweet, never sees any content. This service just looks at how and when you post ot use twitter and then make patterns out of it. That's it.

The biggest challenge for this service is to detect "Bot farms" or "Follow Farms". Reading content of tweets here doesnot make much sense because lot of bots are just there to increase followers of people. The bots hardly posts anything they mostly follows people and wait for follow back, it doesnot post even a single word. The next problem is 'Zero Content Signal', the content is easy to change, just ask ai to rewrite the flagged content and boom that's it, some post marked as spam ? Run it through ai and you are back in an hour.

Hence twitter updated its algorithms to detect usage patterns, this servcei BDSM checks around last 512 actions and compare this with the actions of how an actual human uses twitter, it checks actions like scrolls, likes, follows, views, reposts, replies etc. Then these action and logs run through BDSM algorithm and it assigns a bot detection score, based on a probabilty distribution if its a bot or not. Based on this score you may get a captcha to do some actions like reporting, posting, following etc. Twitter just does not block anyone immediately, they check for usage rhythm, timestamps and patterns.

There can be instances when a bot or you may have done some actions in past and you also may get categorised as a bot according to BDSM. These concepts and solutions comes very handy when you are designing systems.

Summary
Twitter/X finally open-sourced parts of its recommendation system, giving us a peek behind the curtain at why one tweet gets millions of views while another dies quietly with 17 impressions and emotional damage.

From Home Mixer, which decides what appears on your feed, to tweet scoring signals that reward engagement and punish negative feedback, the system is basically a giant ranking machine constantly asking: “Is this interesting, useful, spammy… or are you just desperate for followers?”

And then there’s the wonderfully named BDSM — Behavioural Detection Sequence Model. Instead of obsessing over what you write, it studies how you behave: likes, follows, scrolls, reposts, timing, and hundreds of recent actions to figure out whether you’re a human or a suspiciously enthusiastic script running from somebody’s basement.

The bigger lesson is actually about system design: when content can easily be rewritten or manipulated, behaviour and patterns often become much stronger signals than the content itself.

So yes, come for the unfortunate acronym. Stay for recommendation systems, ranking algorithms, bot detection, and some genuinely useful engineering ideas. 😈

Feel free to reach out to me on :
linkedIn - https://www.linkedin.com/in/devansh-bataan-488453189/
email me at - devanshbataan.dev@gmail.com

Devansh

Bengaluru, India

Top comments (0)