Session-based recommendation

On this page 7

Session-based recommendation is the task of predicting the next item a user will interact with using only the ordered events of the current session, such as clicks, views, searches and add-to-cart actions, without relying on a persistent user profile. Within recommender systems, it addresses the common situation in which visitors are anonymous, logged out or behave very differently from one visit to the next.

The approach treats a session as a short sequence with a coherent intent, for example shopping for running shoes or browsing news about one event. Models learn transition patterns between items across millions of past sessions and apply them in real time to the few events the current visitor has produced.

How session-based recommendation models a visit

A session-based recommender represents each session as an ordered list of item identifiers, often enriched with event type, dwell time and timestamp, and outputs a ranked list of candidate items for the next step. Sessions are usually delimited by inactivity timeouts, commonly about 30 minutes, or by explicit events such as checkout.

Training uses historical logs: each prefix of a session becomes an input and the following item becomes the target. The model learns item embeddings and a session encoder that compresses the prefix into one vector, which is then scored against all candidate items. Because no user identifier is needed, the method works on the first page view of a new visitor, which directly mitigates the user side of the cold start problem.

The table below lists the signals typically available inside a session and what they reveal.

SignalWhat it indicatesTypical use
Item click or viewCurrent interestCore sequence input
Dwell timeStrength of interestWeighting or filtering short bounces
Add to cartPurchase intentHigher weight, complementary items
Search queryExplicit needCandidate filtering and context
Device and referrerContext of the visitContext features for ranking
Signals inside a session

Main model families

Session-based recommendation methods range from simple co-occurrence heuristics to deep neural sequence models, and the simple methods remain surprisingly competitive. Careful benchmark studies have repeatedly shown that well-tuned nearest-neighbor baselines can match or beat many neural models on public datasets.

FamilyRepresentative methodsKey ideaMain trade-off
Item-to-item rulesCo-occurrence, sequential rulesRecommend items that followed the last itemIgnores earlier events
Session k-nearest neighborsSKNN, V-SKNN, STANFind similar past sessionsMemory and lookup cost at scale
Recurrent networksGRU4RecEncode the sequence step by stepSensitive to loss and sampling choices
Attention modelsNARM, STAMP, SASRecWeight events by relevance to intentNeeds more data and tuning
Graph neural networksSR-GNNModel the session as an item graphHigher training cost
Model families for session-based recommendation

Neural models need a sampled softmax or ranking loss with negative sampling, because scoring every item in a catalog of millions at each step is too expensive. The choice of loss and the number of negatives often affect accuracy as much as the architecture itself.

Session-based recommendation is a special case of sequential recommendation in which the sequence is limited to one visit and no cross-session history is assumed. Session-aware variants combine both by adding a long-term user representation when the visitor is known.

ApproachInputNeeds user identityBest fit
Session-based recommendationEvents of the current sessionNoAnonymous traffic, fast-changing intent
Sequential recommendationFull interaction historyYesLogged-in users with long histories
Collaborative filteringUser-item matrixYesStable long-term preferences
Next-basket recommendationSequence of past basketsYesGrocery and repeat purchases
Context-aware recommendationProfile plus context featuresUsuallyTime, location or device effects
Comparison with neighboring recommendation tasks

Evaluating and deploying session-based recommenders

Offline evaluation follows a time-based split, training on older sessions and testing on the most recent days, because random splits leak future information. Typical metrics are HitRate@20 and MRR@20, which measure whether the true next item appears in the top 20 and how high it ranks.

In production, a session model usually serves as a candidate generation or ranking stage inside a multi-stage pipeline. Latency budgets of tens of milliseconds mean the session encoder must update after every event, often in a streaming system that keeps the session state in memory.

SituationRecommended choiceReason
Small catalog, limited teamSession k-nearest neighborsStrong accuracy with little tuning
Large catalog, rich logsAttention or GRU-based modelLearns long patterns within sessions
Many returning usersSession-aware hybridAdds long-term preferences
Strict latency limitPrecomputed item-to-item rulesConstant-time lookups
Choosing an approach

Limitations and common pitfalls

Session-based recommenders work only with very short evidence, so the first one or two clicks dominate predictions and can be noisy or accidental. They also tend to amplify popularity bias, because popular items appear in more training transitions and therefore score higher.

  • Repeated items in a session can inflate offline metrics if the model simply recommends what was just viewed.
  • Weak baselines in comparisons exaggerate the gains of new neural architectures.
  • Item cold start remains: brand-new products have no transitions until enough sessions include them.
  • Offline metrics predict online click-through only partly, so A/B testing remains necessary.

Teams also face a feedback loop risk: the model learns from sessions shaped by its own earlier recommendations. Adding some exploration and monitoring catalog coverage and diversity helps keep the system from narrowing over time.

The short version

Session-based recommendation suggests what you might want next based only on what you are doing right now. It does not need to know who you are or what you bought last year. It looks at the few products or articles you just opened and compares them with what many other visitors did after similar steps.

Think of a helpful shop assistant who notices you trying on hiking boots and offers wool socks. They read your current intent from the last few minutes, not from a customer file.

Where it makes a difference

An online sporting goods retailer finds that about 70 percent of its visitors browse without logging in, so its profile-based recommendations show only generic bestsellers to most of them. The team adds a session-based model trained on six months of anonymous click logs.

After a visitor views two trail running shoes and a hydration vest, the model ranks trail socks, gaiters and a running belt at the top of the product page widget. In a four-week A/B test, the widget shows a clear increase in click-through rate and a modest rise in items per order for anonymous visitors.

The team keeps a simple item-to-item fallback for the very first page view and adds a diversity rule so that the widget does not show five nearly identical shoes, which improves catalog coverage without hurting clicks.