# What Are the Two Main Candidate Sources for the X For You Feed?

> Discover the two main candidate sources powering the X For You feed: the Follow-Based Timeline and the Recommendation Engine Feed. Learn how your personalized content is curated.

- Repository: [SpaceXAI Org/x-algorithm](https://github.com/xai-org/x-algorithm)
- Tags: deep-dive
- Published: 2026-09-12

---

**The X For You feed is built from two primary candidate sources: the Follow-Based Timeline, which aggregates posts from accounts the user follows, and the Recommendation Engine Feed, which surfaces content from machine learning models based on inferred interests and content relevance.**

The `xai-org/x-algorithm` repository contains the open-source implementation of X's recommendation system. Understanding the **two main candidate sources for the X For You feed** reveals how the platform balances social graph content with algorithmic discovery.

## The Two Main Candidate Sources for the X For You Feed

The feed generation pipeline defined in [`phoenix/xrex/configs/data_feeds.py`](https://github.com/xai-org/x-algorithm/blob/main/phoenix/xrex/configs/data_feeds.py) instantiates two distinct candidate sources. These streams are retrieved independently before being merged into the final personalized timeline.

### Follow-Based Timeline

The **Follow-Based Timeline** retrieves organic posts exclusively from the user’s social graph. This source ensures that content from followed accounts remains prominent in the feed, preserving the classic "Home" timeline experience within the For You tab.

According to the source code in [`phoenix/xrex/configs/data_feeds.py`](https://github.com/xai-org/x-algorithm/blob/main/phoenix/xrex/configs/data_feeds.py), this feed is registered as `follow_timeline`:

```python

# phoenix/xrex/configs/data_feeds.py

from .config_registry import register_feed

@register_feed(name="follow_timeline")
def follow_timeline_feed(user_id):
    # Pull recent posts from accounts the user follows

    return fetch_follow_posts(user_id)

```

The actual retrieval of follow relationships is handled by [`sid_services.py`](https://github.com/xai-org/x-algorithm/blob/main/sid_services.py) in the inference layer, which queries the social graph to fetch posts from followed accounts.

### Recommendation Engine Feed

The **Recommendation Engine Feed** (also referred to as the Explore or Interest feed) generates candidates from X's machine learning recommendation system. Unlike the follow-based source, this stream surfaces posts from accounts the user does not follow, using collaborative filtering, content-based ranking, and relevance models to predict interest.

The feed is registered as `recommended_feed` in the same configuration file:

```python

# phoenix/xrex/configs/data_feeds.py

@register_feed(name="recommended_feed")
def recommended_feed(user_id):
    # Query the ML recommendation models for candidate posts

    return query_recsys_models(user_id)

```

The underlying recommendation models are implemented in [`phoenix/xrex/models/recsys_two_tower_model.py`](https://github.com/xai-org/x-algorithm/blob/main/phoenix/xrex/models/recsys_two_tower_model.py), which provides the two-tower architecture used to generate these candidates. The serving infrastructure in [`phoenix/xrex/inference/gen_recs_services.py`](https://github.com/xai-org/x-algorithm/blob/main/phoenix/xrex/inference/gen_recs_services.py) then exposes these candidates to the feed building pipeline.

## How the Candidate Sources Are Merged

During the serving phase, the X algorithm merges and ranks content from both sources to produce the final For You feed. The `build_for_you_feed` function handles the combination logic, interleaving follow-based content with algorithmic recommendations.

```python

# phoenix/xrex/configs/data_feeds.py

def build_for_you_feed(user_id, max_items=50):
    follows = follow_timeline_feed(user_id)
    recommendations = recommended_feed(user_id)

    # Simple interleaving merge; real implementation uses a learned ranker

    merged = interleave(follows, recommendations, max_items)
    return merged

```

The merging process typically employs a learned ranking model that weighs signals from both sources, ensuring the final ranked list balances recency from follows with relevance from the recommendation engine.

## Key Implementation Files in xai-org/x-algorithm

- **[`phoenix/xrex/configs/data_feeds.py`](https://github.com/xai-org/x-algorithm/blob/main/phoenix/xrex/configs/data_feeds.py)** – Defines the `follow_timeline` and `recommended_feed` candidates, including the `build_for_you_feed` merging logic.
- **[`phoenix/xrex/models/recsys_two_tower_model.py`](https://github.com/xai-org/x-algorithm/blob/main/phoenix/xrex/models/recsys_two_tower_model.py)** – Implements the two-tower recommendation model used to generate candidates for the recommended feed.
- **[`phoenix/xrex/inference/gen_recs_services.py`](https://github.com/xai-org/x-algorithm/blob/main/phoenix/xrex/inference/gen_recs_services.py)** – Serves recommendation candidates from the ML models to the feed building pipeline.
- **[`phoenix/xrex/inference/sid_services.py`](https://github.com/xai-org/x-algorithm/blob/main/phoenix/xrex/inference/sid_services.py)** – Provides the social graph service that fetches posts from the user's followed accounts for the follow-based timeline.

## Summary

- The **X For You feed** combines two distinct candidate sources: the **Follow-Based Timeline** and the **Recommendation Engine Feed**.
- The **Follow-Based Timeline** sources content exclusively from accounts the user follows, retrieved via `follow_timeline_feed` in [`data_feeds.py`](https://github.com/xai-org/x-algorithm/blob/main/data_feeds.py).
- The **Recommendation Engine Feed** generates candidates using machine learning models implemented in [`recsys_two_tower_model.py`](https://github.com/xai-org/x-algorithm/blob/main/recsys_two_tower_model.py), accessed through `recommended_feed`.
- Both streams are merged and ranked by the `build_for_you_feed` function before being displayed to the user.

## Frequently Asked Questions

### What is the difference between the Follow-Based Timeline and the Recommendation Engine Feed?

The **Follow-Based Timeline** retrieves posts only from accounts the user explicitly follows, maintaining the social graph relationship. The **Recommendation Engine Feed** uses machine learning models to surface content from accounts the user does not follow, based on inferred interests, content similarity, and collaborative filtering signals.

### How does the X For You feed combine content from both sources?

According to [`phoenix/xrex/configs/data_feeds.py`](https://github.com/xai-org/x-algorithm/blob/main/phoenix/xrex/configs/data_feeds.py), the `build_for_you_feed` function retrieves candidates from both `follow_timeline_feed` and `recommended_feed`, then merges them using an interleaving strategy or a learned ranking model. This process balances organic social content with algorithmic recommendations before returning the final ordered list.

### Where is the recommendation model implemented in the X algorithm codebase?

The core recommendation model is implemented in [`phoenix/xrex/models/recsys_two_tower_model.py`](https://github.com/xai-org/x-algorithm/blob/main/phoenix/xrex/models/recsys_two_tower_model.py). This file contains the two-tower architecture that generates the candidate embeddings used by the recommended feed. The serving layer in [`phoenix/xrex/inference/gen_recs_services.py`](https://github.com/xai-org/x-algorithm/blob/main/phoenix/xrex/inference/gen_recs_services.py) then exposes these candidates to the feed construction pipeline.

### Can the ratio of follow-based versus recommended content be adjusted?

Yes. While the example code in `build_for_you_feed` shows a simple interleaving approach, the configuration in [`data_feeds.py`](https://github.com/xai-org/x-algorithm/blob/main/data_feeds.py) supports parameterized merging strategies. The `max_items` parameter and internal ranking logic can be tuned to weight the Follow-Based Timeline more heavily for users who prefer chronological content, or favor the Recommendation Engine Feed for discovery-focused experiences.