Özer Cem KELAHMETKELAHMET
Tools · Forecasting and tasks

Recommendation

Recommendation systems predict which items a user will like. Learn collaborative filtering, content-based and hybrid methods, metrics, cold start and tabular models.

Overview

A recommendation system predicts which items a user is likely to want and shows those items first. It learns from past interactions such as clicks, purchases, ratings and views, and from attributes of users and items. The goal is to turn a huge catalog into a short, personal list. Products, videos, articles, songs, hotels, flights and offers are all common examples.

Most recommenders combine a few simple ideas. People who behaved alike in the past will likely behave alike in the future. Items that share traits appeal to the same people. A model can learn compact vectors for users and items so that a high dot product means a likely match. Real systems add ranking, filtering and business rules on top. The problem is closely linked to Learning to rank, Clustering and embedding search with FAISS or HNSW.

What it is

A recommender takes a user (or a session, or a context) and returns a ranked list of items. The task can be framed in several ways.

  • Rating prediction. Predict the score a user would give an item.
  • Top-N recommendation. Return the N items with the highest predicted interest.
  • Next-item prediction. Given a sequence of recent actions, predict the next one.
  • Similar-item retrieval. Given an item, return items like it.
  • Bundle or slate generation. Choose a set of items that work well together.

Modern practice leans toward top-N and next-item framings, because a list is what the user sees.

Types of feedback

Feedback type Example Notes
Explicit Star rating, thumbs up Clear but rare and biased toward extremes
Implicit positive Click, view, purchase, play Plentiful, noisy, no direct negatives
Implicit negative Skip, quick bounce, return Useful but ambiguous
Context Time, device, location Adds situational signal
Content Text, images, categories, price Helps with new items

Implicit feedback is the norm. A missing interaction does not mean dislike. The user may never have seen the item. Good models treat unobserved pairs as unlabeled, not as negatives.

The interaction matrix

Picture a table where each row is a user and each column is an item. A cell holds an interaction value, or is empty. The table is huge and mostly empty. A dataset with a million users and a hundred thousand items has a hundred billion cells, and only a tiny share has a value. Recommendation is the art of filling in the empty cells well enough to rank them.

Analogy: a seating chart at a very large party. You know who talked to whom for a few minutes. You want to introduce people who would get along but have not met.

Main families of methods

Popularity. Recommend what is popular overall or in a segment. Simple and strong as a baseline.

Content-based filtering. Recommend items whose attributes match what the user liked before. Works for new items. Can become repetitive.

Collaborative filtering. Use the behavior of many users. It needs no item attributes. It struggles with new users and items.

Hybrid. Combine both, either by blending scores or by building a model that takes both kinds of input.

Sequence models. Model the order of actions with recurrent networks, transformers or simple Markov chains.

Reinforcement and bandit methods. Treat recommendation as a sequence of choices with feedback and trade off exploring against exploiting.

Where it came from

Early systems in the 1990s used neighborhood methods. They found users with similar tastes and averaged their ratings. Research groups built systems for news, movies and music, and online shops soon applied item-to-item similarity at scale. Item-based collaborative filtering was attractive because item similarities change slowly and can be precomputed.

A public prize competition around the mid 2000s on movie ratings made matrix factorization famous. Teams learned that factorizing the rating matrix into low-dimensional user and item factors beat neighborhood methods, and that blending many models helped further. Work on implicit feedback followed, including weighted matrix factorization for confidence-weighted interactions and Bayesian personalized ranking, which optimizes a pairwise ranking loss.

Factorization machines generalized matrix factorization to arbitrary feature sets. Wide and deep models in the mid 2010s combined memorization of feature crosses with generalization through embeddings. Two-tower neural networks became standard for retrieval. Sequence-aware models based on recurrent networks and later transformers captured the order of actions. Graph neural networks represented users and items as nodes and learned from the interaction graph; see GCN and GraphSAGE.

More recently, large language models and foundation models have entered the field, both as feature extractors for text and as rerankers or explainers. The central ideas of embeddings, implicit feedback and ranking have stayed stable.

How it works

Step 1: collect and clean interactions

Logs record who did what to which item and when. Cleaning removes bots, duplicates and test traffic. Anomaly detection helps find unusual users such as scrapers. Timestamps are kept because later steps depend on time.

Step 2: build features and ids

Users and items get ids. Item attributes (category, price, brand, text) and user attributes (region, plan type, device) are encoded. Rare ids are bucketed. Text and images become embeddings via encoders.

Step 3: choose a model family

Neighborhood methods

For user-based filtering, find the k most similar users to the target and average their ratings on candidate items. For item-based filtering, find items similar to those the user liked. Similarity is computed with cosine or correlation on the interaction vectors.

Analogy: asking friends with similar taste what film to watch tonight.

Matrix factorization

Learn a vector for each user and each item so that their dot product approximates the interaction. The vectors are small, for example 32 to 256 numbers. Training minimizes an error plus a regularization term.

text
predicted(u, i) = dot(user_vector[u], item_vector[i]) + user_bias[u] + item_bias[i]

The vectors capture hidden traits. One dimension might loosely track "action versus drama," but nobody tells the model that.

Analogy: describing every guest and every dish by a few flavor scores. If a guest likes sweet and spicy, and a dish scores high on both, it is a good match.

Implicit-feedback factorization

For clicks and purchases, each observed interaction has high confidence, and unobserved cells have low confidence. Alternating least squares can solve this at scale. Bayesian personalized ranking samples triples of a user, a positive item and a sampled negative item, and trains the model to score the positive higher.

Two-tower models

One neural network (the user tower) maps user features and history to a vector. A second (the item tower) maps item features to a vector. The score is the dot product. Training uses in-batch negatives and a softmax loss. After training, item vectors go into an approximate nearest neighbor index such as HNSW, IVF-PQ or FAISS. At request time, compute the user vector and search the index. This gives retrieval in milliseconds over millions of items.

Sequence models

Treat the last N actions as a sentence and the next item as the next word. A transformer reads the sequence and predicts the next item. See Transformers. This captures session intent: someone viewing three tents is probably planning a trip.

Graph models

Build a bipartite graph of users and items. Propagate information along edges so that each node's vector reflects its neighbors. This captures multi-hop relations such as "users who bought what your neighbors bought."

Step 4: retrieve candidates

Run one or several retrievers: collaborative, content-based, popular, recent, trending. Merge their outputs into a candidate set of a few hundred items.

Step 5: rank

A ranker scores each candidate using many features, including retrieval scores, user-item interactions, freshness and price. Gradient boosting or a neural model is common. See Learning to rank, XGBoost and LightGBM.

Step 6: re-rank and apply rules

The final stage removes items already bought, enforces diversity, applies stock and policy rules, and inserts sponsored or editorial items where allowed.

Step 7: learn from feedback

Every impression and action is logged. The loop retrains models on a schedule or continuously. Because the model decides what users see, the data is shaped by past recommendations. Exploration and randomization reduce this feedback-loop bias.

Handling cold start

  • New user: use popularity, context such as location and time, onboarding questions, or a first-session bandit.
  • New item: use content features, similarity to known items, and a small exploration budget.
  • New system: start with rules and popularity, collect data, then add learning.

Key concepts and terms

Term Meaning
User-item matrix Table of interactions, mostly empty
Embedding Dense vector representing a user or item
Latent factor Hidden trait learned by the model
Implicit feedback Behavior such as clicks or purchases
Cold start Lack of data for a new user or item
Candidate generation Cheap stage that finds a few hundred options
Ranking Stage that orders the candidates
Negative sampling Choosing non-interacted items as pseudo negatives
Popularity bias Tendency to recommend already popular items
Exposure bias Users can only interact with what they were shown
Diversity How different the recommended items are from each other
Novelty How unfamiliar the items are to the user
Serendipity Pleasant surprise: relevant and unexpected
Coverage Share of the catalog that ever gets recommended
Hit rate at k Whether a held-out item appears in the top k
NDCG Position-weighted ranking quality
Recall at k Share of relevant items found in the top k
Bandit Method that balances exploring and exploiting

Offline and online metrics

Offline metrics use logged data. Hold out the last interaction of each user, ask the model for a top-N list, and check whether the held-out item appears. Hit rate, recall, MAP and NDCG are common. These measures are cheap but rely on past exposure.

Online metrics use live experiments. Click-through rate, conversion, revenue per session, retention and long-term satisfaction are typical. A/B tests are the standard tool. Guardrail metrics such as complaint rate or unsubscribe rate protect against short-term gains with long-term harm.

