Author Diversity Decay Mechanism in the X Algorithm: Preventing Consecutive Same-Author Posts

The Author Diversity decay mechanism applies a geometric score penalty to posts based on how many times their author has already appeared in the current feed, ensuring the For-You timeline interleaves content from different creators rather than showing consecutive posts from the same account.

The Author Diversity decay mechanism is a core component of the ranking pipeline in the open-source X Algorithm (xai-org/x-algorithm). By dynamically adjusting post scores according to author repetition, this system ensures the For-You feed remains varied and prevents any single creator from dominating a user's timeline.

How the Author Diversity Decay Mechanism Works

The mechanism operates during the final scoring phase, after raw model predictions are computed but before the final ranked slate is returned.

Configuration Parameters

Two tunable parameters control the decay behavior, both defined in home-mixer/params/param.rs (lines 35-44):

  • rust_home_mixer_author_diversity_decay — The base decay factor (default 0.5) that determines how quickly scores decrease with each additional post from the same author.
  • rust_home_mixer_author_diversity_floor — The minimum multiplier any post can receive (default 0.25), preventing scores from collapsing to zero.

A third boolean flag, rust_home_mixer_enable_author_diversity (default true), controls whether the mechanism is active.

Counting Author Appearances

Before applying penalties, the system counts how many times each author appears in the current candidate slate. The author_pool_counts function in home-mixer/scorers/ranking_scorer.rs (lines 629-644) builds this mapping based on the ordering determined by pre-diversity scores.

// home-mixer/scorers/ranking_scorer.rs
fn author_pool_counts(candidates: &[PostCandidate], pre_diversity_scores: &[f64]) -> Vec<u32> {
    /* ... */
}

Computing the Diversity Multiplier

The core mathematical logic resides in the diversity_multiplier function (lines 625-627). For a given author who has appeared k times already, the multiplier is calculated as:

fn diversity_multiplier(decay_factor: f64, floor: f64, exponent: f64) -> f64 {
    (1.0 - floor) * decay_factor.powf(exponent) + floor
}

This yields a geometric decay starting at 1.0 for the author's first post (when k = 0), then decreasing by the decay factor for each subsequent appearance. The value never drops below the configured floor, ensuring posts retain some ranking potential regardless of author frequency.

Applying the Decay to Post Scores

The apply_author_diversity function (lines 666-678) orchestrates the final adjustment. It retrieves the appearance counts, computes multipliers for each candidate, and multiplies the raw scores:

fn apply_author_diversity(
    query: &ScoredPostsQuery,
    candidates: &[PostCandidate],
    pre_diversity_scores: &[f64],
) -> Vec<f64> {
    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()
}

The scorer checks rust_home_mixer_enable_author_diversity at lines 14-15. If disabled, the function returns a vector of 1.0 values, effectively bypassing the decay and preserving original scores.

Why It Prevents Consecutive Same-Author Posts

Because the multiplier shrinks geometrically with each additional appearance, subsequent posts from the same author receive progressively lower effective scores. With the default decay factor of 0.5, the second post from an author receives a 0.75 multiplier, the third receives 0.625, and the fourth receives 0.5625, asymptotically approaching the floor of 0.25.

This mathematical penalty ensures that unless a post has an exceptionally high raw model score, it will rank below posts from authors who have not yet appeared in the slate. The ranking pipeline naturally interleaves content from diverse creators, eliminating contiguous blocks from single accounts and enforcing temporal diversity across the timeline.

Implementation Example

The following example demonstrates how to apply the Author Diversity decay manually using the internal API:

use home_mixer::scorers::ranking_scorer::RankingScorer;
use home_mixer::params::ScoredPostsQuery;

// Pre-diversity scores for three candidate posts
let pre_scores = vec![0.9, 0.85, 0.8];
let candidates = vec![/* PostCandidate instances */];

// Default query with decay=0.5, floor=0.25
let query = ScoredPostsQuery::default();

// Apply author diversity adjustments
let adjusted = RankingScorer::apply_author_diversity(&query, &candidates, &pre_scores);
// adjusted[0] remains 0.9 if author is new
// adjusted[1] becomes 0.6375 if same author as index 0 (0.85 * 0.75)

Disabling the Mechanism

To bypass the Author Diversity logic for debugging or experimental ranking, disable the feature via query parameters:

let mut query = ScoredPostsQuery::default();
query.params.set_bool("rust_home_mixer_enable_author_diversity", false);

let scores = RankingScorer::apply_author_diversity(&query, &candidates, &raw_scores);
// All multipliers are 1.0 → scores remain unchanged from raw predictions

Summary

  • Geometric decay: The mechanism uses an exponential decay formula (1.0 - floor) * decay^k + floor to penalize repeated authors, where k is the number of previous appearances.
  • Configurable thresholds: Two parameters (rust_home_mixer_author_diversity_decay and rust_home_mixer_author_diversity_floor) control the penalty strength and minimum score boundary.
  • Implementation location: Core logic resides in home-mixer/scorers/ranking_scorer.rs, specifically within apply_author_diversity (lines 666-678) and diversity_multiplier (lines 625-627).
  • Toggle control: The feature can be disabled via rust_home_mixer_enable_author_diversity without modifying source code.
  • Diversity enforcement: By reducing scores for repeat authors, the system algorithmically enforces author diversity rather than relying solely on raw engagement predictions.

Frequently Asked Questions

What is the default decay factor in the X Algorithm?

The default value for rust_home_mixer_author_diversity_decay is 0.5, and the default floor (rust_home_mixer_author_diversity_floor) is 0.25. These values are defined in home-mixer/params/param.rs and provide a balanced penalty that halves the distance to the floor with each additional post from the same author.

How does the Author Diversity mechanism affect post ranking?

Posts receive a multiplier between 0.25 and 1.0 based on how many times their author has already appeared in the current feed. This multiplier scales the raw machine learning score, meaning a high-engagement post from a frequently appearing author may rank below a moderately engaging post from a new author in the same batch.

Can the Author Diversity decay be disabled?

Yes. Setting the boolean parameter rust_home_mixer_enable_author_diversity to false causes the apply_author_diversity function to return a vector of 1.0 multipliers, effectively neutralizing the decay mechanism and allowing raw scores to pass through unchanged. This check occurs in the score method around lines 14-15 of ranking_scorer.rs.

At what point does the diversity multiplier reach its floor?

The multiplier asymptotically approaches the configured floor (default 0.25) but technically never reaches it mathematically. However, with a decay factor of 0.5, the multiplier reaches approximately 0.26 by the fifth post from the same author, effectively hitting the floor for practical ranking purposes within a standard batch size.

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 →