xai-org/x-algorithm
Algorithm powering the For You feed on X
X For You Feed Algorithm
What it is
- The open‑source core of the For You timeline on X (formerly Twitter). It decides which posts a viewer sees by mixing content from accounts they follow (in‑network) with content discovered from other accounts (out‑of‑network) and then ranking everything with a transformer‑based model.
Key components
- Home Mixer – the main request‑time pipeline that gathers candidates, hydrates them, applies pre‑scoring filters, scores them with the Phoenix model, re‑ranks, and finally selects the top‑K posts.
- Thunder – in‑memory cache of recent posts from followed accounts.
- Phoenix – retrieval model that predicts a viewer’s probability of taking actions (like, retweet, report, dwell time, etc.) on each candidate post.
- SimClusters – similarity‑based source that surfaces posts from accounts the viewer does not follow.
- Visibility‑filtering – a separate subsystem that decides per post whether it should be shown, shown with a notice, behind an interstitial, or dropped, based on labels, blocks, mutes, legal compliance, etc.
- Labeling path – continuous background pipelines that run classifiers (media‑model‑proxy, CLIP, Agatha, BDSM, etc.) and rule engines (Botmaker, Scarecrow, Abuse‑Enforcement) to attach safety and authenticity labels to posts and accounts.
- Blending pipeline – after ranking, non‑post items such as ads, “Who to Follow” recommendations, and prompts are interleaved with the organic timeline.
How it works (high‑level flow)
- Query hydration – collect the viewer’s recent engagement history, follow list, blocks/mutes, etc.
- Candidate sources – query Thunder (in‑network), Phoenix retrieval, SimClusters, and a shared popular‑posts list in parallel.
- Candidate hydration – fetch post text, media, author details, existing labels, language, etc.
- Pre‑scoring filters – drop duplicates, old posts, viewer’s own posts, blocked accounts, etc.
- Scoring – Phoenix predicts action probabilities; a value model combines them with configurable weights; optional VMRanker can call an external reranker.
- Selection – keep the top‑K scored candidates.
- Post‑selection filters – visibility‑filtering decides the final fate of each post; deduplication of conversation threads follows.
- Blending – ads, follow suggestions, and prompts are interleaved with the ranked posts.
- Side effects – log serving events, refresh caches, record ad metrics.
Configuration & experimentation
- All tunable weights and feature flags live in
home-mixer/params/param.rs. Experiments can enable/disable individual stages (e.g., the Brazil 2026 Election filter) without code changes.
What’s not in the repo
- Production data stores, real‑time model training pipelines, and the full set of private safety models. The repository contains the orchestration code and synthetic‑data generation for proof‑of‑concept training.
Transparency tools
- An Under the Hood label‑transparency UI reports to users why a post’s visibility was limited (e.g., legal takedown, compliance filters).
Typical use cases
- Researchers studying large‑scale recommendation pipelines.
- Engineers building similar feed systems who need a reference architecture for candidate generation, scoring, and safety filtering.
- Auditors or policy analysts examining how platform decisions (weights, legal filters) are implemented.
Getting started
- Clone the repo.
- Follow the
READMEsections on synthetic data generation to run a small‑scale Phoenix training run. - Use the provided configuration files to spin up the Home Mixer service locally (requires Rust toolchain).
- Explore the transparency tool by running the
under_the_hoodserver and querying it with a test user ID.
License – see the LICENSE file in the repository.
Related
- Dispatch
- Project
- Project
- Project
- Project