Offline gains often do not translate online. A model that predicts what users would have clicked anyway looks strong offline and adds nothing online. Counterfactual evaluation and careful experiments help.

A worked example

This example builds a tiny matrix factorization recommender with synthetic data and plain NumPy. It uses implicit feedback and a ranking loss.

python
import numpy as np

rng = np.random.default_rng(0)

n_users, n_items, dim = 300, 120, 16

# Hidden truth: users and items live in a small taste space
true_u = rng.normal(size=(n_users, 4))
true_i = rng.normal(size=(n_items, 4))
affinity = true_u @ true_i.T

# Simulate implicit clicks: the top affinity items are clicked with noise
clicks = []
for u in range(n_users):
    probs = np.exp(affinity[u] * 1.5)
    probs /= probs.sum()
    items = rng.choice(n_items, size=12, replace=False, p=probs)
    clicks.extend((u, int(i)) for i in items)

# Hold out the last click of each user for testing
by_user = {}
for u, i in clicks:
    by_user.setdefault(u, []).append(i)
train = [(u, i) for u, items in by_user.items() for i in items[:-1]]
test = {u: items[-1] for u, items in by_user.items()}
seen = {u: set(items[:-1]) for u, items in by_user.items()}

U = rng.normal(scale=0.1, size=(n_users, dim))
V = rng.normal(scale=0.1, size=(n_items, dim))
lr, reg = 0.05, 0.01

for epoch in range(30):
    rng.shuffle(train)
    for u, pos in train:
        neg = int(rng.integers(n_items))
        while neg in seen[u]:
            neg = int(rng.integers(n_items))
        x = U[u] @ (V[pos] - V[neg])
        g = 1.0 / (1.0 + np.exp(x))       # gradient of -log sigmoid(x)
        du = g * (V[pos] - V[neg]) - reg * U[u]
        dp = g * U[u] - reg * V[pos]
        dn = -g * U[u] - reg * V[neg]
        U[u] += lr * du
        V[pos] += lr * dp
        V[neg] += lr * dn

def hit_rate_at(k):
    hits = 0
    for u, target in test.items():
        scores = U[u] @ V.T
        scores[list(seen[u])] = -np.inf   # do not recommend seen items
        top = np.argpartition(-scores, k)[:k]
        hits += int(target in top)
    return hits / len(test)

print("HitRate@10:", hit_rate_at(10))

How to read this example:

  • The loss is the Bayesian personalized ranking idea: for each user, the clicked item should outscore a random unclicked item.
  • Seen items are excluded at test time, which mirrors real use.
  • The hold-out is the last event per user, a simple temporal split.
  • The popularity baseline is easy to add: count clicks per item and rank by count. Always compare against it.

A numeric walk-through

Suppose a user vector is [0.8, 0.1] and two item vectors are A = [0.9, 0.0] and B = [0.1, 0.9]. The dot products are 0.72 for A and 0.17 for B. The model recommends A first. If the user then clicks B, the next training step nudges the user vector a bit toward B's direction, and B's vector a bit toward the user's. After many such updates, vectors of users and the items they like end up close together.

A neural version in outline

python
import torch
import torch.nn as nn
import torch.nn.functional as F

class TwoTower(nn.Module):
    def __init__(self, n_users, n_items, dim=64):
        super().__init__()
        self.user = nn.Embedding(n_users, dim)
        self.item = nn.Embedding(n_items, dim)

    def forward(self, u, i):
        zu = F.normalize(self.user(u), dim=-1)
        zi = F.normalize(self.item(i), dim=-1)
        return zu @ zi.T          # in-batch similarity matrix

model = TwoTower(1000, 5000)
opt = torch.optim.Adam(model.parameters(), lr=1e-3)

def step(users, pos_items, temperature=0.1):
    logits = model(users, pos_items) / temperature
    labels = torch.arange(len(users))
    loss = F.cross_entropy(logits, labels)   # other positives act as negatives
    opt.zero_grad(); loss.backward(); opt.step()
    return loss.item()

This is the same in-batch contrastive idea as InfoNCE and Contrastive learning. It is written in PyTorch.

Strengths and limitations

Strengths

  • Turns large catalogs into short personal lists.
  • Learns from behavior without needing hand-written rules.
  • Scales with embeddings and approximate nearest neighbor search.
  • Combines many signals: content, context, sequence and graph.
  • Improves with more data and feedback.
  • Can support discovery, not only repeat purchases.

Limitations

  • Cold start for new users and items.
  • Feedback loops: the system shapes the data it learns from.
  • Popularity bias: popular items get more exposure, then more clicks.
  • Filter bubbles: users see narrower content over time.
  • Implicit signals are noisy and can be misread. A click is not always a like.
  • Offline metrics can mislead.
  • Privacy and consent constraints limit the data you can use. Regulations on personal data apply.
  • Hard to explain to users and auditors without extra work.
  • Metrics that favor short-term engagement can harm long-term trust.

How it compares with alternatives

Approach Needs Handles new items Handles new users Typical use
Popularity Counts Partly Yes Baseline, fallback
Content-based Item attributes Yes Needs a profile Catalogs with rich metadata
User-based CF Interaction history No No Small, stable sets
Item-based CF Interaction history No Partly (with one action) Retail, "also bought"
Matrix factorization Interactions No No Core collaborative baseline
Two-tower Interactions plus features Yes (with features) Yes (with features) Large-scale retrieval
Sequence model Ordered logs Partly Partly Sessions, feeds
Graph model Interaction graph Partly Partly Rich relational data
Bandit Online feedback Yes Yes Exploration, cold start
Learning to rank Candidate features Depends on features Depends on features Final scoring
Clustering Vectors Yes Yes Segments, diversity

A recommender is not the same as search. Search starts from a query the user typed. Recommendation often starts from nothing but history. In practice, products mix them: a search page shows personalized ranking, and a home page shows recommendations.

Role in tabular foundation models

Recommendation data is tabular in most production stacks. The interaction log is a table with user id, item id, time, action and context. The feature store holds tables of user and item attributes. Ranking datasets are tables where each row is a user-item candidate. That is why recommendation is a natural field for models that learn from raw tables.

Rows, columns and mixed types

A recommender row mixes numbers (price, age of item, counts), categories (brand, region, device), timestamps and ids. Tabular foundation models such as TabPFN, TabICL, TabSTAR, FT-Transformer and SAINT are designed to read such mixed rows. They tokenize numeric and categorical cells, then relate cells within a row and rows within a table through attention. See /model/architecture for how this kind of design works.

High-cardinality ids

User and item ids are the hard part. There may be millions of them, and an id has no meaning on its own. Classic tabular models bucket or hash ids. Embedding tables handle them better but need lots of data. For tabular foundation models, a practical approach is to replace raw ids with aggregated behavior features (counts, recency, category shares) or with embeddings from a collaborative model, and to feed those to the foundation model. Treating raw ids as unseen categories fits poorly with pre-training on tables whose ids carry no meaning.

Pre-training on synthetic or real tables

Models pre-trained on a broad prior of synthetic tables learn general rules such as monotone effects, interactions and noise handling. A click-propensity table with a handful of features looks like many tasks from that prior. This allows a small recommendation team to get a strong pointwise click or purchase model with little tuning. For research on this style of training see /model/research, and for comparisons see /model/benchmarks.

In-context learning

In-context learning gives the model labeled rows as examples and asks it to predict new rows without weight updates. For recommendation this has a useful form: take recent labeled impressions for a segment or a new campaign as context, and score new candidates. It is a quick way to adapt to a niche or a new market with few labels. Context length limits how many rows fit, so you sample or summarize.

No column names

Many recommender tables have anonymous or coded feature names, especially when data comes from partners or from privacy-protected exports. A model that depends on column names fails. A tabular foundation model that learns from values and their joint behavior can work without names, though it benefits from names when they are available.

Missing values and imputation

Interaction features are full of holes: no history for a new user, no rating for most items, unknown location. Gradient boosting handles missing values natively. Foundation models handle them through masking during pre-training; see Masked cell modeling. Learned imputers, described in Imputation networks, can fill missing attributes before ranking. In fact, matrix factorization is itself an imputation method: it fills the empty cells of the interaction matrix.

Continual learning

Taste, catalogs and seasons shift. Retraining from scratch is costly and can forget rare patterns. Continual learning methods such as Experience replay, EWC and Synaptic Intelligence preserve earlier knowledge while the model updates on new data. In recommendation this helps keep long-tail knowledge while adapting to trends.

Anomaly detection

Fake reviews, click farms and bot traffic distort interaction data. Anomaly detection with Isolation forest or learned scores removes suspicious users and items before training. Clean data improves both the recommender and the foundation model that reads the table.

Sector and semantic classification

Item descriptions and categories vary across merchants and catalogs. Semantic classification assigns each item to a standard category or sector from its text and attributes, even when category columns are inconsistent. That unified label becomes a strong feature and a handle for cross-catalog models. See Semantic sector heads.

Where tabular foundation models help most

  • Small or new segments with few labels.
  • Click, conversion and churn propensity models used as features.
  • Fast baselines without heavy tuning.
  • Tables with anonymous or inconsistent columns.

Where they help less

  • Retrieval over millions of items, which needs embeddings and an ANN index, not a row-wise model.
  • Extremely large logs with billions of rows, where specialized embedding models and boosted trees scale better.
  • Deep sequence modeling of raw event streams, where sequence transformers fit better.

Practical guidance and best practices

Start with a baseline

  • Build a popularity baseline per segment first.
  • Add an item-to-item "also viewed" model.
  • Only then add learned retrieval and ranking.

Data and splits

  • Split by time. Train on the past, test on the future.
  • Never let the same interaction appear in both train and test.
  • Remove or cap heavy users and bots so they do not dominate training.
  • Keep position and impression logs, not just clicks.

Negatives

  • Use impressions that were shown but not clicked as hard negatives when available.
  • Otherwise sample negatives, ideally with popularity-aware sampling.
  • Do not treat all unobserved items as true dislikes.

Evaluation

  • Report multiple metrics: hit rate, NDCG, coverage, diversity and novelty.
  • Slice by new versus returning users and by item age.
  • Compare with the baseline in every report.
  • Use online experiments for the final decision.

Diversity and fairness

  • Add diversity re-ranking so lists are not made of near duplicates.
  • Track exposure for providers, sellers or creators and set minimums if needed.
  • Include user controls such as "not interested" and use them as signals.

Serving

  • Precompute item vectors and index them with an ANN library.
  • Cache user vectors for active users.
  • Budget latency per stage.
  • Keep a safe fallback list for failures.

Privacy

  • Collect only what you need and respect consent choices.
  • Prefer aggregated or pseudonymous features where possible.
  • Provide ways to delete or export a user's data as the law requires.

A quick design checklist

Use this list when you plan a first recommender.

  1. Decide what a good outcome is: a purchase, a play, a return visit.
  2. List the surfaces: home page, item page, email, cart.
  3. Choose the candidate sources and a fallback.
  4. Choose the ranking label and the metric that matches it.
  5. Plan the time-based split and the baseline.
  6. Define guardrails for diversity, fairness and complaints.
  7. Plan the experiment and the rollback.

Each surface may need its own model. An item page wants similar items. A cart page wants complements. A home page wants a mix. Treat them as separate products that share data and infrastructure.

Common mistakes

  1. Random split of interactions. Leaks future behavior into training.
  2. Treating missing as negative. Teaches the model that unseen means disliked.
  3. Ignoring popularity bias. Leads to the same blockbuster items for everyone.
  4. Optimizing clicks only. Can promote clickbait and hurt retention.
  5. No cold-start plan. New users get an empty page.
  6. Skipping the baseline. Without it, you cannot tell whether complexity pays off.
  7. Evaluating only offline. Offline lifts may vanish online.
  8. Recommending items already bought. Unless repeat purchase is the point.
  9. Forgetting business rules. Stock, age limits, region rules and legal filters must be applied.
  10. Overfitting to heavy users. Light users are the majority in most products.
  11. Feeding raw ids to a model that cannot handle them. Aggregate or embed first.
  12. Letting the feedback loop run unchecked. Add exploration and monitor coverage.

Frequently asked questions

What is a recommendation system?

A recommendation system is software that predicts which items a person will want and shows them in a ranked list. It learns from past behavior, such as clicks and purchases, and from attributes of users and items. It is used for products, media, travel, offers and many other catalogs.

What is the difference between collaborative filtering and content-based filtering?

Collaborative filtering learns from the behavior of many users and needs no knowledge of what the items are. Content-based filtering learns from item attributes and matches them to a user profile. Collaborative methods find surprising matches but struggle with new items, while content-based methods handle new items but can be repetitive.

How does matrix factorization work?

Matrix factorization learns a short vector for each user and each item so that the dot product of a user vector and an item vector predicts the interaction. The vectors capture hidden traits that explain the data. Training adjusts the vectors to reduce prediction error on observed interactions, with regularization to avoid overfitting.

What is the cold start problem?

Cold start means the system lacks data about a new user or a new item, so it cannot rely on past behavior. Common fixes are content features, popularity fallbacks, short onboarding questions, similarity to known items and a small exploration budget through bandit methods.

How do I evaluate a recommender?

Offline, hold out recent interactions and measure hit rate, recall and NDCG at a cutoff, plus coverage and diversity. Online, run A/B tests and measure conversion, retention and guardrail metrics. Offline results guide development, but online tests make the final decision.

What is implicit feedback?

Implicit feedback is behavior that suggests interest without an explicit rating, such as clicks, views, plays and purchases. It is abundant but noisy, and it has no clear negatives. Models for implicit feedback usually treat unobserved pairs as unlabeled and use confidence weights or sampled negatives.

Can tabular foundation models be used for recommendation?

They fit best as scorers inside the ranking stage, for example to predict click or purchase probability from a row of features, and for small or new segments with few labels. They are not a replacement for embedding-based retrieval over millions of items, which needs vector indexes and specialized models.

How should I handle user and item ids?

Raw ids carry no meaning on their own and have very high cardinality. Use learned embeddings in a collaborative model, or replace ids with aggregated behavior features such as counts, recency and category shares. Hashing or bucketing rare ids is a common fallback in boosted tree pipelines.

What is popularity bias and how can I reduce it?

Popularity bias is the tendency of a recommender to push already popular items, which then gain even more exposure. Reduce it with popularity-aware negative sampling, re-ranking for diversity, exposure constraints, and exploration that gives less-seen items a fair chance.

No. Search starts from a query that a user types, while recommendation often starts from history and context with no query. Both rank items, and both use similar tools such as embeddings and learning to rank, so many products blend them.

Glossary

  • A/B test: An online experiment comparing two versions.
  • ALS: Alternating least squares, a method for fitting factorization models.
  • ANN: Approximate nearest neighbor search over vectors.
  • Bandit: An online method that balances exploring new options and exploiting known good ones.
  • BPR: Bayesian personalized ranking, a pairwise loss for implicit feedback.
  • Candidate generation: The stage that finds a manageable set of items to rank.
  • Click-through rate: Clicks divided by impressions.
  • Cold start: Lack of data for new users or items.
  • Collaborative filtering: Recommending from the behavior of similar users or items.
  • Content-based filtering: Recommending from item attributes.
  • Coverage: Share of the catalog that gets recommended.
  • Embedding: A dense vector that represents an entity.
  • Exposure bias: Bias from the fact that users only act on what was shown.
  • Hybrid recommender: A system that combines several methods.
  • Implicit feedback: Behavior used as a proxy for preference.
  • In-batch negatives: Other items in the same training batch used as negatives.
  • Latent factor: A hidden trait learned by a model.
  • Matrix factorization: Approximating the interaction matrix by a product of two small matrices.
  • Slate: A set of items shown together.
  • Two-tower model: A pair of networks that embed users and items separately.

Summary

A recommendation system turns a large catalog into a short, personal, ranked list. It learns from interactions and attributes using neighborhood methods, matrix factorization, two-tower networks, sequence models and graphs, and it works in stages: retrieve, rank, re-rank and apply rules. The hard parts are cold start, noisy implicit feedback, popularity bias, feedback loops and the gap between offline and online metrics.

Because recommender data lives in tables with mixed types, missing values and sometimes anonymous columns, tabular foundation models can add value as fast scorers, imputers and anomaly filters, especially for small segments. They complement, rather than replace, embedding retrieval and boosted-tree rankers. Build a baseline first, split by time, measure with several metrics, and confirm gains with online tests. For more background see /model/research, /model/architecture and /model/benchmarks.

It belongs to Forecasting and tasks in my stack, under Foundation models and applied ML. Others in the same group:

Type to search.
    ↑↓ navigate↵ open