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
ACandidatePipeline 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
Source
Retrieves candidate items from a data source.candidate-pipeline/source.rs
Hydrator
Enriches candidates with additional features.candidate-pipeline/hydrator.rs
Filter
Removes candidates that shouldn’t be shown to the user.candidate-pipeline/filter.rs
Scorer
Computes scores for ranking candidates.candidate-pipeline/scorer.rs
Selector
Sorts and selects top candidates.candidate-pipeline/selector.rs
SideEffect
Runs asynchronous actions that don’t affect the pipeline result.candidate-pipeline/side_effect.rs
Pipeline Execution
TheCandidatePipeline trait orchestrates all stages:
candidate-pipeline/candidate_pipeline.rs
Parallel vs Sequential Execution
- Parallel Stages
- Sequential Stages
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 MixerMonitoring and Logging
The framework automatically logs each stage: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
Related Components
Home Mixer
Production implementation using Candidate Pipeline
Phoenix
ML components integrated as Sources and Scorers