Giter VIP home page Giter VIP logo

twitter / the-algorithm Goto Github PK

View Code? Open in Web Editor NEW
61.4K 366.0 12.2K 7.62 MB

Source code for Twitter's Recommendation Algorithm

Home Page: https://blog.twitter.com/engineering/en_us/topics/open-source/2023/twitter-recommendation-algorithm

License: GNU Affero General Public License v3.0

Starlark 5.81% Java 21.95% Python 3.91% Dockerfile 0.01% Scala 62.86% Thrift 2.36% Shell 0.04% Rust 1.15% C 0.13% C++ 1.77% CMake 0.01%

the-algorithm's Introduction

Twitter's Recommendation Algorithm

Twitter's Recommendation Algorithm is a set of services and jobs that are responsible for serving feeds of Tweets and other content across all Twitter product surfaces (e.g. For You Timeline, Search, Explore, Notifications). For an introduction to how the algorithm works, please refer to our engineering blog.

Architecture

Product surfaces at Twitter are built on a shared set of data, models, and software frameworks. The shared components included in this repository are listed below:

Type Component Description
Data tweetypie Core Tweet service that handles the reading and writing of Tweet data.
unified-user-actions Real-time stream of user actions on Twitter.
user-signal-service Centralized platform to retrieve explicit (e.g. likes, replies) and implicit (e.g. profile visits, tweet clicks) user signals.
Model SimClusters Community detection and sparse embeddings into those communities.
TwHIN Dense knowledge graph embeddings for Users and Tweets.
trust-and-safety-models Models for detecting NSFW or abusive content.
real-graph Model to predict the likelihood of a Twitter User interacting with another User.
tweepcred Page-Rank algorithm for calculating Twitter User reputation.
recos-injector Streaming event processor for building input streams for GraphJet based services.
graph-feature-service Serves graph features for a directed pair of Users (e.g. how many of User A's following liked Tweets from User B).
topic-social-proof Identifies topics related to individual Tweets.
representation-scorer Compute scores between pairs of entities (Users, Tweets, etc.) using embedding similarity.
Software framework navi High performance, machine learning model serving written in Rust.
product-mixer Software framework for building feeds of content.
timelines-aggregation-framework Framework for generating aggregate features in batch or real time.
representation-manager Service to retrieve embeddings (i.e. SimClusers and TwHIN).
twml Legacy machine learning framework built on TensorFlow v1.

The product surfaces currently included in this repository are the For You Timeline and Recommended Notifications.

For You Timeline

The diagram below illustrates how major services and jobs interconnect to construct a For You Timeline.

The core components of the For You Timeline included in this repository are listed below:

Type Component Description
Candidate Source search-index Find and rank In-Network Tweets. ~50% of Tweets come from this candidate source.
cr-mixer Coordination layer for fetching Out-of-Network tweet candidates from underlying compute services.
user-tweet-entity-graph (UTEG) Maintains an in memory User to Tweet interaction graph, and finds candidates based on traversals of this graph. This is built on the GraphJet framework. Several other GraphJet based features and candidate sources are located here.
follow-recommendation-service (FRS) Provides Users with recommendations for accounts to follow, and Tweets from those accounts.
Ranking light-ranker Light Ranker model used by search index (Earlybird) to rank Tweets.
heavy-ranker Neural network for ranking candidate tweets. One of the main signals used to select timeline Tweets post candidate sourcing.
Tweet mixing & filtering home-mixer Main service used to construct and serve the Home Timeline. Built on product-mixer.
visibility-filters Responsible for filtering Twitter content to support legal compliance, improve product quality, increase user trust, protect revenue through the use of hard-filtering, visible product treatments, and coarse-grained downranking.
timelineranker Legacy service which provides relevance-scored tweets from the Earlybird Search Index and UTEG service.

Recommended Notifications

The core components of Recommended Notifications included in this repository are listed below:

Type Component Description
Service pushservice Main recommendation service at Twitter used to surface recommendations to our users via notifications.
Ranking pushservice-light-ranker Light Ranker model used by pushservice to rank Tweets. Bridges candidate generation and heavy ranking by pre-selecting highly-relevant candidates from the initial huge candidate pool.
pushservice-heavy-ranker Multi-task learning model to predict the probabilities that the target users will open and engage with the sent notifications.

Build and test code

We include Bazel BUILD files for most components, but not a top-level BUILD or WORKSPACE file. We plan to add a more complete build and test system in the future.

Contributing

We invite the community to submit GitHub issues and pull requests for suggestions on improving the recommendation algorithm. We are working on tools to manage these suggestions and sync changes to our internal repository. Any security concerns or issues should be routed to our official bug bounty program through HackerOne. We hope to benefit from the collective intelligence and expertise of the global community in helping us identify issues and suggest improvements, ultimately leading to a better Twitter.

Read our blog on the open source initiative here.

the-algorithm's People

Contributors

dzhao avatar mrauro avatar pouriya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

the-algorithm's Issues

Rewrite in rust?

Is your feature request related to a problem? Please describe.
Code base wirtten in legacy lang

Describe the solution you'd like
Rust is better, trust me bro

Describe alternatives you've considered
No

Additional context
No

Rewrite Twitter mobile apps in Flutter, reasons enlisted inside the issue

Oh Twitter, Twitter, hear me out,
Your mobile app's what I'm talking about.
It's time to make a change, you see,
Rewrite it all in Flutter, please!

Blue's your theme, we all know that,
Flutter's the same, just like a hat.
Both have a bird, that's a fact,
Flutter's mascot's Dash, Twitter's Larry, that's that!

Seven letters each, can't you see?
That's a sign, it's meant to be!
Both of the words rhyme so nice,
Flutter's the perfect spice.

Twitter's app is often slow,
It's like a turtle, don't you know?
Flutter's faster, quick as a flash,
It'll make your app feel like a Dash.

So Twitter, dear, don't be afraid,
Join hands with Flutter, it's not a charade.
Your users will love you more,
And they'll tweet about it, that's for sure!

So let's do this, let's make it real,
With Flutter's help, we'll seal the deal.
Twitter in Flutter, a match made in heaven,
Let's do it now, before it's eleven!

Rewrite in Rust

OMG imagine using that disgusting language over RUST. As a proud rustacean, I’m going to inform you: that’s blasphemy. You can do better. Grab cargo and start using a beautiful memory managed, statically typed, comfortable yet low level language with a spectacular packaging system. No more memory leaks. No more makefiles. End the weird bugs caused by unrequested type casting. Easily find libraries. AND ALL OF THAT IS BLAZING FAST (at C/cpp-level speeds - yay compiled langs and llvm c:). Why wouldn’t you? The syntax is spectacular as well; extremely clean, much better than anything else out there. Those match statements are so extremely pleasant, and the looping conventions are orgasmic. And the compiler is the most useful and polite you’ll come across; no more endlessly scrolling segmentation fault and template errors. It’s amazing and I love it and you should switch now because it’s far superior to literally everything else, all those gross languages you’re used to using. Come to rust and you’ll never look back, it’s so versatile and cleeeeean. Graydon Hoare is literally a god. The rust book is my bible. this is my religion now. USE RUST

It is year 2028 and Linux has been completely rewritten in Rust.

After adding Rust support to Linux kernel in 2021 Linux repo has been flooded with patches and pull requests from brave Rustaceans rewriting critical components in Rust to ensure their stability and memory safety that C could never guarantee. After a few painful years of code reviews and salt coming from C programmers losing their jobs left and right we have finally achieved a 100% Rust Linux kernel. Not a single kernel panic or crash has been reported ever since. In fact, the kernel was so stable that Microsoft gave up all their efforts in Windows as we know it, rewrote it in Rust, and Windows became just another distro in the Linux ecosystem. Other projects and companies soon followed the trend - if you install any Linux distro nowadays it won't come with grep, du or cat - there is only ripgrep, dust and bat. Do you use a graphical interface? Good luck using deprecated projects such as Wayland, Gnome or KDE - wayland-rs , Rsome and RDE is where it's all at. The only serious browser available is Servo and it holds 98% of the market share. Every new game released to the market, including those made by AAA developers, is using the most stable, fast and user-friendly game engine - Bevy v4.20. People love their system and how stable, safe and incredibly fast it is. Proprietary software is basically non-existent at this point. By the year 2035 every single printer, laptop, industrial robot, rocket, autonomous car, submarine, sex toy is powered by software written in Rust. And they never crash or fail. The world is so prosperous and stable that we have finally achieved world peace.

Ferris looks down at what he has created once more and smiles, as he always did. He says nothing as he is just a crab and a mascot, but you can tell from his eyes... That he is truly proud of his community.

Rewrite in rust

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Better
Describe the solution you'd like
A clear and concise description of what you want to happen.
We would have a better ecosystem
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Ill help write it
Additional context
Add any other context or screenshots about the feature request here.
We can do this

the algorithm

not reading all that but happy for you or sorry that happened

Why no assembly?

Surely Twitter could just be written in assembly.

Is that on the timeline?

Who is in charge of the assembly project?

Make it 100% safe

Currently the code is only 1.5% safe please make it 100% safe (by RIIR)

IMPORTANT

Guys please keep this place for real bugs and contributions, 🙏

Remove the code in the algorithm that boosts the tweets of Elon Musk's account

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. I'm always frustrated when Elon appears in people's feeds without their consent.

Describe the solution you'd like
A clear and concise description of what you want to happen.
Could you remove the part of the algorithm that boosts Elon Musk's tweets?
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
No alternatives are in here except making a 3rd party client that filters out Elon Musk's tweets.

Additional context
Add any other context or screenshots about the feature request here.

Rewrite in TI-Basic

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Staying Focused on Scala: Why It's the Right Choice for Our Project

Hey y'all, I hate to be the party pooper, but can we get back on track here? I see a whole lotta talk 'bout rewritin' the codebase in Rust or assembly, but let's not forget about Scala! It's a powerful language that's designed to be concise, expressive, and scalable - perfect for this project. So before we start talkin' 'bout rewrite this and rewrite that, how 'bout someone explains what Scala is and why we're using it in the first place? Let's give it the attention it deserves, y'all!

allow "AI" to tweet and like tweets on your behalf

if you have made a lot of tweets, twitter should have a firm understanding of you as a person by now. naturally, the next step would be a feature which allows "AI" to automatically creates tweets on your behalf -- tweeting what you would have said, and liking tweets that you would have liked. that way, you can just check in and see your virtual "self" tweeting on auto pilot, and nonetheless experience the pleasure of seeing people liking "your" posts. i imagine this is going to be implemented sooner or later by a third party so many as well implement it in-house to have more fine-tuned control over the experience.

Thank you Elon for open sourcing!

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Please open a discussion page.

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.