How the Out-of-Network Discount Works in the X Feed Algorithm

The X feed algorithm applies a multiplicative discount of 25% (using a factor of 0.75) to out-of-network candidates via the configurable rust_home_mixer_oon_weight_factor parameter.

The out-of-network discount is a core mechanism in the X (formerly Twitter) feed ranking system that reduces the visibility of content originating from outside a viewer's social graph. According to the xai-org/x-algorithm source code, this discount ensures that posts from accounts the user does not follow receive lower base relevance scores than in-network content. The implementation relies on a configurable weight factor applied during the final scoring phase of the home feed mixer.

Understanding the Out-of-Network Discount Logic

When the RankingScorer processes candidates for the home timeline, it distinguishes between content from followed accounts (in-network) and content from accounts the user does not follow (out-of-network). For out-of-network candidates, the algorithm multiplies the base relevance score by the OON weight factor to de-prioritize external content.

The default configuration sets this factor to 0.75, meaning out-of-network posts receive only 75% of the score they would otherwise earn. This 25% reduction applies after all other relevance calculations but before final ranking, creating a tunable boundary between social graph content and external recommendations.

Implementation in the Ranking Scorer

The discount logic lives in home-mixer/scorers/ranking_scorer.rs, where the scorer retrieves the configuration flag and conditionally applies the multiplier.

Parameter Configuration

The weight factor is defined as a configurable parameter in home-mixer/params/param.rs. The system exposes this value through feature flags using the parameter name rust_home_mixer_oon_weight_factor, allowing real-time adjustment without code deployment. This configuration-based approach enables the platform to tune the boundary between in-network and out-of-network content dynamically.

Score Calculation Logic

Inside the RankingScorer implementation, the code retrieves the factor from query parameters and applies it during candidate evaluation:

// Retrieve the OON weight factor from feature flags
let oon_weight_factor = query.params.get(OonWeightFactor);

// Apply discount for out-of-network candidates
if !candidate.is_in_network {
    score = base_score * oon_weight_factor;
}

This logic executes for every candidate in the scoring pipeline. The is_in_network boolean property determines whether the candidate originates from the viewer's social graph, triggering the multiplication when the value is false.

Code Example: Verifying the Discount Behavior

The repository includes unit tests in home-mixer/scorers/ranking_scorer.rs that validate the discount calculation. The following pattern demonstrates how to verify that out-of-network candidates receive exactly 75% of their in-network equivalent scores:

// Configure the scorer with the default OON weight factor
let query = query_with_flags(&[
    ("rust_home_mixer_oon_weight_factor", "0.75"), // 25% discount
    ("rust_home_mixer_value_model_mode", "weighted"),
]);

// Create test candidates: one in-network, one out-of-network
let candidates = vec![
    candidate(1, Some(true)),   // in-network
    candidate(2, Some(false)),  // out-of-network
];

let scored = scorer.score(&query, &candidates).await;

// Verify the discount is applied correctly
let in_network_score = scored[0].as_ref().unwrap().score.unwrap();
let oon_score = scored[1].as_ref().unwrap().score.unwrap();
assert!((oon_score - in_network_score * 0.75).abs() < 1e-9);

This test confirms that when two candidates have identical base relevance scores, the out-of-network candidate's final score equals the in-network score multiplied by 0.75.

Configuration and Tuning

The out-of-network discount operates as a feature flag-controlled parameter, making it adjustable per request or through gradual rollouts. Platform operators can modify the rust_home_mixer_oon_weight_factor value to:

  • Increase the discount (lower values) to prioritize social graph content more aggressively
  • Decrease the discount (higher values) to surface more external recommendations
  • Set the factor to 1.0 to effectively disable the out-of-network penalty

According to the source code analysis, the parameter retrieval happens at the beginning of the scoring process, ensuring the factor remains consistent across all candidates within a single ranking request.

Summary

  • The out-of-network discount applies a multiplicative factor of 0.75 (default) to candidates outside the viewer's social graph.
  • Implementation resides in home-mixer/scorers/ranking_scorer.rs within the RankingScorer logic.
  • The configurable parameter rust_home_mixer_oon_weight_factor controls the discount magnitude via feature flags.
  • Out-of-network candidates receive 75% of their base relevance score compared to identical in-network content.
  • Unit tests verify the precise mathematical application of this discount in the scoring pipeline.

Frequently Asked Questions

What is the default out-of-network discount value in the X algorithm?

The default value is 0.75, which applies a 25% reduction to the base relevance scores of out-of-network candidates. This means content from accounts the user does not follow starts with a 25% penalty compared to social graph content before other ranking factors are considered.

How is the out-of-network discount applied in the X feed algorithm?

The discount applies as a multiplicative factor during the final scoring phase. When candidate.is_in_network evaluates to false, the RankingScorer multiplies the candidate's base score by the rust_home_mixer_oon_weight_factor. This occurs in home-mixer/scorers/ranking_scorer.rs after relevance calculations but before final ranking.

Can the out-of-network discount factor be adjusted without deploying new code?

Yes. The factor is configured through the rust_home_mixer_oon_weight_factor feature flag, defined in home-mixer/params/param.rs. This allows real-time adjustment of the discount rate via feature flag systems without requiring code changes or service restarts.

Where is the out-of-network discount logic implemented in the x-algorithm codebase?

The core logic resides in home-mixer/scorers/ranking_scorer.rs, specifically within the scoring method that checks the is_in_network property. The parameter definition exists in home-mixer/params/param.rs, and comprehensive unit tests verifying the 0.75 multiplier behavior appear in the test section of the ranking scorer file.

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 →