A four-stage recommender system progressively turns a large item pool into a small, usable recommendation list. Retrieval generates many candidates quickly; filtering removes ineligible items; scoring estimates detailed affinity; ordering produces the final presentation. Separating these jobs keeps speed, business rules, model quality, and ranking logic independently tunable. section 1.4.1 section 2.6
A practical pipeline assigns one primary responsibility to each stage:
- Retrieval finds hundreds or thousands of candidates with fast database queries or approximate nearest-neighbor search. section 1.4.1
- Filtering applies eligibility rules, such as excluding consumed, unavailable, or inappropriate items. section 1.4.1
- Scoring adds detailed relevance or affinity estimates to the remaining candidates. section 1.4.1
- Ordering combines scores and business objectives such as diversity, fairness, freshness, or popularity before selecting the final results. section 1.4.1
Personalized popular-content carousel
A streaming service can retrieve titles with high recent view counts, filter out watched or otherwise ineligible content, score the survivors against a user's taste, and order them into a personalized carousel. Users therefore receive different results from the same popular-content surface. section 1.4.1
Listing 2.14 Four-stage recommender
def recommend_for_user(user_id, k=10): candidates = retrieve_candidates_for_user(user_id) #A candidates = apply_filters(candidates, user_id) #B candidates = add_additional_scores(candidates) #C recommendations = rank_and_select_top_k(candidates, k) #D return recommendations
Use the compact implementation to trace how candidates flow through retrieval, filtering, scoring, and final selection. section 2.2.8
The pattern supports interchangeable implementations: teams can replace retrieval without rewriting scoring or filtering, test stages independently, cache retrieval, batch scoring, parallelize ranking, and centralize logging, monitoring, error handling, fallbacks, and experiments in a reusable framework. section 2.2.8
