How Author Diversity Decay Reduces Scores for Repeated Authors in X Algorithm

Author diversity decay progressively lowers the ranking scores of posts from repeatedly seen authors by applying a multiplicative penalty that grows exponentially with each additional appearance, ensuring a diverse content feed.

The home-mixer component in the xai-org/x-algorithm repository implements author diversity decay to prevent content monopolization by a small set of creators. This mechanism adjusts raw ranking scores based on how many times an author has already appeared in the candidate pool, promoting editorial diversity without hard limits on author frequency.

How Author Diversity Decay Works in X Algorithm

The implementation follows a three-stage pipeline in home-mixer/scorers/ranking_scorer.rs. Each stage transforms the data to progressively penalize repeated authors while maintaining ranking stability.

Counting Previous Author Appearances

The system first establishes the order of posts by sorting them according to their pre-diversity scores in descending order. The author_pool_counts function then iterates through this ranked list to count how many times each author has already been encountered.

// home-mixer/scorers/ranking_scorer.rs → lines 29-45
let mut indexed = pre_diversity_scores.iter().enumerate().collect();
indexed.sort_by(|(_, a), (_, b)| b.partial_cmp(a).unwrap_or(Ordering::Equal));
let mut counts = vec![0u32; candidates.len()];
let mut author_counts = FxHashMap::default();
for (idx, _) in indexed {
    let author_id = candidates[idx].author_id;
    let k = author_counts.get(&author_id).copied().unwrap_or(0);
    counts[idx] = k;                     // number of prior posts by this author
    author_counts.insert(author_id, k + 1);
}

This produces a vector where each element represents the number of previous appearances (0 for the first post, 1 for the second, etc.) for the corresponding candidate.

Calculating the Decay Multiplier

For each appearance count k, the diversity_multiplier function computes a value between a configured floor and 1.0. The formula applies an exponential decay based on the AuthorDiversityDecay parameter:

// home-mixer/scorers/ranking_scorer.rs → lines 25-27
fn diversity_multiplier(decay_factor: f64, floor: f64, exponent: f64) -> f64 {
    (1.0 - floor) * decay_factor.powf(exponent) + floor
}

The exponent corresponds directly to the author-appearance count. When k is 0 (first appearance), the multiplier is 1.0 (no penalty). As k increases, the multiplier approaches the AuthorDiversityFloor asymptotically. These parameters are defined in home-mixer/params/param.rs and supplied via query context.

Applying the Penalty to Final Scores

The apply_author_diversity function combines these stages to produce final adjusted scores. It multiplies each pre-diversity score by its corresponding decay multiplier:

// home-mixer/scorers/ranking_scorer.rs → lines 66-78
let counts = Self::author_pool_counts(candidates, pre_diversity_scores);
let multipliers = Self::author_diversity_multipliers(query, &counts);
pre_diversity_scores
    .iter()
    .zip(multipliers)
    .map(|(&score, multiplier)| score * multiplier)
    .collect()

This transformation occurs automatically when the EnableAuthorDiversity flag is set in the query parameters, feeding the adjusted scores into downstream ranking logic.

Code Example: Simulating Author Diversity Decay

The following Rust example demonstrates how identical raw scores degrade for successive posts from the same author using a decay factor of 0.5 and a floor of 0.25:

// Example: three posts from the same author with identical raw scores
let raw_scores = vec![1.0, 1.0, 1.0];
let decay = 0.5;          // AuthorDiversityDecay
let floor = 0.25;         // AuthorDiversityFloor

// Simulated counts: 0, 1, 2 (first, second, third appearance)
let counts = vec![0u32, 1, 2];
let multipliers: Vec<f64> = counts.iter()
    .map(|&k| RankingScorer::diversity_multiplier(decay, floor, k as f64))
    .collect();   // → [1.0, 0.625, 0.25]

let final_scores: Vec<f64> = raw_scores.iter()
    .zip(multipliers)
    .map(|(&s, m)| s * m)
    .collect();   // → [1.0, 0.625, 0.25]

The first post retains its full score of 1.0, the second drops to 0.625, and the third falls to the floor of 0.25, effectively eliminating it from top positions unless its original score was substantially higher than competitors.

Configuration Parameters for Author Diversity

According to the source code in home-mixer/params/param.rs, three parameters control this behavior:

  • AuthorDiversityDecay: The base value (between 0.0 and 1.0) raised to the power of the appearance count. Lower values create steeper penalties.
  • AuthorDiversityFloor: The minimum multiplier allowed, preventing scores from approaching zero regardless of repetition.
  • EnableAuthorDiversity: A boolean flag that determines whether apply_author_diversity is invoked during the scoring pipeline.

Tuning these values allows platform operators to balance between author diversity and content quality signals, with aggressive decay factors heavily suppressing repeated authors while higher floors preserve their ranking potential.

Summary

  • Author diversity decay uses exponential penalties based on prior author appearances in the ranked candidate list.
  • The author_pool_counts function in ranking_scorer.rs tracks repetition order, while diversity_multiplier applies the mathematical decay function.
  • Final scores equal pre-diversity scores multiplied by decay values ranging from 1.0 down to AuthorDiversityFloor.
  • The mechanism only activates when EnableAuthorDiversity is set to true in the query parameters.
  • Configuration through AuthorDiversityDecay and AuthorDiversityFloor allows granular control over the diversity-quality tradeoff.

Frequently Asked Questions

What is the formula for author diversity decay in X Algorithm?

The formula implemented in home-mixer/scorers/ranking_scorer.rs is (1.0 - floor) * decay_factor.powf(exponent) + floor, where exponent is the number of previous appearances by that author. This produces a multiplier that starts at 1.0 and asymptotically approaches the floor value as the author appears more frequently.

Where is author diversity decay implemented in the X Algorithm codebase?

The core logic resides in home-mixer/scorers/ranking_scorer.rs, specifically within the author_pool_counts, diversity_multiplier, and apply_author_diversity functions. The tunable parameters are defined in home-mixer/params/param.rs, and the candidate data structures live in home-mixer/models/candidate.rs.

How can I disable author diversity decay in X Algorithm?

Set the EnableAuthorDiversity parameter to false in the query configuration. When disabled, the scoring pipeline skips the apply_author_diversity step entirely, and posts receive their original pre-diversity scores without author-based penalties.

What is the minimum score multiplier for repeated authors?

The minimum multiplier is controlled by the AuthorDiversityFloor parameter. Regardless of how many times an author appears, the multiplier never falls below this value. For example, if the floor is set to 0.25, even the tenth post from the same author will receive at least 25% of its original score.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →