Recommender and Ranking Systems
Collaborative Filtering and Content-Based Recommendation · 16 min
Recommendation is fundamentally a prediction problem with a twist: instead of predicting a single well-defined label, a recommender must estimate, for every user, how much that user would value each of potentially millions of items, using only a sparse record of past interactions. The two classical strategies for making this estimate are content-based filtering and collaborative filtering. Content-based filtering represents items by their attributes — genre, cast, text features, audio embeddings — and represents a user by the attributes of items that user has previously liked, then recommends new items whose attribute profile resembles the user's profile. This approach needs no data from other users and handles new items gracefully as soon as their attributes are known, but it struggles to recommend anything that differs stylistically from a user's established taste and requires rich, well-curated item metadata to work at all. In practice, item attributes might be represented as bag-of-words or TF-IDF vectors over text descriptions, categorical tags such as genre, or learned embeddings, and the quality of the resulting recommendations is bounded by how well those attributes actually capture what makes an item appealing.
Collaborative filtering takes the opposite bet: it ignores item content entirely and instead exploits regularities in the pattern of interactions across many users. The term itself was introduced by David Goldberg, David Nichols, Brian Oki, and Douglas Terry in their 1992 description of the Tapestry system built at Xerox PARC, which let users annotate documents they had read and made those annotations available to other users' filters, so that people collaborated to filter a shared stream of email and news rather than each filtering alone. Modern collaborative filtering generalizes this idea algorithmically: user-based approaches find other users with similar rating histories and recommend what those neighbors liked, while item-based approaches find items with similar rating patterns across the user base and recommend items similar to ones a user already rated highly. Similarity is typically computed with cosine similarity or Pearson correlation over the rows or columns of a sparse user-item ratings matrix, and predictions are formed as similarity-weighted averages of neighbors' ratings.
Collaborative filtering's central strength is that it can surface serendipitous recommendations with no understanding of why an item is good — it only needs enough co-occurring ratings to detect the pattern — but this same property is its central weakness. A new user with no ratings and a new item with no ratings are both invisible to the algorithm, a failure mode known as the cold-start problem, and the underlying ratings matrix is typically more than ninety-nine percent empty for large catalogs, which makes neighbor-finding statistically noisy unless it is regularized carefully. Production systems therefore rarely rely on pure collaborative or pure content-based filtering; they combine both signals, along with contextual features like time of day and device, in hybrid architectures. A hybrid design can, for instance, fall back on content similarity to bridge the cold-start gap for a brand-new item while still relying on collaborative signal for items with an established interaction history, letting each component cover the other's characteristic blind spot.
Matrix Factorization and Learning to Rank · 16 min
Neighborhood-based collaborative filtering compares users or items directly, but a more powerful family of methods instead assumes that both users and items can be described by a small number of latent factors — hidden dimensions that might loosely correspond to things like genre preference or production budget, though the model never labels them explicitly. Matrix factorization learns a low-dimensional vector for every user and every item such that the dot product of a user's vector and an item's vector approximates that user's rating for that item, and it fills in the vast majority of unobserved entries in the ratings matrix by exploiting the low-rank structure it discovers. Yehuda Koren, Robert Bell, and Chris Volinsky's account of the techniques used in the Netflix Prize competition showed that matrix factorization models, fit by gradient descent or alternating least squares and regularized to avoid overfitting the sparse observed ratings, systematically outperformed classic nearest-neighbor techniques and could be extended to incorporate implicit feedback, changing user preferences over time, and varying confidence in different observations.
Producing a good rating prediction for every item is not the same task as producing a good ordered list of the top few items to show a user, and this distinction motivated the learning-to-rank subfield. Pointwise approaches simply predict a relevance score for each item independently and sort by that score, but this ignores the fact that ranking quality depends on relative order, not on getting each score numerically exact. Pairwise approaches instead train the model on pairs of items with a known preference order and optimize the model to correctly predict which of the two should rank higher. Chris Burges and colleagues developed RankNet along these lines, defining a probabilistic cost function over pairs of documents and training a neural network with gradient descent so that, for any pair where one document is known to be more relevant than the other, the network's predicted probability of that ordering is pushed toward one; they validated the method on both synthetic data and real query logs from a commercial search engine.
A third family, listwise approaches, optimizes an objective computed over the entire ranked list at once, directly targeting ranking-quality metrics such as normalized discounted cumulative gain rather than a proxy loss defined on pairs or points. The choice among pointwise, pairwise, and listwise formulations trades off computational cost against how faithfully the training objective matches the metric that will actually be used to judge the system, and in production settings the ranking model is typically only the final stage of a pipeline: a fast retrieval step first narrows millions of items down to a few hundred candidates, and the learning-to-rank model then orders that much smaller candidate set with more expensive features. This retrieval-then-rank split exists because scoring every catalog item with a full ranking model is computationally infeasible at serving time, so a cheaper, high-recall retrieval stage is used to discard the vast majority of clearly irrelevant items before the more expensive, higher-precision ranking stage is ever invoked.
Feedback Loops and Bias in Deployed Recommenders · 14 min
A recommender system trained on historical interaction data is not observing a neutral sample of what users want; it is observing what users did in response to a previous version of the very system being trained, which means the training data is entangled with the model's own past decisions. A 2020 survey by Chen and colleagues catalogs several distinct biases that arise from this entanglement. Selection bias arises because users mostly rate items they already chose to consume, so the observed ratings are not a random sample of how a user would rate everything. Exposure bias arises because an item a user never interacted with might be something they would have loved had it ever been shown to them, so the absence of an interaction is not reliable evidence of disinterest. Position bias arises because users disproportionately click on whatever is placed near the top of a ranked list regardless of its true relevance, which can make a mediocre item look good simply because it was ranked highly, for reasons that may have had nothing to do with its quality.
These biases compound into a feedback loop: a model exposes certain items more, users interact with those items more because they were shown more, that interaction data trains the next version of the model, and the model exposes those same items even more heavily than before. The survey describes this self-reinforcing dynamic as amplifying popularity bias, where already-popular items are recommended even more disproportionately to their genuine popularity, a pattern often called the Matthew effect after the sociological observation that advantage compounds. Left unaddressed, such loops can narrow the effective diversity of what a platform surfaces over time, systematically disadvantage new or niche items and the users who would have preferred them, and make offline evaluation on historical logs a biased measure of how a new ranking policy will actually perform once deployed, since the historical logs were themselves generated by a different, earlier policy, a circularity that makes naive historical backtesting an unreliable substitute for live or counterfactual evaluation.
Addressing feedback-loop bias generally requires techniques that go beyond simply fitting historical interaction data more accurately. These include propensity-based reweighting of observed interactions to correct for the non-random way items were exposed, explicit exploration strategies that occasionally show under-exposed items to gather less biased signal, and evaluation protocols such as randomized interleaving or held-out logged bandit data that attempt to estimate how a candidate policy would perform under exposure patterns different from the one that generated the training data. None of these techniques fully eliminates the feedback problem, and understanding the qualitative shape of the bias — knowing which failure mode a given symptom points to — remains a prerequisite for choosing a sensible mitigation. A platform observing declining catalog diversity, for example, is facing a different underlying problem than one observing degraded recommendations for new users, even though both might show up as a drop in the same aggregate engagement metric.
Cosine Similarity Between Two Users
Ada rated three movies 5, 3, 4 and Ben rated the same three 4, 2, 5. Their cosine similarity of about 0.97 is computed directly from the dot product (46) divided by the product of the two vectors' magnitudes (7.07 × 6.71 ≈ 47.4), showing them as strong neighbors for a one-neighbor prediction.
- Content-based filtering compares item attributes to a user's own profile, while collaborative filtering compares interaction patterns across users or items — production systems typically blend both to cover each other's blind spots.
- Matrix factorization replaces direct neighbor comparison with a small set of learned latent factors per user and item, and its dot-product predictions filled in the overwhelming majority of a ratings matrix that was more than ninety-nine percent empty in the Netflix Prize data.
- A recommender's own past output shapes the data it is next trained on, so exposure, position, and popularity biases compound into feedback loops that offline evaluation on historical logs cannot fully detect.
Recall Practice
Glossary
- Collaborative filtering
- Recommending items to a user based on patterns of interaction across many users, without relying on the content or attributes of the items themselves.
- Content-based filtering
- Recommending items whose attributes resemble the attributes of items a specific user previously liked, using item metadata rather than other users' behavior.
- Matrix factorization
- A technique that represents users and items as low-dimensional latent vectors whose dot product approximates observed ratings, filling in most of a sparse interaction matrix.
- Learning to rank
- A family of methods — pointwise, pairwise, and listwise — that train a model to order a list of items rather than to predict each item's score in isolation.
- Cold-start problem
- The difficulty of making good recommendations for a new user or new item that has little or no interaction history for the model to learn from.
- Exposure bias / feedback loop
- The distortion that arises when a recommender's own past decisions about what to show shape the interaction data it is subsequently trained on, reinforcing previously favored items.
Hand-Compute a User-Based Collaborative Filtering Prediction
A fully worked, paper-and-pencil exercise: given two users' ratings on three co-rated movies, compute the cosine similarity between their rating vectors by hand (dot product divided by the product of vector magnitudes), then use that similarity to make a one-neighbor rating prediction for a fourth movie. No software is run and no real user data is collected — every number is provided in the exercise and the arithmetic is checked step by step, exactly as it would be worked through on paper in a course problem set.
Ready to test yourself?
5 questions on this module.