Skip to main content

Overview

The Candidate Pipeline is a flexible, extensible framework for building multi-stage recommendation systems. It provides a clean abstraction for composing complex pipelines from reusable components. The framework powers Home Mixer and can be used to build any candidate retrieval and ranking system.
Design Philosophy: Separate pipeline execution and monitoring from business logic, enabling engineers to focus on building individual components rather than orchestration.

Core Concepts

A CandidatePipeline orchestrates the flow of candidates through multiple stages:

Pipeline Stages

The framework defines traits for each pipeline stage:

QueryHydrator

Enriches the query with additional context before retrieving candidates.
candidate-pipeline/query_hydrator.rs
Example: Fetch user’s engagement history before candidate retrieval

Source

Retrieves candidate items from a data source.
candidate-pipeline/source.rs
Example: Retrieve posts from Thunder

Hydrator

Enriches candidates with additional features.
candidate-pipeline/hydrator.rs
Example: Fetch author information

Filter

Removes candidates that shouldn’t be shown to the user.
candidate-pipeline/filter.rs
Example: Remove user’s own posts

Scorer

Computes scores for ranking candidates.
candidate-pipeline/scorer.rs
Example: Phoenix ML scorer

Selector

Sorts and selects top candidates.
candidate-pipeline/selector.rs
Example: Select top K by score

SideEffect

Runs asynchronous actions that don’t affect the pipeline result.
candidate-pipeline/side_effect.rs
Example: Cache request info

Pipeline Execution

The CandidatePipeline trait orchestrates all stages:
candidate-pipeline/candidate_pipeline.rs

Parallel vs Sequential Execution

Query Hydrators, Sources, and Hydrators run in parallel:
This maximizes throughput for independent operations.

Error Handling

The framework provides graceful error handling:
  • Component failures are logged but don’t crash the pipeline
  • Sources: Partial results from successful sources are used
  • Hydrators: Failed hydrations skip update, candidates proceed
  • Filters: Failed filters use backup (pre-filter candidates)
  • Scorers: Failed scorers skip update, candidates use existing scores

Building a Pipeline

Example: Building the Phoenix Candidate Pipeline for Home Mixer

Monitoring and Logging

The framework automatically logs each stage:
Stage timings and component success rates are tracked via metrics.

Benefits

Composability

Build complex pipelines from simple, reusable components

Testability

Each component can be tested independently

Observability

Built-in logging and metrics for every stage

Flexibility

Components can be enabled/disabled per request

Home Mixer

Production implementation using Candidate Pipeline

Phoenix

ML components integrated as Sources and Scorers