[FEATURE] Two-Stage Recommendation Pipeline: Candidate Generation + LightGBM Ranker
Description
Motivation
Two-stage recommendation systems are widely adopted in industry (YouTube, Pinterest, Alibaba, etc.), yet there is no end-to-end, well-structured reference implementation in this repository that clearly demonstrates how to properly connect the candidate generation stage to the ranking stage.
Most existing examples either:
- Focus on a single model in isolation, or
- Skip over the practical details of how to wire the two stages together correctly (feature leakage, negative sampling strategy, group construction for LTR, etc.)
This makes it difficult for practitioners to apply two-stage modeling correctly in real-world pipelines. The goal of this contribution is to provide a clean, reusable reference that fills that gap.
Proposed Design
Stage 1 — Candidate Generation
Retrieve a small set of candidate items (e.g. top-K) from the full item catalog for each user.
Status: open to suggestions. I am still evaluating which model to use for this stage. Possible directions include:
- Matrix Factorization (ALS, SVD) — fast, well-understood baseline
- Neural Collaborative Filtering (NCF) — already in the repo, easy to integrate
- Two-Tower / DSSM — more scalable for large catalogs
- SAR — lightweight, already supported
If you have a recommendation or strong opinion on which candidate model fits best here, please leave a comment.
Stage 2 — Ranking
Re-rank the retrieved candidates using LightGBM with the lambdarank objective (lgb.LGBMRanker), which was recently merged into staging via #2288.
Why This Matters
Two-stage ranking is the dominant paradigm in production recommendation systems, but getting the details right is non-trivial:
- Candidate recall must be high enough that the ranker has good items to work with
- Negative sampling must be done carefully to avoid inflated metrics
- Feature computation must respect train/test boundaries to prevent leakage
Related
- #2288 — LightGBM LambdaRank notebook (staging, merged)
- #2205 — Embedding ranker in PyTorch
Expected behavior with the suggested feature
- Select and implement candidate generation model (Stage 1)
- Build a connector that converts Stage 1 output into a ranked candidate pool for Stage 2
- Apply proper negative sampling for the ranking stage
- Evaluate end-to-end with standard metrics:
NDCG@K,Precision@K,Recall@K - Provide a clean notebook (
lightgbm_two_stage_movielens.ipynb) on MovieLens 1M
Willingness to contribute
- Yes, I can contribute for this issue independently.
- Yes, I can contribute for this issue with guidance from Recommenders community.
- No, I cannot contribute at this time.
Other Comments
Source: recommenders-team/recommenders