Topic 216 / Specialist
Recommendation system architecture
Chapter 13.8 · Recommendation System Architecture
What and why
A recommendation system decides, for a given user and context, which items to show from a catalog too large to rank exhaustively in real time — the problem full-text search (→ 209) solves for explicit queries, recommendation solves with no query at all, inferring intent from behavior instead. Its defining architecture is a funnel: narrow a huge catalog to a manageable candidate set, then rank that set with a more expensive model, because running the expensive model over the entire catalog for every request fits no latency budget. Builds on: → 123 (batch processing and ETL — the pattern behind offline training).
Diagram
Catalog (millions) ─► Candidate generation (thousands) ─► Ranking (hundreds) ─► Re-ranking
(tens shown)
cheap, high recall cheap signals expensive model business rules
How it works
- Candidate generation narrows the full catalog to a few hundred or thousand plausible items quickly and cheaply, using simple signals (co-purchase, same category, popularity) — speed and recall (don't drop a genuinely good item) matter more than precision here.
- Ranking scores each candidate more expensively, using a model trained on richer features (user history, item features, context), affordable only because it scores hundreds of items, not millions.
- Re-ranking applies business rules on top of the model's ranking — diversity (don't show 10 variants of the same item), freshness, inventory availability, deduplication — the model optimizes one objective, re-ranking enforces constraints the model doesn't know about.
- Collaborative filtering recommends from patterns across users ("users who did X also did Y"), needing no understanding of item content but suffering when an item or user is new (step 6).
- Content-based filtering recommends from item attributes and similarity instead of other users' behavior, working for new items with no interaction history but requiring those attributes to exist and be meaningful.
- Cold start: a new user or new item has no behavioral history for collaborative filtering to use — mitigated by content-based signals, popularity defaults, or explicit onboarding until enough behavioral data accumulates.
- Offline training with online serving: the ranking model is trained on batch historical data (→ 123's pattern, applied to training data) on a schedule, then served online — a copy of the trained model, or its scores, sits in a low-latency path, decoupled from the training pipeline's own schedule.
- Feature stores keep the same feature definitions ("purchases in the last 7 days") consistent between what the offline training pipeline computed and what the online serving path looks up at request time — a mismatch here silently degrades recommendation quality with no visible error.
- Feedback loops: what gets recommended influences what gets clicked, which becomes training data for the next model — a system can reinforce its own past decisions rather than genuinely improving, a bias worth watching for explicitly.
Practical example
(illustrative). A catalog of 2,000,000 items: candidate generation using category and co-purchase signals narrows this to 500 candidates in a few milliseconds; a ranking model scores those 500 using richer per-user features — a computation infeasible against all 2,000,000 items in the same latency budget; re-ranking then removes 3 near-duplicate items and ensures at least 2 categories are represented before showing the final 20.
When to use it
- Use when: the catalog is large enough that exhaustive ranking is infeasible and enough behavioral or content signal exists to personalize.
- Avoid when: the catalog is small enough to rank exhaustively, or a much simpler heuristic (most popular, most recent, same category) performs adequately — the funnel above isn't justified until that simpler baseline is measured and found wanting.
- Failure scenarios: cold start producing poor recommendations for new users or items with no fallback; training-serving skew from a feature-store inconsistency silently degrading quality; a feedback loop amplifying existing popularity instead of genuine relevance.
- Simpler alternative: a popularity-ranked or manually curated list, or content-based similarity alone, until personalization is proven to matter for the product.
Practice
(Decision kind — judge scenarios and defend the choice; 20–30 min, no lab services). Given 4 scenarios — a brand-new user, a brand-new item, a catalog of 50 items, a catalog of 5 million items — decide for each whether the full candidate-generation-then- ranking funnel is justified or a simpler heuristic suffices, and name the cold-start mitigation if any. Done when you can defend each choice against "why not just always run the full funnel."
Key takeaway
Recommendation architecture is a funnel — cheap, high-recall candidate generation feeding an expensive ranking model, corrected by business-rule re-ranking — plus the offline/online split that lets training stay batch while serving stays fast. Done when you can: pick a funnel stage to simplify for a given catalog size and justify it. Used next in → 219 (the offline-training/online-serving split generalizes to the full ML system lifecycle).
References
None — this topic makes no external claims.
Source directory