twitter/the-algorithm

Source code for the X Recommendation Algorithm

View on GitHub ↗Jump to charts ↓

Summary Information

Updated 37 minutes ago
Added to GitGenius on January 20th, 2026
Created on March 27th, 2023
Open Issues & Pull Requests: 522 (+0)
Number of forks: 13,287
Total Stargazers: 73,869 (+0)
Total Subscribers: 408 (+0)

Repository Insights (GitGenius)

Median issue/PR response: 6.3 days
Mean response time: 112.7 days
90th percentile: 546.3 days
Tracked items: 167

How this project is maintained

Around half of the issues opened in the past year never receive a reply. 100% of open issues come from outside the core team, so the backlog reflects real-world use rather than internal planning. 67% of tracked open issues have had no activity in three months, so the open count overstates what is actively being worked. Only 1% of issues opened in the past year have been closed. Three people close 51% of everything that gets resolved.

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Open issues: 225
New in 7 days: 2
Closed in 7 days: 0
Avg open age: 576 days
Stale 30+ days: 212
Stale 90+ days: 196

Recent activity

Opened in 7 days: 1
Closed in 7 days: 0
Comments in 7 days: 3
Events in 7 days: 4

Top labels

  • unrelated bug or feature (31)
  • project maintenance (3)
  • code quality (1)
  • documentation (1)
  • enhancement (1)
  • hall of fame (1)

Detailed Description

X's Recommendation Algorithm is the source code repository for the recommendation and content ranking systems that power X's feed delivery across all product surfaces, including the For You Timeline, Search, Explore, and Notifications. Written primarily in Scala, the repository represents a comprehensive open-source release of the infrastructure and machine learning models that determine which posts and content users see on the platform.

The repository is organized around three primary architectural layers: data services, machine learning models, and software frameworks. The data layer includes tweetypie, which handles core post reading and writing operations, unified-user-actions, which provides real-time streams of user interactions, and user-signal-service, a centralized platform for retrieving both explicit signals like likes and replies and implicit signals such as profile visits and tweet clicks. These foundational data services feed into the broader recommendation pipeline.

The model layer contains several key components for ranking and personalization. SimClusters performs community detection and generates sparse embeddings organized by community membership. TwHIN provides dense knowledge graph embeddings for both users and posts. The real-graph model predicts the likelihood of user-to-user interactions, while tweepcred applies a Page-Rank algorithm to calculate user reputation scores. Additional models handle trust and safety by detecting NSFW and abusive content, and topic-social-proof identifies topics related to individual posts. The recos-injector streams events to build input for GraphJet-based services, while graph-feature-service computes features describing interactions between user pairs.

The software framework layer includes navi, a high-performance machine learning model serving system written in Rust, and product-mixer, a framework for constructing content feeds. The timelines-aggregation-framework generates aggregate features in both batch and real-time contexts, representation-manager retrieves embeddings, and twml provides legacy machine learning infrastructure built on TensorFlow v1.

For the For You Timeline specifically, the repository details candidate sourcing from search-index for in-network posts, tweet-mixer for out-of-network coordination, user-tweet-entity-graph for graph-based candidate discovery, and follow-recommendation-service for account recommendations. Ranking occurs through light-ranker and heavy-ranker models, with home-mixer serving as the main construction and serving service. Visibility-filters handle content filtering for compliance and quality, while timelineranker provides a legacy relevance-scoring service.

Recommended Notifications are powered by pushservice as the main recommendation engine, supported by pushservice-light-ranker for initial candidate pre-selection and pushservice-heavy-ranker, a multi-task learning model predicting user engagement probabilities.

The repository overlaps in contributors with microsoft/vscode, microsoft/typescript, and rust-lang/rust, suggesting cross-pollination with major open-source projects. Most active issue labels focus on unrelated bugs or features, documentation, and enhancements. The repository uses Bazel for building most components but lacks a top-level BUILD or WORKSPACE file, with plans to add more complete build and test infrastructure in the future.