Recommender Systems: High-Level Guide
This document is an extensive technical guide to modern recommendation systems. It synthesizes the supplied materials on recommendation-system foundations, candidate generation, collaborative filtering, ranking, re-ranking, calibration, search, evaluation, moderation, graph neural networks, Transformers, cold start, bias, multi-armed bandits, multi-objective optimization, generative recommendation, and representative research papers.
The central engineering problem is to select and order a small set of useful items from a very large catalog for a particular user, context, or query, while satisfying latency, quality, safety, diversity, business, and fairness constraints.
Contents
- Recommendation-system foundations
- Production funnel architecture
- Data and feature representations
- Candidate generation
- Collaborative filtering and matrix factorization
- Two-tower retrieval and approximate nearest neighbors
- Ranking and learning to rank
- Re-ranking and slate optimization
- Calibration
- Search and hybrid retrieval
- Evaluation and loss functions
- Bias, feedback loops, and fairness
- Content moderation and integrity
- Cold-start strategies
- Popular neural architectures
- Graph neural networks
- Transformers and sequential recommendation
- Multi-armed and contextual bandits
- Multi-objective optimization
- Generative recommendation and LLMs
- Production challenges
- Research-paper map
- End-to-end reference architecture
- Implementation blueprint
- Final technical takeaways
Recommendation-system foundations
What is a recommendation system?
A recommendation system is a machine-learning system that estimates which items a user is likely to find useful, relevant, enjoyable, or valuable, and then presents a selected set of those items.
An item may be:
- A movie, song, video, article, product, restaurant, job, advertisement, or social connection.
- A search result or document.
- A notification, explanation, image, or content collection.
- A generated response or conversational suggestion.
A recommendation request usually contains three conceptual components:
| Component | Meaning | Examples |
|---|---|---|
| User or query | The entity for which recommendations are generated | User ID, search query, device, location |
| Item or document | A candidate that may be recommended | Movie, product, video, restaurant |
| Representation | A numerical description used by models | Features, embeddings, graph vectors |
A system attempts to estimate a relevance or utility function:
\[\hat{r}(u, i, c) = f_\theta(u, i, c)\]where:
- $u$ is the user or user representation.
- $i$ is the item.
- $c$ is contextual information.
- $f_\theta$ is a learned model.
- $\hat{r}$ is a predicted relevance, engagement probability, utility, or score.
Why recommendation systems are difficult
A production recommender must solve several problems simultaneously:
- The catalog may contain millions or billions of items.
- Most user-item interactions are unobserved.
- Feedback is often implicit rather than explicit.
- Exposure is not random; users interact with what the system shows them.
- Popular items receive more exposure and therefore more feedback.
- New users and items have little or no history.
- User preferences change over time.
- Different objectives can conflict.
- The system must often respond within a strict latency budget.
- A recommendation can affect user behavior, creating feedback loops.
- Safety, policy, legal, and fairness requirements may override engagement.
Discovery, search, and recommendation
Search and recommendation are closely related but have different starting conditions.
| Property | Search | Recommendation |
|---|---|---|
| Explicit intent | Usually provided by a query | Often inferred from behavior or context |
| User state | Query-centric | User-history and context-centric |
| Candidate set | Query-matching documents | Personalized catalog items |
| Main challenge | Interpret the query and retrieve relevant results | Infer preferences and balance relevance with discovery |
| Typical signals | Terms, semantic similarity, filters | History, embeddings, context, social graph, popularity |
Modern systems often combine both. Search activity can enrich a recommender, while recommendation models can personalize search results.
Production funnel architecture
The two-stage funnel
A common production architecture separates fast retrieval from expensive ranking:
OFFLINE SYSTEMS
+-------------------+-------------------+-------------------+
| Events and Data | Feature Pipelines | Model Training |
+-------------------+-------------------+-------------------+
| | |
v v v
+-------------------+-------------------+-------------------+
| Item Embeddings | User Features | Models and |
| ANN Indices | Feature Store | Checkpoints |
+-------------------+-------------------+-------------------+
|
v
ONLINE REQUEST PATH
+-------------------+
| User / Query |
+-------------------+
|
v
+-------------------+
| Candidate |
| Generation |
+-------------------+
|
v
+-------------------+
| Ranking / Scoring |
+-------------------+
|
v
+-------------------+
| Final List |
+-------------------+
The two stages have different optimization goals:
| Stage | Main goal | Typical model or method |
|---|---|---|
| Candidate generation | High recall at low latency | Matrix factorization, two-tower model, ANN, popularity retrieval |
| Ranking | High precision and utility | Logistic regression, GBDT, deep ranker, Transformer |
Candidate generation operates over a large catalog and must be efficient. Ranking receives a much smaller candidate set and can use richer features and more computationally expensive models.
The four-stage funnel
Some production systems separate ranking into retrieval, filtering, scoring, and ordering:
+-------------------+
| Entire Catalog |
+-------------------+
|
v
+-------------------+
| Retrieval |
| High Recall |
+-------------------+
|
v
+-------------------+
| Filtering |
| Eligibility Rules |
+-------------------+
|
v
+-------------------+
| Scoring |
| Personalized |
+-------------------+
|
v
+-------------------+
| Ordering |
| Diversity, Policy |
+-------------------+
|
v
+-------------------+
| User-Facing Slate |
+-------------------+
The four stages separate concerns:
- Retrieval finds a broad set of potentially relevant items.
- Filtering removes items that cannot or should not be shown.
- Scoring estimates relevance or expected utility.
- Ordering constructs the final slate while considering diversity, novelty, freshness, policy, and business constraints.
Multiple candidate generators
A production system often combines several candidate sources:
- Collaborative-filtering candidates.
- Content-similarity candidates.
- Trending and popular candidates.
- Geographical candidates.
- Social-graph candidates.
- Search-derived candidates.
- Recently viewed or continued items.
- New-item exploration candidates.
- Sponsored or business-priority candidates.
These sources are merged into a common candidate pool. Their individual scores are not necessarily comparable, which is one reason a separate ranking model is used.
Offline and online environments
The offline environment creates artifacts needed by online serving:
- Item and user embeddings.
- ANN indices.
- Feature-store values.
- Trained model checkpoints.
- Popularity statistics.
- Calibration maps.
- Policy and moderation classifiers.
- Candidate-generator configurations.
The online environment performs request-specific work:
- Resolve user and context.
- Retrieve candidates.
- Apply eligibility filters.
- Fetch online features.
- Score candidates.
- Re-rank the slate.
- Log exposure and outcomes.
Data and feature representations
Explicit and implicit feedback
Feedback can be explicit or implicit.
| Feedback type | Examples | Strengths | Limitations |
|---|---|---|---|
| Explicit | Rating, like, dislike, save | Direct preference signal | Sparse and subject to rating behavior |
| Implicit | Click, view, purchase, dwell time | Abundant and naturally collected | Ambiguous; exposure affects observations |
| Negative feedback | Hide, skip, report, unsubscribe | Useful for filtering and preference modeling | Often sparse and not always comparable across users |
An impression without an interaction is not always a true negative. The user may not have noticed the item, may have lacked time, or may have preferred another visible item.
Dense and sparse features
Dense features are continuous or numerical values:
- Age or normalized price.
- Rating statistics.
- Time since the last interaction.
- Watch duration.
- Device or network measurements.
Sparse features are categorical identifiers or high-cardinality values:
- User ID.
- Item ID.
- Country.
- Language.
- Product category.
- Artist ID.
- Search terms.
Sparse features are commonly mapped to trainable embeddings.
Sparse ID
|
v
Embedding Lookup Table
|
v
Dense Vector
|
+--> Concatenate with numerical features
|
v
Neural or ranking model
Univalent and multivalent features
A univalent feature has one value for an entity, such as a user’s primary language. A multivalent feature contains a set or sequence, such as genres associated with a movie or a user’s viewing history.
A variable-length collection can be transformed into a fixed-width vector using pooling:
\[\mathbf{h}_{\text{pool}} = \frac{1}{n}\sum_{j=1}^{n}\mathbf{e}_j\]where $\mathbf{e}_j$ is the embedding of the $j$-th element.
Mean pooling is simple and scalable, but it discards order and may treat all events equally. More advanced systems use recency weighting, attention, RNNs, Transformers, or graph aggregation.
Embeddings
An embedding is a learned numerical vector representing an entity or event.
Embedding spaces can encode:
- Similarity between items.
- Similarity between users.
- User-item compatibility.
- Semantic content.
- Behavioral patterns.
- Graph neighborhoods.
Similarity may be measured using a dot product:
\[s(u, i) = \mathbf{u}^{\top}\mathbf{i}\]or cosine similarity:
\[\text{cos}(\mathbf{u}, \mathbf{i}) = \frac{\mathbf{u}^{\top}\mathbf{i}} {\lVert\mathbf{u}\rVert_2\lVert\mathbf{i}\rVert_2}\]Embedding quality depends on the training objective, negative-sampling strategy, data coverage, and serving-time consistency.
Feature stores and training-serving consistency
A feature store can provide a common definition of features for both training and serving. This reduces training-serving skew, where the model sees one representation during training and another during production inference.
Important consistency requirements include:
- Identical transformations.
- Identical normalization parameters.
- Correct event-time semantics.
- No future information leaking into historical examples.
- Consistent missing-value handling.
- Versioned feature definitions.
Candidate generation
Candidate generation reduces a large catalog to a manageable set of items that can be scored in later stages.
Content-based filtering
Content-based filtering recommends items based on item characteristics and the user’s inferred profile.
Examples of item features include:
- Text descriptions.
- Genres.
- Tags.
- Images.
- Audio features.
- Actors, artists, or creators.
- Product attributes.
A content-based system can construct a user profile by aggregating features from items the user interacted with:
\[\mathbf{u} = \text{aggregate}(\{\mathbf{i}_j : j \in H_u\})\]where $H_u$ is the user’s interaction history.
Advantages
- Can recommend new items when content features are available.
- Does not require other users’ interactions.
- Can personalize niche interests.
- Is relatively easy to explain through item attributes.
Limitations
- It may over-specialize in existing interests.
- It requires useful item metadata.
- It may lack serendipity.
- It often requires domain-specific feature engineering.
Collaborative filtering
Collaborative filtering uses interactions among users and items rather than item content alone.
The central assumption is that users with similar behavior may prefer similar items, and items consumed by similar users may be related.
User-item interactions
|
v
+------------------------+
| Discover user patterns |
| and item patterns |
+------------------------+
|
v
+------------------------+
| Learn latent vectors |
+------------------------+
|
v
+------------------------+
| Retrieve or score |
| unseen items |
+------------------------+
Collaborative filtering can discover relationships that are not obvious from item metadata, but it is vulnerable to sparse data and cold start.
Matrix factorization
A user-item interaction matrix can be approximated using latent user and item factors:
\[R \approx U V^{\top}\]The predicted interaction can be written as:
\[\hat{r}_{ui} = \mu + b_u + b_i + \mathbf{p}_u^{\top}\mathbf{q}_i\]where:
- $\mu$ is the global bias.
- $b_u$ and $b_i$ are user and item biases.
- $\mathbf{p}_u$ is the user latent vector.
- $\mathbf{q}_i$ is the item latent vector.
The model may minimize squared error for explicit ratings or use a ranking loss for implicit feedback.
Weighted alternating least squares
Weighted alternating least squares (WALS) is useful for large sparse interaction matrices. It alternates between solving for user factors while holding item factors fixed and solving for item factors while holding user factors fixed.
A generic objective is:
\[\min_{U,V} \sum_{u,i} c_{ui}(p_{ui} - \mathbf{u}_u^{\top}\mathbf{v}_i)^2 + \lambda(\lVert U\rVert_F^2 + \lVert V\rVert_F^2)\]where $c_{ui}$ weights confidence in an observed or unobserved interaction.
Negative sampling
Many recommender tasks have far more unobserved pairs than observed positive pairs. Negative sampling selects a manageable set of presumed negative examples.
Common strategies include:
- Uniform random negatives.
- Popularity-weighted negatives.
- In-batch negatives.
- Hard negatives from a retrieval model.
- Time-aware negatives.
- Exposure-aware negatives.
Negative sampling changes the training distribution. Evaluation and serving should account for that difference.
Two-tower retrieval and approximate nearest neighbors
Two-tower architecture
A two-tower model independently encodes a user or query and an item:
+------------------+ +------------------+
| User features | | Item features |
+------------------+ +------------------+
| |
v v
+------------------+ +------------------+
| User tower | | Item tower |
| Neural encoder | | Neural encoder |
+------------------+ +------------------+
| |
v v
+------------------+ +------------------+
| User embedding | | Item embedding |
+------------------+ +------------------+
\ /
\ /
v v
Similarity function
|
v
Retrieval score
The item tower can be run offline for the entire catalog. At request time, only the user tower and ANN lookup need to run.
A typical loss encourages positive pairs to have high similarity and negatives to have lower similarity:
\[\mathcal{L}_{\text{InfoNCE}} = -\log \frac{\exp(s(u, i^+)/\tau)} {\exp(s(u, i^+)/\tau) + \sum_{j \in N}\exp(s(u, i_j^-)/\tau)}\]where $\tau$ is a temperature parameter.
Approximate nearest-neighbor retrieval
Exact comparison of a query vector with every catalog vector is expensive. Approximate nearest-neighbor methods trade a small amount of recall for much lower latency.
Common index families include:
- HNSW graphs.
- Inverted-file indices.
- Product quantization.
- Tree-based indices.
- Hybrid graph and quantization systems.
Important ANN trade-offs include:
- Recall versus latency.
- Memory versus compression.
- Update speed versus query speed.
- Index freshness versus rebuild cost.
Candidate-generator evaluation
Candidate generation is usually evaluated using recall at a candidate-set size:
\[\text{Recall@K} = \frac{|\text{relevant items in top-}K|} {|\text{relevant items}|}\]High retrieval recall is necessary but not sufficient. A generator may retrieve relevant items but create a candidate set that is redundant, unsafe, stale, or difficult for later ranking to process.
Ranking and learning to rank
Scoring versus ranking
Scoring assigns an independent value to each candidate. Ranking orders candidates according to those scores or according to a list-level objective.
A scoring model may estimate:
- Click probability.
- Purchase probability.
- Watch probability.
- Expected watch time.
- Conversion value.
- Long-term satisfaction.
A ranking model may then sort candidates, subject to additional constraints.
Point-wise learning to rank
Point-wise methods treat each item independently as a regression or classification example.
Examples include:
- Logistic regression.
- Linear regression.
- Gradient-boosted decision trees.
- Neural networks.
For binary engagement, binary cross-entropy is common:
\[\mathcal{L}_{\text{BCE}} = -\left[y\log\hat{p} + (1-y)\log(1-\hat{p})\right]\]Point-wise approaches are simple and scalable, but they do not directly model competition among items in the same slate.
Pair-wise learning to rank
Pair-wise methods train on item pairs and attempt to place the preferred item above the less-preferred item.
A pairwise logistic loss can be expressed as:
\[\mathcal{L}_{\text{pair}} = -\log \sigma(s(u, i^+) - s(u, i^-))\]Examples include RankNet, RankSVM, LambdaRank, and LambdaMART.
Pair-wise approaches align more closely with ordering but may require many item pairs.
List-wise learning to rank
List-wise methods optimize an entire candidate list or an approximation to a list-ranking metric.
Examples include ListNet, ListMLE, SoftRank, and list-wise Lambda methods.
They can better represent the final ranking objective but usually have higher computational and implementation complexity.
Multi-stage ranking
Large platforms may use multiple ranking passes:
Candidate pool: 500 items
|
v
First pass: lightweight model
|
v
Top 150 items
|
v
Second pass: richer model
|
v
Top 50 items
|
v
Final pass: deep model and constraints
|
v
Top 25 items
The first pass prioritizes speed, while later passes use richer features and more expressive models.
Objective-function design
The ranking objective determines what the system learns to optimize. Optimizing only one metric can create undesirable behavior:
| Objective | Possible failure mode |
|---|---|
| Click-through rate | Clickbait and shallow engagement |
| Watch time | Bias toward long content |
| Purchases | Reduced discovery or over-commercialization |
| Popularity | Feedback loops and reduced long-tail exposure |
| Short-term engagement | Lower long-term satisfaction |
Production rankers often combine several predicted outcomes and apply constraints or re-ranking after model scoring.
Re-ranking and slate optimization
Re-ranking operates after initial scoring and modifies the candidate order or removes candidates to satisfy additional goals.
Common re-ranking objectives
- Diversity.
- Freshness.
- Novelty.
- Serendipity.
- Popularity control.
- Seasonality.
- Fairness.
- Creator or seller coverage.
- Safety and policy compliance.
- Business constraints.
Diversity
If the highest-scoring items are almost identical, the user may receive a repetitive slate. Diversity can be encouraged through:
- Category quotas.
- Similarity penalties.
- Maximum marginal relevance.
- Multiple candidate generators.
- Multiple rankers with different objectives.
- Clustering and coverage constraints.
A simple diversity-aware objective is:
\[\text{Utility}(S) = \sum_{i \in S} \text{relevance}(i) - \lambda \sum_{i,j \in S} \text{similarity}(i,j)\]where $S$ is the selected slate.
Freshness and seasonality
Freshness can be modeled using a time-decay function:
\[w(t) = \exp(-\lambda \Delta t)\]where $\Delta t$ is the age of the item or event.
Seasonality can be represented through:
- Day-of-week features.
- Month or holiday indicators.
- Historical performance during similar periods.
- Time-aware models.
- Event-specific rules.
Popularity control
Popularity is useful for cold-start fallback and broad appeal, but excessive popularity weighting can suppress long-tail content. A re-ranker may normalize or penalize popularity so that relevant niche items receive exposure.
Re-ranking as constrained selection
A practical formulation is:
\[\max_{S \subseteq C} U(S)\]subject to constraints such as:
- Size constraint: $|S| = K$.
- At most $m$ items from one category.
- At least one fresh item.
- No policy-violating item.
- Minimum creator or seller coverage.
Calibration
Calibration measures whether predicted probabilities match observed frequencies.
If a model assigns a click probability of $0.7$ to a group of impressions, approximately 70% of that group should click for the model to be well calibrated.
Calibration matters when probabilities are used for:
- Threshold decisions.
- Risk-sensitive decisions.
- Utility calculations.
- Multi-objective combinations.
- Budget allocation.
- Downstream re-ranking.
Platt scaling
Platt scaling fits a sigmoid mapping from a raw score $s$ to a probability:
\[P(y=1 \mid s) = \frac{1}{1 + \exp(As+B)}\]The parameters $A$ and $B$ are learned on a held-out calibration set.
Isotonic regression
Isotonic regression learns a non-decreasing mapping without assuming a sigmoid shape. It can be more flexible but may overfit when calibration data is limited.
Bayesian calibration
Bayesian binning methods estimate event probabilities within score bins while incorporating uncertainty and priors. They can be useful when data is limited or estimates need uncertainty handling.
Calibration evaluation
Common diagnostics include:
- Reliability diagrams.
- Expected calibration error.
- Maximum calibration error.
- Brier score.
- Log loss.
Calibration should be evaluated by important slices, such as device, geography, language, user activity, item popularity, and traffic source.
Search and hybrid retrieval
Information retrieval
Information retrieval concerns representing, storing, organizing, and accessing information from large collections.
A search system receives a query $q$ and a document collection $D$ and attempts to return a ranked subset of useful documents.
Lexical search
Lexical search relies on term overlap. TF-IDF assigns a weight to a term based on its local frequency and global rarity:
\[\text{tfidf}(t,d) = \text{tf}(t,d) \cdot \log\left(\frac{N}{\text{df}(t)}\right)\]BM25 improves term-based retrieval by incorporating term frequency saturation and document-length normalization.
Strengths
- Fast lookup through inverted indices.
- Strong performance for identifiers and exact terminology.
- Good interpretability.
- Mature ecosystem.
Limitations
- Vocabulary mismatch.
- Weak synonym and paraphrase handling.
- Limited semantic understanding.
- Difficulty with ambiguous intent.
Semantic search
Semantic search encodes queries and documents into dense vectors and retrieves nearby vectors.
It can handle:
- Synonyms.
- Paraphrases.
- Related concepts.
- Cross-language or cross-modal relationships.
Limitations include:
- Higher compute cost.
- Larger storage requirements.
- Harder explanations.
- Potential overgeneralization.
- Need for domain adaptation.
Hybrid search
Hybrid search combines lexical and semantic retrieval:
User Query
|
+------------------+
| |
v v
Lexical Retrieval Dense Retrieval
| |
+--------+---------+
v
Candidate Fusion
|
v
Neural Reranking
|
v
Final Results
Reciprocal Rank Fusion combines rankings without requiring directly comparable scores:
\[\text{RRF}(d) = \sum_{m=1}^{M}\frac{1}{k + r_m(d)}\]where $r_m(d)$ is the rank of document $d$ in system $m$.
Index structures
| Index | Mapping | Main use |
|---|---|---|
| Forward index | Document to terms | Reconstruction, metadata, snippets |
| Inverted index | Term to documents | Lexical retrieval |
| Embedding index | Vector to nearby vectors | Semantic retrieval |
Modern search systems may maintain all three.
Evaluation and loss functions
Offline evaluation
Offline evaluation typically involves:
- Define historical examples.
- Split data by time or user appropriately.
- Train candidate models.
- Evaluate on held-out interactions.
- Compare metrics and slices.
- Check leakage and bias.
- Select candidates for online testing.
Random splitting can produce overly optimistic results when future interactions leak into training or when users appear in both sets in unrealistic ways.
Online evaluation
Online evaluation uses live traffic, typically through:
- A/B tests.
- Interleaving.
- Contextual bandits.
- Holdout groups.
- Gradual rollouts.
Online metrics should include guardrails, not only the primary objective.
Precision and recall
\[\text{Precision} = \frac{TP}{TP+FP}\] \[\text{Recall} = \frac{TP}{TP+FN}\]At a cutoff $K$:
\[\text{Precision@K} = \frac{\text{relevant items in top }K}{K}\] \[\text{Recall@K} = \frac{\text{relevant items in top }K}{\text{total relevant items}}\]Mean reciprocal rank
MRR emphasizes the position of the first relevant item:
\[\text{MRR} = \frac{1}{M}\sum_{j=1}^{M}\frac{1}{\text{rank}_j}\]It ignores later relevant items after the first one.
Average precision and mean average precision
Average precision rewards relevant items appearing early and averages precision at relevant positions. Mean average precision averages AP across queries or users.
NDCG
Discounted cumulative gain discounts lower-ranked items:
\[\text{DCG@K} = \sum_{r=1}^{K}\frac{2^{rel_r}-1}{\log_2(r+1)}\]NDCG normalizes DCG by the ideal DCG:
\[\text{NDCG@K} = \frac{\text{DCG@K}}{\text{IDCG@K}}\]NDCG is useful when relevance is graded and rank position matters.
Business and engagement metrics
Possible metrics include:
- Click-through rate.
- Conversion rate.
- Session length.
- Dwell time.
- Completion rate.
- Repeat visits.
- Retention.
- Revenue or margin.
- Creator coverage.
- Catalog coverage.
- Diversity.
- Complaint or report rate.
- Unsubscribe or disable rate.
No single metric captures recommendation quality. A metric should be selected according to the product objective and evaluated with guardrails.
Common loss functions
| Task | Typical loss |
|---|---|
| Binary engagement | Binary cross-entropy |
| Rating prediction | Mean squared error or mean absolute error |
| Pairwise preference | Pairwise logistic or hinge loss |
| Representation learning | Contrastive or triplet loss |
| List ranking | List-wise ranking loss |
| Diversity | Diversity regularizer or slate objective |
| Fairness | Group or exposure constraint loss |
Bias, feedback loops, and fairness
Position bias
Items shown higher in a list often receive more attention regardless of intrinsic relevance. This creates a confound between position and relevance.
Possible mitigations include:
- Randomized exposure experiments.
- Inverse propensity weighting.
- Position-aware click models.
- Interleaving.
- Position features used carefully during training.
- Counterfactual evaluation.
Inverse propensity weighting uses:
\[w_i = \frac{1}{P(\text{exposure}_i)}\]Care is required because low-propensity examples receive high weights and can increase variance.
Popularity bias
Popularity bias causes popular items to receive more exposure, interactions, and future recommendations. This can suppress niche content and create a self-reinforcing loop.
Possible mitigations include:
- Popularity-aware sampling.
- Logit adjustment.
- Long-tail exploration.
- Exposure constraints.
- Diversity-aware re-ranking.
- Separate evaluation by popularity bucket.
Selection bias
The training data contains interactions only for items that were exposed. Unexposed items provide little or no direct feedback, so the model may mistake lack of interaction for lack of relevance.
Selection bias can be studied through:
- Exposure logs.
- Propensity estimation.
- Randomized traffic.
- IPS or doubly robust estimators.
- Counterfactual evaluation.
Duration bias
If watch time is optimized directly, longer videos may appear better simply because they have more time available to accumulate watch time.
Possible mitigations include:
- Completion rate.
- Relative watch-time quantiles within duration buckets.
- Normalized watch time.
- Multi-objective objectives.
- Separate short-form and long-form modeling.
Clickbait bias
Click optimization can reward sensational content that attracts clicks but produces poor satisfaction. Weighted objectives can incorporate watch quality, completion, reports, or long-term engagement.
Single-interest bias
A system may overrepresent a user’s most frequent interest and neglect other interests. Mitigations include:
- Interest-aware user representations.
- Diversity constraints.
- Multiple interest vectors.
- Calibrated probability distributions.
- Exploration policies.
- Topic or category coverage metrics.
Fairness
Fairness can concern:
- Equal opportunity for creators or sellers.
- Exposure across item groups.
- User-group performance parity.
- Content safety and accessibility.
- Geographic or language coverage.
Fairness should be evaluated alongside utility, because improving one dimension can affect another.
Content moderation and integrity
Engagement alone is not an acceptable recommendation objective when content can cause harm.
A moderation-aware funnel can be structured as follows:
+-------------------+
| Content Ingestion |
+-------------------+
|
v
+-------------------+
| Input Moderation |
| Classifiers |
+-------------------+
|
v
+-------------------+
| Eligible Catalog |
+-------------------+
|
v
+-------------------+
| Retrieval |
+-------------------+
|
v
+-------------------+
| Ranking |
+-------------------+
|
v
+-------------------+
| Final Safety |
| and Policy Checks |
+-------------------+
|
v
+-------------------+
| User Presentation |
+-------------------+
Moderation may include:
- Automated classifiers.
- Human review.
- User reporting.
- Appeals.
- Age and region policies.
- Copyright enforcement.
- Hate-speech detection.
- Child-safety protections.
- Misinformation policies.
- Spam and coordinated inauthentic behavior detection.
Moderation can occur at multiple points:
- At content ingestion.
- Before candidate retrieval.
- After retrieval.
- During ranking or re-ranking.
- Immediately before presentation.
- After user reports or post-publication review.
A content item can be removed, down-ranked, age-gated, region-restricted, or routed for human review depending on policy.
Cold-start strategies
Cold start occurs when the system lacks enough interaction data to personalize effectively.
Item cold start
New items can be represented using content features:
- Text embeddings.
- Image or audio embeddings.
- Metadata.
- Category information.
- Creator or seller attributes.
- Knowledge-based rules.
This makes content-based and hybrid systems useful for newly added items.
User cold start
New users can be handled using:
- Popular items.
- Geography or language-specific popularity.
- Demographic or contextual priors.
- Onboarding surveys.
- Preference elicitation.
- Active learning.
- Session-level behavior.
- Search queries.
A practical transition is:
New User
|
v
Popular and Contextual Candidates
|
v
Onboarding or Early Interactions
|
v
Session Representation
|
v
Personalized Retrieval and Ranking
Community or marketplace cold start
A new marketplace has both new users and new items. Possible strategies include:
- Early-adopter programs.
- Internal testing.
- Employee dogfooding.
- Beta releases.
- Transfer from similar markets.
- Rules and domain knowledge.
- Targeted exploration.
Feature hashing
Feature hashing maps high-cardinality identifiers into a fixed number of buckets. It reduces memory but introduces possible collisions.
A signed hashing scheme or multiple hash functions can reduce systematic collision effects. Hashing is useful for managing dynamic categories, but collision analysis and monitoring are important.
Popular neural architectures
Wide and Deep
Wide and Deep combines:
- A wide component for memorization of explicit feature crosses.
- A deep component for generalization through embeddings and nonlinear layers.
Sparse Features
|
+----------------------+
| |
v v
+--------------+ +--------------+
| Wide Model | | Deep Model |
| Crosses | | Embeddings |
+--------------+ +--------------+
| |
+----------+-----------+
v
Combined Prediction
The wide side can memorize specific interactions such as user-category combinations. The deep side can generalize to related but unseen combinations.
Factorization machines
Factorization Machines model pairwise feature interactions using latent vectors:
\[\hat{y} = w_0 + \sum_i w_i x_i + \sum_{i=1}^{n}\sum_{j=i+1}^{n}\langle \mathbf{v}_i, \mathbf{v}_j\rangle x_i x_j\]They are effective for sparse, high-dimensional features and can incorporate user, item, and context variables.
DeepFM
DeepFM combines a factorization-machine component with a deep neural network. The FM part captures pairwise interactions, while the deep part models higher-order nonlinear relationships.
Neural Collaborative Filtering
NCF replaces the simple matrix-factorization inner product with a neural interaction function. User and item embeddings are combined and passed through an MLP.
Deep and Cross Networks
DCN learns explicit feature crosses through a cross network rather than requiring manual cross-feature engineering. The deep component provides generalization.
DLRM
Deep Learning Recommendation Models typically use embedding tables for sparse features, dense feature processing, feature interaction, and an MLP prediction tower. They are common in large-scale click and conversion prediction.
When deep learning may not help
Deep models are not always better. Simpler models may win when:
- Data is sparse.
- The dataset is small.
- Features are homogeneous.
- Latency constraints are strict.
- Interpretability is essential.
- A well-tuned linear or tree model already captures the available signal.
Graph neural networks
Graph representation
A recommendation graph may contain:
- User nodes.
- Item nodes.
- Creator or seller nodes.
- Category nodes.
- Query nodes.
- Interaction edges.
- Purchase, click, follow, or friendship edges.
A user-item system is often represented as a bipartite graph.
User A -------- Item 1
| |
| |
+---------- Item 2
User B -------- Item 2
|
+---------- Item 3
Message passing
A generic graph-convolution layer aggregates neighbor information:
\[\mathbf{h}_v^{(l+1)} = \phi\left( W_0^{(l)}\mathbf{h}_v^{(l)} + \text{AGG}_{u\in\mathcal{N}(v)} W_1^{(l)}\mathbf{h}_u^{(l)} \right)\]where $\mathcal{N}(v)$ is the neighborhood of node $v$.
The process consists of:
- Compute messages.
- Aggregate messages.
- Transform the aggregate.
- Update the node representation.
- Repeat across layers.
GCNs, GATs, and GraphSAGE
| Architecture | Main idea | RecSys value |
|---|---|---|
| GCN | Aggregate neighborhood features | Captures relational structure |
| GAT | Learn attention weights over neighbors | Focuses on important relationships |
| GraphSAGE | Sample and aggregate neighbors | Supports scalable and inductive learning |
| Edge-aware GNN | Uses edge attributes in message passing | Models interaction type and strength |
GraphSAGE is particularly useful for new nodes because it can generate representations from features and sampled neighborhoods rather than requiring a learned vector for every node.
Graph losses
Possible objectives include:
- Node classification loss.
- Link-prediction binary cross-entropy.
- Pairwise ranking loss.
- Triplet loss.
- Graph reconstruction loss.
- Regularization losses.
For a positive user-item edge and a negative sampled edge:
\[\mathcal{L}_{\text{margin}} = \max\left(0, m - s(u,i^+) + s(u,i^-) \right)\]where $m$ is a margin.
Graph recommender workflow
User-item events
|
v
Construct graph
|
v
Sample neighborhoods
|
v
Run message passing
|
v
Generate user/item embeddings
|
v
Score unseen edges
|
v
Retrieve and rank items
Industry patterns
Graph-based recommendation is useful for:
- Social friend and story ranking.
- Item discovery.
- Food and restaurant recommendations.
- Related content.
- Pinterest-style visual discovery.
- Search and entity relationships.
Graph models can improve relational understanding, but they also introduce costs related to graph storage, neighborhood sampling, freshness, and distributed training.
Transformers and sequential recommendation
Why sequences matter
A user’s recent actions may reveal short-term intent that differs from long-term preferences. Order, timing, and the relationship between events can therefore matter.
Pooling treats events as an unordered collection. Sequential models can represent:
- Recency.
- Repeated patterns.
- Session intent.
- Transition probabilities.
- Long-range dependencies.
Transformer self-attention
For queries $Q$, keys $K$, and values $V$, scaled dot-product attention is:
\[\text{Attention}(Q,K,V) = \text{softmax}\left(\frac{QK^{\top}}{\sqrt{d_k}}\right)V\]Self-attention allows an event to use information from other events in the sequence.
Sequential recommendation pipeline
Ordered interaction history
|
v
+--------------------------+
| Item and event embeddings|
+--------------------------+
|
v
+--------------------------+
| Positional or temporal |
| information |
+--------------------------+
|
v
+--------------------------+
| Transformer encoder |
+--------------------------+
|
v
+--------------------------+
| User or session vector |
+--------------------------+
|
v
+--------------------------+
| Candidate scoring |
+--------------------------+
RNNs and GRUs
RNNs and GRUs process event sequences recurrently. They can be effective for short sessions but have sequential computation and may struggle with long histories.
Behavioral Sequence Transformer
A ranking model can condition on a user’s behavior sequence and a target item, predicting the probability of engagement. The target item can be marked or included alongside the historical sequence.
Multimodal and multitask Transformers
Modern systems may combine:
- Text embeddings.
- Image embeddings.
- Audio embeddings.
- Product or item metadata.
- User history.
- Search queries.
- Multiple engagement labels.
Multitask training can improve sparse objectives by sharing representations across clicks, saves, purchases, and other events.
Multi-armed and contextual bandits
Multi-armed bandit problem
A bandit chooses an action from a set of arms and observes a reward. The objective is to maximize cumulative reward while balancing exploration and exploitation.
\[\max \mathbb{E}\left[\sum_{t=1}^{T} r_t\right]\]Regret compares the reward obtained with the reward that would have been obtained by always choosing the best action.
Epsilon-greedy
With probability $\epsilon$, choose an exploratory action. With probability $1-\epsilon$, choose the action with the highest estimated reward.
Upper confidence bound
UCB selects an action using both estimated reward and uncertainty:
\[\text{UCB}_i(t) = \hat{\mu}_i(t) + c\sqrt{\frac{\ln t}{n_i(t)} }\]where $n_i(t)$ is the number of times arm $i$ has been selected.
Thompson sampling
Thompson sampling maintains a posterior distribution over each arm’s reward and samples from those posteriors to select actions.
Contextual bandits
Contextual bandits condition the action choice on user and environment context:
\[a_t = \pi(x_t)\]where $x_t$ may include:
- User attributes.
- Device.
- Time.
- Location.
- Recent history.
- Item context.
Contextual bandits are useful when different users respond differently to the same candidate.
Bandits in recommendation systems
Bandits can be used for:
- Exploration of long-tail items.
- Personalization.
- Testing variants.
- Recommendation explanations.
- Artwork selection.
- Cuisine discovery.
- Dynamic content selection.
- Cold-start items.
Off-policy evaluation
Historical logs are generated by an old policy, but the goal is to estimate a new policy. Inverse propensity scoring can estimate counterfactual reward when exposure probabilities are known or estimated:
\[\hat{V}_{\text{IPS}}(\pi) = \frac{1}{N}\sum_{t=1}^{N} \frac{\mathbb{1}[a_t = \pi(x_t)]r_t} {p(a_t\mid x_t)}\]High variance is a major challenge. Self-normalized and doubly robust estimators can reduce some problems.
Bandits versus A/B testing
| Property | A/B testing | Bandit testing |
|---|---|---|
| Allocation | Usually fixed | Adapts over time |
| Interpretation | Straightforward | More complex |
| Exploration | Controlled by experiment design | Built into policy |
| Underperforming variants | Continue receiving assigned traffic | Can receive less traffic |
| Best use | Clear statistical comparison | Continuous adaptation and personalization |
Multi-objective optimization
A recommender may need to optimize several objectives:
- Relevance.
- Engagement.
- Diversity.
- Freshness.
- Creator coverage.
- Revenue.
- Long-term retention.
- Safety.
- Fairness.
These objectives can conflict. Multi-objective optimization seeks Pareto-optimal trade-offs: improving one objective further would worsen at least one other objective.
A weighted model may be written as:
\[S(i) = \sum_{j=1}^{m} w_j s_j(i)\]where $s_j$ are objective-specific scores and $w_j$ are tunable weights.
Constrained optimization
A primary metric can be optimized subject to guardrails:
\[\max_x m_1(x)\]subject to:
\[m_j(x) \ge c_j, \quad j=2,\dots,m\]or, for safety constraints:
\[\text{violation}(x) \le \epsilon\]MOO versus MAB
| Concept | Multi-objective optimization | Multi-armed bandit |
|---|---|---|
| Core problem | Balance conflicting objectives | Explore and exploit uncertain actions |
| Typical setting | Static or periodically tuned | Sequential and adaptive |
| Output | Pareto set or weighted policy | Action-selection policy |
| Example | Relevance versus diversity | Explore new items versus exploit known items |
Generative recommendation and LLMs
The generative shift
Traditional recommenders score or rank known items. Generative recommenders model recommendation as conditional generation:
\[\hat{y} = \arg\max_{y} p(y \mid C)\]where $C$ includes user history, context, item metadata, queries, or retrieved information.
The generated output may be:
- An item identifier.
- A sequence of item identifiers.
- A semantic item ID.
- A natural-language explanation.
- A conversational recommendation.
- A multimodal recommendation artifact.
Semantic IDs
Semantic IDs represent items as sequences of discrete codes derived from content embeddings, often through residual vector quantization.
Item content
|
v
Dense item embedding
|
v
Residual quantization
|
v
Semantic ID tokens
|
v
Autoregressive recommendation model
A Semantic ID can be represented as:
\[\text{SID}(i) = (c_1,c_2,\dots,c_L)\]where each $c_l$ is selected from a learned codebook.
Semantic IDs may improve generalization to new or long-tail items because related items can share code structure.
Hybrid dense-generative systems
A practical architecture may combine dense retrieval with an LLM or generative ranker:
User context
|
+----------------------+
| |
v v
Dense retrieval Context and metadata
| |
+----------+-----------+
v
Candidate set
|
v
Generative ranker
|
v
Explanation and slate
Retrieval provides grounding and scalability. Generative models provide contextual reasoning, explanation, and flexible interaction.
Retrieval-augmented recommendation
A retrieval-augmented recommender retrieves relevant catalog, profile, or policy context before generating a recommendation or explanation.
This can reduce hallucination and improve factual grounding, but it introduces:
- Additional latency.
- Retrieval-quality dependence.
- Context-window constraints.
- Privacy and authorization requirements.
- More complex evaluation.
LLM use cases in recommendation
LLMs may support:
- Query understanding.
- Catalog enrichment.
- Item summarization.
- Natural-language explanations.
- Conversational preference elicitation.
- Cold-start item representation.
- Cross-domain transfer.
- Semantic ID generation.
- Agentic recommendation workflows.
LLMs should not replace all specialized models automatically. A production design must consider latency, cost, controllability, privacy, and the need for exact catalog grounding.
Production challenges
Offline-online mismatch
A model can improve offline metrics but perform worse online because of:
- Distribution shift.
- Exposure bias.
- Metric misalignment.
- Training-serving skew.
- Feedback loops.
- User adaptation.
- Latency or timeout behavior.
- Differences in candidate availability.
Reproducibility
Reproducible training requires versioning:
- Code.
- Data.
- Features.
- Dependencies.
- Random seeds.
- Model configurations.
- Training environment.
- Evaluation scripts.
Model freshness
User preferences and item popularity change. Systems may use:
- Periodic retraining.
- Incremental updates.
- Online learning.
- Streaming features.
- Time-decay features.
- Bandit exploration.
Latency
Latency can be improved through:
- Smaller first-stage models.
- ANN retrieval.
- Caching.
- Batching.
- Parallel candidate generators.
- Quantization.
- Distillation.
- Feature precomputation.
- Asynchronous enrichment.
- Efficient serving infrastructure.
Feature and model failures
A new feature can reduce performance if it introduces noise, leakage, or a mismatch with the target objective. Feature changes should be tested offline and online, with slice analysis and rollback capability.
Monitoring
Production monitoring should cover:
- Request latency.
- Candidate counts.
- Ranking distributions.
- Feature missingness.
- Model scores.
- Calibration.
- Engagement.
- Long-term retention.
- Safety violations.
- Fairness slices.
- Popularity and creator exposure.
- Drift and data quality.
Research-paper map
The supplied paper collection covers several influential production and research directions.
| Area | Representative work or system | Main idea |
|---|---|---|
| Candidate generation | YouTube recommendations | Separate retrieval and ranking neural networks |
| Feature interaction | Wide and Deep | Memorization plus generalization |
| Neural CF | NCF | Replace matrix-factorization interaction with an MLP |
| Sequential recommendation | Behavior Sequence Transformer | Model behavior history with self-attention |
| Generative retrieval | TIGER | Generate Semantic IDs for retrieval |
| Graph recommendation | PinSage | Scalable graph convolution for item embeddings |
| Large-scale graph recommendation | Pixie | Random walks over a very large object graph |
| Social recommendation | GraFRank and ELR | Model multimodal and edge-contextual relationships |
| Search and recommendation | Netflix systems | Combine ranking, search, evidence, and page generation |
| Marketplace recommendation | DoorDash | Combine relevance, diversity, location, and cold start |
| Real-time recommendation | Monolith | Real-time training and collisionless embedding tables |
| Multimodal product representation | ItemSage | Combine text and image information for item embeddings |
| Generative recommendation | PLUM and related work | Adapt language-model-style generation to recommendation |
Research reading strategy
Read papers according to the part of the system they address:
- Start with a two-stage production architecture.
- Study embeddings and matrix factorization.
- Study feature-interaction architectures.
- Study sequential and graph models.
- Study re-ranking, bias, and evaluation.
- Study bandits and counterfactual evaluation.
- Study semantic IDs and generative retrieval.
End-to-end reference architecture
The following design combines the main ideas covered in the source collection.
OFFLINE DATA PLANE
+------------------------------------------------------------------+
| Events | Catalog | User Data | Policies | Content | Experiments |
+------------------------------------------------------------------+
| | | | |
v v v v v
+------------------------------------------------------------------+
| Validation, Cleaning, Joining, Labeling, and Feature Generation |
+------------------------------------------------------------------+
| | | | |
v v v v v
+------------------------------------------------------------------+
| Embeddings | Feature Store | Popularity | Moderation | Policies |
+------------------------------------------------------------------+
| | | | |
+----------+-------------+-----------+----------+
|
v
+------------------------------------------------------------------+
| Model Training: Retrieval, Ranking, Calibration, Bandits, MOO |
+------------------------------------------------------------------+
|
v
+------------------------------------------------------------------+
| ANN Indices | Model Registry | Calibration Maps | Configurations |
+------------------------------------------------------------------+
|
v
ONLINE REQUEST
+------------------------------------------------------------------+
| User, Query, Device, Location, Session, Time, and Authorization |
+------------------------------------------------------------------+
|
v
+------------------------------------------------------------------+
| Candidate Generators: CF, Content, ANN, Popular, Search, Social |
+------------------------------------------------------------------+
|
v
+------------------------------------------------------------------+
| Eligibility Filters and Content Moderation |
+------------------------------------------------------------------+
|
v
+------------------------------------------------------------------+
| Feature Retrieval and Candidate Scoring |
+------------------------------------------------------------------+
|
v
+------------------------------------------------------------------+
| Calibration, Re-ranking, Diversity, Freshness, Fairness, MOO |
+------------------------------------------------------------------+
|
v
+------------------------------------------------------------------+
| Final Slate, Explanation, Logging, Feedback, and Monitoring |
+------------------------------------------------------------------+
System contracts
Each stage should expose clear contracts:
| Stage | Input | Output | Main quality requirement |
|---|---|---|---|
| Candidate generation | User and context | Broad candidate set | High recall and low latency |
| Filtering | Candidates and policy context | Eligible candidates | Safety and correctness |
| Ranking | Candidates and features | Scored candidates | Predictive quality and calibration |
| Re-ranking | Scores and constraints | Ordered slate | Diversity, fairness, freshness |
| Serving | Slate and presentation context | User response | Latency and reliability |
| Logging | Exposure and outcomes | Training and evaluation data | Causal and audit quality |
Implementation blueprint
Phase 1: Define the product objective
Write down:
- What users are trying to accomplish.
- What an item means in the product.
- What successful interaction means.
- Which outcomes are short-term.
- Which outcomes are long-term.
- Which outcomes must be prevented.
- Which stakeholders require coverage or fairness.
Phase 2: Build a baseline
Start with simple baselines:
- Global popularity.
- Segment popularity.
- Recently popular items.
- Item-to-item co-occurrence.
- Logistic regression.
- Matrix factorization.
- Simple content similarity.
A baseline provides a reference for complexity and failure analysis.
Phase 3: Build the data pipeline
Implement:
- Event collection.
- Catalog ingestion.
- Identity resolution.
- Time-aware joins.
- Feature computation.
- Negative sampling.
- Training and validation splits.
- Data-quality checks.
- Versioned datasets.
Phase 4: Add candidate generators
Use multiple generators:
- Collaborative filtering.
- Content-based retrieval.
- Two-tower ANN retrieval.
- Popularity and trending.
- Search-derived candidates.
- Exploration candidates.
Track candidate-source coverage and per-source recall.
Phase 5: Add ranking
Begin with a simple calibrated model, then add complexity only when needed.
Evaluate:
- Log loss.
- AUC.
- NDCG.
- MRR.
- Recall at candidate cutoffs.
- Slice-level metrics.
- Calibration.
Phase 6: Add re-ranking and guardrails
Implement:
- Deduplication.
- Diversity constraints.
- Freshness.
- Moderation.
- Creator or seller coverage.
- Geographic and age restrictions.
- Fairness checks.
- Business rules.
Phase 7: Run online experiments
Use a controlled rollout with:
- Primary metrics.
- Guardrail metrics.
- User segmentation.
- Minimum sample size.
- Rollback conditions.
- Monitoring dashboards.
- Experiment documentation.
Phase 8: Improve adaptivity
Consider:
- Contextual bandits.
- Online features.
- Incremental embeddings.
- Sequence models.
- Graph representations.
- Multi-objective tuning.
- Generative or conversational layers.
Phase 9: Productionize
Add:
- Model registry.
- Feature and schema versioning.
- Shadow testing.
- Canary deployment.
- Latency budgets.
- Fallback models.
- Monitoring and alerting.
- Audit logs.
- Privacy controls.
- Incident response.
Final technical takeaways
- A production recommender is usually a funnel, not a single model.
- Retrieval optimizes broad coverage and latency; ranking optimizes precision and utility.
- Re-ranking is where diversity, freshness, fairness, moderation, and business constraints can be enforced explicitly.
- Collaborative filtering discovers behavior-based relationships but is vulnerable to sparsity and cold start.
- Content-based representations help new items but can over-specialize.
- Two-tower models and ANN indices make large-scale retrieval practical.
- Ranking objectives must be chosen carefully because optimizing clicks, watch time, or revenue alone can create harmful behavior.
- Calibration matters whenever predicted probabilities drive downstream decisions.
- Search and recommendation increasingly share lexical, semantic, and hybrid retrieval infrastructure.
- Offline metrics are necessary but cannot replace online experimentation.
- Logged interaction data is biased by exposure, position, popularity, and previous policies.
- Counterfactual methods, randomized exposure, and contextual bandits help address feedback loops.
- Cold-start handling requires content, context, exploration, onboarding, or knowledge-based strategies.
- Wide and Deep, Factorization Machines, DeepFM, DCN, DLRM, and NCF represent different ways to model feature interactions.
- Graph neural networks exploit relationships among users, items, and interactions.
- Transformers model ordered behavior and long-range dependencies.
- Multi-objective optimization is needed when relevance, diversity, safety, fairness, and business value conflict.
- Generative recommendation reframes retrieval and ranking as conditional generation, often using semantic item identifiers.
- LLMs can support query understanding, metadata enrichment, explanations, conversational preference elicitation, and generative retrieval, but production deployment still requires grounding, latency control, and evaluation.
- The best practical system is usually the simplest architecture that meets the product’s quality, latency, safety, and operational requirements.
Resources
- Recommendation Systems: Introduction
- Candidate Generation
- Ranking and Scoring
- Re-ranking
- Calibration
- Popular Architectures
- Search and Information Retrieval
- Music Recommendation with PySpark
- Evaluation Metrics and Loss Functions
- Content Moderation
- Graph Neural Networks
- Transformers
- Challenges of Building a Recommender System
- Recommendation-System Research Papers
- Bias in Recommendation Systems
- Cold Start
- Multi-Armed Bandits
- Multi-Objective Optimization
- Generative AI in Recommender Systems