xai-org /x-algorithm

Algorithm powering the For You feed on X

★ 34,166⑂ 5,513👁 321● 166
RustCreated 2026-01-19
34,166
stars
+128+143+658
5,513
forks
321
watchers
–
prs
166
issues
–
releases
–
discussions

README

X For You Feed Algorithm

This repository contains the core code that determines which posts a viewer sees in the For You feed on X. It combines in-network content (from accounts the viewer follows) with out-of-network content (discovered through ML-based retrieval and other mechanisms), filters content based on a variety of inputs, and ranks posts using a transformer model.

 Table of Contents

- Notable Updates
  - October 26th, 2026
  - October 13th, 2026
  - October 8th, 2026
  - September 18th, 2026
  - August 14th, 2026
  - August 13th, 2026
- Overview
- System Architecture
  - Request Path
  - Labeling Path
- Components
- How It Works
  - Scoring and Ranking
  - Filtering
- Experiments and Configuration
- What's not in this repo?
- Under the Hood Label Transparency Tool
- Key Design Decisions
- License

---



 Notable Updates

 October 26th, 2026

- Brazil 2026 Elections filter removed. With the 2026 Brazilian elections over, we have removed Brazil2026ElectionFilter from For You. Posts from the accounts it covered are no longer filtered out because of it. See the August 14th, 2026 update for what the filter did.

 October 13th, 2026

- Retrieval trained to surface posts people read all the way through. Phoenix retrieval is now also trained to surface posts that people read all the way through.

 October 8th, 2026

- Ranking predicts time spent much better. The Phoenix ranking model now does a better job of estimating how long you'll spend on each post: see the code.

 September 18th, 2026

- Under the Hood. Reports now include information about whether one's account or posts have had their visibility limited because of required compliance with law(s). For example, you'll be able to see if any of your posts were withheld from showing in a country following a legal demand — and which country.

 August 14th, 2026

Notable updates:

- How weights work. There's a common misconception about how weights related to actions (e.g. Like, Share, Block, Report, etc) work in ranking. The weights scale the predicted probabilities of such actions (or predicted continuous values, e.g. dwell time) — they do not scale the raw engagement counts, so e.g. it'd be incorrect to see that a report has 468 times higher weight than a like and conclude that e.g. "1 report cancels out 468 likes". The weights are a multiple on your own predicted probability of Liking, Reporting, etc, which is substantially driven by your own behavior. We've added comments to the code so that LLMs or people reading it are more likely to understand it correctly.
- Brazil 2026 Elections. As announced by X, in accordance with Brazilian electoral law, For You began running Brazil2026ElectionFilter, which removed posts from accounts reported to Brazil's Electoral Court for the 2026 election, unless the viewer explicitly follows the account. (Removed after the election; see the October 26th, 2026 update.)

 August 13th, 2026

This release:

- Adds key configuration parameters (including weigh

Snapshot: 2026-11-10T09:35:25Z · Data license Apache-2.0 · JSON