OpenSource-Hub

x-algorithm

アプリケーション

xai-org/x-algorithm

X プラットフォームの「おすすめ」フィードにランキングを提供する Rust アルゴリズムシステム。

概要

X社がオープンソース化した推薦エンジンで、「おすすめ」タイムラインに表示する投稿の選定とランク付けに使用される。フォローしているアカウントのコンテンツとフォローしていないアカウントからの発見コンテンツを組み合わせ、可視性ルールでフィルタリングし、Transformer モデルに基づいてスコアリングを行う。リポジトリには、候補取得、学習、ランキング、透明性ツールなどの関連コンポーネントが含まれている。

README プレビュー

# X For You Feed Algorithm\n\nThis 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.\n\n## Table of Contents\n\n- [Notable Updates](#notable-updates)\n  - [August 14th, 2026](#august-14th-2026)\n  - [August 13th, 2026](#august-13th-2026)\n- [Overview](#overview)\n- [System Architecture](#system-architecture)\n  - [Request Path](#request-path)\n  - [Labeling Path](#labeling-path)\n- [Components](#components)\n- [How It Works](#how-it-works)\n  - [Scoring and Ranking](#scoring-and-ranking)\n  - [Filtering](#filtering)\n- [Experiments and Configuration](#experiments-and-configuration)\n- [What's not in this repo?](#whats-not-in-this-repo)\n- [Under the Hood Label Transparency Tool](#under-the-hood-label-transparency-tool)\n- [Key Design Decisions](#key-design-decisions)\n- [License](#license)\n\n---\n\n\n\n## Notable Updates\n\n### August 14th, 2026\n\nNotable updates:\n\n- **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](home-mixer/params/param.rs) [to the code](home-mixer/scorers/ranking_scorer.rs) so that LLMs or people reading it are more likely to understand it correctly.\n- **Brazil 2026 Elections.** As [announced

FAQ (2)

トラブル対応
認証済みのXアカウントがプロフィールページで「Not verified yet」と表示されるのはなぜですか?

これは通常、認証が実際に失われたわけではなく、一時的な認証ステータス/UIの同期の問題です。報告されたケースでは、「About this account」セクションには「Verified since June 2026」および「Identity verified with an official ID」と正しく表示されていた一方で、プロフィールカードには「Not verified yet」と誤って表示されていました。この問題は、アカウントに変更を加えることなく自然に解消されました。トラブルシューティング手順:1) 「About this account」で認証ステータスを確認してください。2) X の iOS アプリを閉じて再度開いてください。3) アプリを最新バージョンに更新してください。4) ログアウトしてから再度ログインしてください。5) サーバー/UIの状態が更新されるのを待ってください。「About this account」セクションでも未完了と表示されている場合を除き、本人確認を繰り返さないでください。不一致が解消されない場合は、X Supportにお問い合わせください。

参照 Issue #114
トラブル対応
TokioとDashMapで並行する「いいね」イベントが重複投稿やネットワーク内スコアの水増しを引き起こす問題を修正する方法

競合状態が発生するのは、共有の Semaphore::new(1) が一度も取得されない一方、DashMap が各操作で個々のシャードしかロックしないためです。そのため、削除済みチェックの読み取り、投稿の挿入、および VecDeque の更新はアトミックではありません。即時の修正: insert_posts() を呼び出す前にセマフォを取得し、操作全体を通じて保持します:

let permit = Arc::clone(&semaphore)
    .acquire_owned()
    .await
    .expect("semaphore closed");

post_store_clone.insert_posts(batch).await?;

drop(permit);

これによりすべての挿入が直列化され、TinyPost エントリの重複が防止されますが、スループットが低下する可能性があります。より細かい粒度の修正として、投稿/著者ごとに外部ロックを追加し、そのロックの下で完全な read-modify-write を実行します:

let lock = self.locks
    .entry(author_id)
    .or_insert_with(|| Arc::new(tokio::sync::Mutex::new(())))
    .clone();

let _guard = lock.lock().await;

if self.deleted_posts.contains_key(&post_id) {
    return Ok(());
}

if self.posts.contains_key(&post_id) {
    return Ok(()); // duplicate event
}

self.posts.insert(post_id, Arc::new(compact_post));
self.original_posts_by_user
    .entry(author_id)
    .or_default()
    .push_back(tiny_post);

同じロックを mark_as_deleted() にも適用し、別のシャードにアクセスする間は DashMap のシャードガードを保持しないでください。2つの同一のいいねイベントを同時に送信し、著者の VecDeque に投稿IDが1度だけ含まれることをアサートして、修正を検証します。

参照 Issue #221