Skip to content

Instantly share code, notes, and snippets.

@RichardBray
Created October 1, 2025 09:15
Show Gist options
  • Select an option

  • Save RichardBray/90bf60efb75990672e8310d7bb009098 to your computer and use it in GitHub Desktop.

Select an option

Save RichardBray/90bf60efb75990672e8310d7bb009098 to your computer and use it in GitHub Desktop.
X optimizations for 'For You' page from algo

X "For You" Page Algorithm Optimization Guide

Executive Summary

Based on analysis of X's recommendation algorithm codebase, this document outlines key strategies to improve content visibility on the "For You" timeline. The algorithm uses a sophisticated multi-stage ranking system that considers engagement signals, author credibility, content quality, and user behavior patterns.

Core Algorithm Architecture

1. Multi-Stage Ranking Pipeline

The "For You" timeline uses a complex ranking system:

  • Candidate Sources: Multiple pipelines fetch potential content

    • ForYouScoredTweetsCandidatePipelineConfig: Main scored tweets pipeline
    • ForYouExplorationTweetsCandidatePipelineConfig: Discovery content
    • Video tweets, communities, and other specialized pipelines
  • Feature Hydration: Rich metadata extraction

    • Engagement counts (favorites, replies, retweets, quotes, bookmarks)
    • Author verification status (blue, gold, gray, legacy)
    • Content features (video, media, language, NSFW detection)
    • Social context (in-network, followers, communities)
  • Ranking Models: Neural network scoring

    • Light Ranker: Initial filtering
    • Heavy Ranker: Detailed scoring
    • Phoenix Model: Final reranking

2. Key Ranking Signals

Primary Engagement Metrics

From TweetEngagementCounts and scoring features:

  • Favorite Count: Weighted heavily in ranking
  • Reply Count: Conversation engagement signal
  • Retweet Count: Amplification signal
  • Quote Count: Engagement with commentary
  • Bookmark Count: Long-term value signal

Author Credibility Features

From ForYouScoredTweetsResponseFeatureTransformer:

AuthorIsBlueVerifiedFeature
AuthorIsGoldVerifiedFeature  
AuthorIsGrayVerifiedFeature
AuthorIsLegacyVerifiedFeature
AuthorIsCreatorFeature
AuthorFollowersFeature

Content Quality Signals

  • Video Content: HasVideoFeature, VideoDurationMsFeature
  • Media Richness: TweetMediaIdsFeature
  • Grok Annotations: Content classification and quality scoring
  • Language Detection: TweetLanguageFeature

Optimization Strategies

1. Content Creation Best Practices

Timing and Frequency

  • Peak Hours: Post during high-activity periods
  • Consistency: Regular posting maintains audience engagement
  • Fresh Content: New posts get exploration pipeline consideration

Content Format Optimization

  • Video Priority: Videos get special treatment in ForYouScoredVideoTweetsCandidatePipelineConfig
  • Media-Rich Posts: Include images, videos, GIFs
  • Thread Structure: Conversational threads get conversation module treatment

Engagement Optimization

  • Conversation Starters: Posts that generate replies rank higher
  • Shareable Content: High retweet/quote potential
  • Bookmark-Worthy: Content users save for later

2. Author Profile Enhancement

Verification Status

  • Verification Benefits: All verification types (blue, gold, gray, legacy) boost visibility
  • Creator Status: AuthorIsCreatorFeature provides ranking advantage
  • Follower Growth: AuthorFollowersFeature influences ranking

Network Building

  • In-Network Advantage: InNetworkFeature gives preference to followed accounts
  • Cross-Pollination: Engage with accounts outside your immediate network
  • Community Participation: CommunityIdFeature and CommunityNameFeature matter

3. Engagement Strategy

Early Engagement Critical

  • First Hour: Initial engagement heavily influences ranking
  • Reply Engagement: Posts with author replies get PredictedReplyEngagedByAuthorScoreFeature boost
  • Conversation Depth: Multi-level conversations get conversation module treatment

Quality over Quantity

  • Meaningful Interactions: Algorithm detects genuine vs. spam engagement
  • Diverse Engagement: Mix of favorites, replies, retweets
  • User Actions: UserActionsSizeFeature and UserActionsContainsExplicitSignalsFeature tracked

4. Technical Optimization

Content Features

  • Language Consistency: TweetLanguageFeature helps targeting
  • Media Optimization: Proper video duration, quality
  • Text Quality: Avoid spam triggers, NSFW content (GrokIsNsfwFeature)

Avoiding Penalties

  • Spam Detection: GrokIsSpamFeature can limit reach
  • Low Quality: GrokIsLowQualityFeature reduces visibility
  • Violent Content: GrokIsViolentFeature triggers filtering

Advanced Insights

1. Exploration Pipeline

The ForYouExplorationTweetsCandidatePipelineConfig provides discovery opportunities:

  • Follower Count Threshold: ExplorationTweetsMaxFollowerCountParam (default: unlimited)
  • Injection Frequency: InNetworkExplorationTweetsMinInjectionIntervalParam (30 minutes)
  • Position: ExplorationTweetsTimelinePosition (default: position 15)

2. Scoring Models

Multiple prediction models influence ranking:

  • Engagement Predictions: Favorite, reply, retweet, share scores
  • Quality Predictions: Dwell time, profile clicks, negative feedback
  • Content Scores: Video quality, screenshot, bookmark predictions

3. Real-Time Adaptation

  • Real-Time Aggregates: EngagementsReceivedByAuthorRealTimeAggregateFeatureHydrator
  • User Behavior: Immediate response influences subsequent ranking
  • Trend Detection: Content can gain viral momentum quickly

Implementation Checklist

Immediate Actions

  1. Optimize Posting Schedule: Identify peak engagement times
  2. Enhance Profile: Complete verification if eligible
  3. Content Audit: Remove low-quality posts
  4. Engagement Strategy: Respond to comments promptly

Medium-Term Strategy

  1. Content Diversification: Mix text, images, videos
  2. Network Expansion: Engage with new audiences
  3. Community Building: Participate in relevant communities
  4. Analytics Monitoring: Track which content performs best

Long-Term Growth

  1. Authority Building: Establish expertise in niche
  2. Collaboration: Partner with other creators
  3. Platform Features: Utilize all X features (threads, spaces, etc.)
  4. Algorithm Adaptation: Stay updated on algorithm changes

Monitoring and Metrics

Key Performance Indicators

  • Engagement Rate: Total engagements per follower
  • Reach Expansion: Non-follower impressions
  • Conversation Depth: Reply threads and interactions
  • Content Lifespan: How long content continues to get engagement

Tools and Analytics

  • X Analytics: Native platform insights
  • Third-Party Tools: Advanced analytics platforms
  • A/B Testing: Test different content formats
  • Competitor Analysis: Study successful accounts in your niche

Conclusion

Success on X's "For You" page requires understanding and working with the algorithm's sophisticated ranking system. Focus on creating high-quality, engaging content while building authentic connections with your audience. The algorithm rewards genuine engagement, content quality, and consistent value delivery.

Remember that the algorithm continuously evolves, so stay adaptable and keep testing new approaches. The key is balancing technical optimization with authentic community building.


Note: This analysis is based on the open-source X algorithm repository. Some implementation details may vary, and the platform continuously updates its ranking systems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment