How does collaborative filtering work?
It starts from a matrix of users by items, mostly empty, where each cell holds a rating or a yes. To fill an empty cell it finds a pattern in the filled ones. The core idea is that people who agreed in the past tend to agree again. A model then ranks the items a user has not seen by predicted score and shows the top few.
A worked example with ratings out of 5:
| Film A | Film B | Film C | |
|---|---|---|---|
| Ana | 5 | 4 | ? |
| Ben | 5 | 4 | 5 |
| Cleo | 1 | 2 | 1 |
Ana’s ratings match Ben’s closely and Cleo’s not at all, so the system predicts Ana will rate Film C close to Ben’s 5 and recommends it.
What are the types of collaborative filtering?
| Type | Compares | Good for |
|---|---|---|
| User-based | Users to similar users | Small catalogs, explainable results |
| Item-based | Items to items rated alike by the same users | Large user bases, stable catalogs |
| Matrix factorization | Learned hidden factors for users and items in one shared space | Sparse data at scale |
Matrix factorization is the workhorse at scale. The shared space is what embeddings provide: a user and an item are close when the user is likely to like it. Neighbor methods use the same idea as k-nearest neighbors.
When does collaborative filtering fail?
Three weaknesses recur. A new user or item has no history, the cold-start problem. Sparse data, where most users rate few items, makes similarities unreliable. And popular items dominate, so the long tail is rarely shown. It also learns whatever the crowd does, including bias, so check who is missing from your data. A common remedy is a hybrid that adds content signals such as category or text similarity, like those behind semantic search.
How does collaborative filtering relate to modern AI?
It remains the core of recommendation in retail and media, and the same logic powers “customers also bought” for AI in retail. Language models add a different route: describing items in text and matching intent. Many production systems use both, with collaborative signals for who tends to buy what and a language model for explaining the pick. Start from an item-based baseline on your order history before reaching for anything heavier, and measure it against a simple “most popular” list.