# Twitter algorithm on GitHub: the-algorithm (2023) and x-algorithm (2026)

**Last updated 2026-10-21.** “Twitter algorithm GitHub” points at two repositories. Twitter published [`twitter/the-algorithm`](https://github.com/twitter/the-algorithm) in March 2023: the Twitter-era recommendation services, mostly Scala and Java, with the model code in [`twitter/the-algorithm-ml`](https://github.com/twitter/the-algorithm-ml). The code behind the X For You feed in 2026 is [`xai-org/x-algorithm`](https://github.com/xai-org/x-algorithm), and that is the repo this page maps. This walkthrough is commit [`cb45b55`](https://github.com/xai-org/x-algorithm/commit/cb45b55) (2026-10-09). It follows the repo `README.md` and the file citations in [`X_ALGORITHM_BOOST_PLAYBOOK.md`](https://github.com/abhirupghosh/tweet-factory/blob/main/X_ALGORITHM_BOOST_PLAYBOOK.md). It is a map, not a second ranker.

## What the README says the repo is

The For You feed is assembled per request. In-network posts come from `thunder/`. Out-of-network posts come from `phoenix/` retrieval, `simclusters/`, and `home-mixer/sources/popular_posts_source.rs`. The same model ranks both. Phoenix reads the viewer’s recent engagements and predicts an action probability per post. Weights in the code blend those predictions. A separate blending pipeline adds ads, Who to Follow, and prompts, which the model does not rank.

Ranking sets order. Whether a post can be shown is `visibility-filtering/`.

## Where to read each stage

| Stage | Path the README and the playbook cite |
|---|---|
| Request order | `home-mixer/candidate_pipeline/phoenix_candidate_pipeline.rs` |
| Query hydration | `home-mixer/query_hydrators/` |
| In-network store | `thunder/`, caps in `thunder/config.rs` |
| Out-of-network retrieval | `phoenix/`, source `home-mixer/sources/phoenix_source.rs` |
| Clusters | `simclusters/`, source `home-mixer/sources/simclusters_source.rs` |
| Popular list | `home-mixer/sources/popular_posts_source.rs` |
| Pre-score filters | `home-mixer/filters/` |
| Weighted sum | `xai-value-model/scoring.rs`, defaults in `home-mixer/params/param.rs` |
| Served recompute | `vm-ranker/`, including `vm-ranker/dpp.rs` and `vm-ranker/params.rs` |
| Visibility | `visibility-filtering/rules/registry.rs` |
| Training code | `phoenix/` (Cargo workspace, `pyproject.toml`, `phoenix/QUICKSTART.md`) |

`Tweet Mixer` and the SID source are in the tree and default off. The playbook records `PhoenixMaxResults` 1000, `ThunderMaxResults` 1200, top-50 selection, and a served `RESULT_SIZE` of 35. Those numbers are in [How the X (Twitter) algorithm works](how-the-x-algorithm-works.md).

## What GitHub does not include

The README section “What’s not in this repo?” says the Grox classifier prompts are not shipped. The playbook repeats that: Jinja templates are loaded by name from `grox/flows/ptos/prompts.py` and `grox/flows/upa/prompts.py`, and the prompt bodies are absent. Trained Phoenix weights are also absent. A default of `0.0` on a head means off in the mirrored primary config, not “the head was deleted.”

`phoenix/run_pipeline.py`, the old demo that used favorite 1.0 and reply 0.5, is not in this commit. The August 13, 2026 README release replaced that demonstration model with training code and the published weights.

The string `TweepCred` does not appear in this commit. The account-scoring job that does exist is `user-cred-v2/`, covered on [What is TweepCred](what-is-tweepcred.md).

## How tweet-factory uses the repo

tweet-factory does not run this pipeline. `src/rank/weights.ts` copies the published probability weights and the negative heads, and `tf generate` multiplies those by an editorial strength. The GitHub tree remains the source for the coefficients. A browser pass over one draft is [tweetfactory.sh/score](https://tweetfactory.sh/score/).

## Related

- [How the X (Twitter) algorithm works](how-the-x-algorithm-works.md)
- [X algorithm changes in 2026](x-algorithm-changes-2026.md)
- [Shadowban on X](shadowban-on-x.md)

## FAQ

### Where is the Twitter algorithm on GitHub?

Two places. The 2023 Twitter release is [`twitter/the-algorithm`](https://github.com/twitter/the-algorithm), with models in [`twitter/the-algorithm-ml`](https://github.com/twitter/the-algorithm-ml). The current X code is [`xai-org/x-algorithm`](https://github.com/xai-org/x-algorithm), commit `cb45b55` as of this page. For You order is `home-mixer/candidate_pipeline/phoenix_candidate_pipeline.rs`. Weights are `home-mixer/params/param.rs`. Visibility rules are `visibility-filtering/rules/registry.rs`.

### Is the Twitter algorithm open source?

Mostly. The ranking code is public on GitHub: `twitter/the-algorithm` since March 2023 and `xai-org/x-algorithm` for the current X feed. The `xai-org/x-algorithm` README says the Grox classifier prompts are not shipped, and the trained Phoenix weights are not in the checkout either.

### What is the difference between twitter/the-algorithm and xai-org/x-algorithm?

`twitter/the-algorithm` is the March 2023 Twitter release, built around services such as `home-mixer`, `simclusters-ann`, and `visibilitylib`, mostly in Scala and Java. `xai-org/x-algorithm` is the code X publishes for the For You feed today, with `thunder/`, `phoenix/` retrieval and ranking, and the weights in `home-mixer/params/param.rs`. To check what affects reach now, read `xai-org/x-algorithm`.

### Can you run the whole ranker from the GitHub checkout?

The README says Phoenix is meant to be trainable end to end, with a quickstart and synthetic data. It also says other directories may omit build files. The Grox prompts and the trained production weights are not in the checkout, so a local Phoenix run is not a reproduction of the live For You score.
