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.
According to GitGenius tracking data, the repository has maintained approximately 73,500 stargazers with minimal recent fluctuation. Issue and pull request response latency shows a median of 124.5 hours across 172 tracked items, though mean latency extends to 2931.1 hours, indicating variable response times. The most active contributors tracked include ghost with 52 events, AKArien with 34 events, and immafrog with 21 events. 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.