Skip to main content
The Phoenix ranking model is a transformer-based neural network that scores candidates retrieved by the retrieval stage. It predicts multiple engagement actions (likes, reposts, replies, etc.) for each candidate while ensuring that scores are independent of other items in the batch.

Model Architecture

Key Design: Candidate Isolation

Critical Design Requirement: The score for a candidate must not depend on which other candidates are in the batch. This ensures consistent scoring regardless of batch composition.
Candidate isolation is achieved through custom attention masking that prevents candidates from attending to each other while still allowing them to attend to user and history context.

Why Candidate Isolation Matters

Without isolation, the model could:
  • Score candidates differently based on which other items are in the batch
  • Create inconsistent rankings across different batch compositions
  • Make A/B testing and experimentation unreliable
  • Cause unexpected behavior when batch sizes or sampling strategies change
With isolation, each candidate receives a deterministic score based solely on user context.

Forward Pass Implementation

Here’s how the ranking model processes inputs:
Source: recsys_model.py:439-474

Input Embedding Construction

The model combines multiple feature types into input embeddings:

1. User Embedding

Source: recsys_model.py:79-119

2. History Embeddings

History embeddings combine:
  • Post hashes (multiple per position)
  • Author hashes (multiple per position)
  • Action embeddings (multi-hot vector of engagement types)
  • Product surface (e.g., Home, Search, Profile)
Source: recsys_model.py:122-182

3. Candidate Embeddings

Similar to history, but without action embeddings (since we’re predicting actions):
Source: recsys_model.py:185-242

Multi-Action Prediction

The model predicts multiple engagement types simultaneously:
Each action dimension corresponds to a different engagement type:
  • Like probability
  • Repost probability
  • Reply probability
  • Click probability
  • Negative feedback probability
  • etc.
The final ranking score is typically a weighted combination of these action logits, where weights reflect business objectives (e.g., replies might be weighted higher than likes).

Hash-Based Feature Encoding

Phoenix uses multiple hash functions for embedding lookup:
Multiple hash functions reduce hash collisions and provide richer representations:
  • Each feature (user, post, author) is hashed multiple times
  • Each hash produces a separate embedding lookup
  • Embeddings are concatenated and projected to the final dimension
This approach works well for sparse, high-cardinality features common in recommendation systems.
Source: recsys_model.py:32-38
Hash value 0 is reserved for padding. The padding mask is computed by checking if the first hash is non-zero:

Model Configuration

Source: recsys_model.py:245-261

Key Differences from Retrieval

Retrieval

  • Two separate towers
  • User tower only
  • Output: normalized embeddings
  • Objective: similarity search

Ranking

  • Single joint model
  • User + history + candidates
  • Output: action logits
  • Objective: engagement prediction

Next Steps

Architecture Details

Deep dive into attention masking implementation

Retrieval Model

Learn about the two-tower retrieval stage