OpenSource-Hub

x-algorithm

애플리케이션

xai-org/x-algorithm

X 플랫폼의 "추천" 피드에 순위를 제공하는 Rust 알고리즘 시스템.

개요

X사가 오픈소스로 공개한 추천 엔진으로, "For You" 타임라인의 게시물 선택 및 순위 지정에 사용됩니다. 인앱 팔로우 콘텐츠와 외부 발견 콘텐츠를 결합하고, 가시성 규칙을 통해 필터링하며, 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 계정이 프로필 페이지에 "아직 인증되지 않음"으로 표시되는 이유는 무엇인가요?

이것은 일반적으로 실제 인증 상실이 아니라 일시적인 인증 상태/UI 동기화 문제입니다. 보고된 사례에서 "이 계정 정보" 섹션에는 "2026년 6월부터 인증됨"과 "공식 신분증으로 신원 인증 완료"가 올바르게 표시되었지만, 프로필 카드에는 "아직 인증되지 않음"이 잘못 표시되었습니다. 이 문제는 계정 변경 없이 저절로 해결되었습니다. 문제 해결 단계: 1) "이 계정 정보"를 확인하여 인증 상태를 확인하세요. 2) X iOS 앱을 닫았다가 다시 여세요. 3) 최신 앱 버전으로 업데이트하세요. 4) 로그아웃했다가 다시 로그인하세요. 5) 서버/UI 상태가 새로고침될 때까지 기다리세요. "이 계정 정보" 섹션에서도 인증이 미완료로 표시되지 않는 한 신원 인증을 반복하지 마세요. 불일치가 계속되면 X Support에 문의하세요.

원본 Issue #114
문제 해결
Tokio와 DashMap을 사용할 때 동시 좋아요 이벤트로 인해 중복 게시물이 발생하고 in-network 점수가 부풀려지는 문제를 해결하는 방법

경합은 공유 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 항목이 방지되지만, 처리량이 감소할 수 있습니다. 더 세분화된 수정을 위해서는 게시물/작성자별로 외부 잠금을 추가하고 해당 잠금 아래에서 전체 읽기-수정-쓰기를 수행하십시오:

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 샤드 가드를 유지하지 마십시오. 동일한 좋아요 이벤트 두 개를 동시에 전송하고 작성자의 VecDeque에 게시물 ID가 한 번만 포함되어 있는지 확인하여 수정 사항을 검증하십시오.

원본 Issue #221