# Session-based Recommendation with Graph Neural Networks

Session-based recommendation with graph neural networks predicts next clicks from anonymous sessions

Shu Wu, Yuyuan Tang, Yanqiao Zhu, Liang Wang, Xing Xie, Tieniu Tan · arXiv · 2018-11-1

- **Problem** Session-based recommenders have no stable user profile to lean on, and sequence models lose links between clicks that are several steps apart. Earlier methods also treat user vectors as essential, which sparse sessions cannot supply.
- **Method** SR-GNN turns each session into a graph and learns item vectors with a gated GNN.
- **Results** On Yoochoose 1/64, SR-GNN reached 70.57 P@20 and 30.94 MRR@20, above NARM at 68.32 and 28.63.

## Why session recommendation needs a different signal

Many services never link clicks to a stable user profile, so the only evidence for a recommendation is the clicks made during the current session. Conventional recommenders depend on dense user-item histories, which such sessions rarely provide. Recurrent models often treat their hidden state as a user representation, and a session with few clicks gives that state little to work with.

Markov-chain models combine past components independently, and that independence assumption limits how much of a session they can use. Sequence models that link consecutive items capture single-step transitions, while links between items several steps apart inside one session are often lost. The method addresses both gaps by changing what is modeled: the session becomes a graph, and item vectors are learned from that graph.

## Turning a session into a directed graph

Each session sequence becomes a directed graph in which every distinct item is one node. Each pair of consecutive clicks gives one directed edge, so the session's click order is kept in the edges. Items can recur within a session, so each edge weight is its occurrence count divided by the outdegree of the edge's start node.

The connection matrix A\_s is the concatenation of a weighted outgoing adjacency matrix and a weighted incoming adjacency matrix. With n nodes it has size n by 2n, so each node receives information from the nodes it points to and from the nodes that point to it. Other ways of building the session graph change only this matrix, and content features such as descriptions can be concatenated to node vectors.

## Learning node vectors with a gated GNN

Each update first builds a message for node i from the node vectors of the whole session graph, through the connection matrix and a learned weight H in R^{d x 2d} plus a bias: \\( a\_{s,i}^{t} = A\_{s,i:} \[v\_1^{t-1}, \\ldots, v\_n^{t-1}\]^\\top H + b \\). Update and reset gates are computed from this message and the node's previous vector, using the sigmoid function.

The reset gate controls how much of the previous vector enters the candidate state, and the new vector blends the previous vector with that candidate under the update gate.

All nodes of one session graph are updated together, and the steps repeat until the node vectors converge. Gates decide which information is kept and which is dropped at each step. The gated GNN builds on the earlier GNN formulation and uses gated recurrent units with back-propagation through time to compute gradients.

## From node vectors to one session embedding

The local embedding is the vector of the last-clicked item, which captures the current interest of the session. The global embedding is an attention-weighted sum of all node vectors, with each weight computed from the last-clicked node vector and the node's own vector: \\( \\alpha\_i = q^\\top \\sigma(W\_1 v\_n + W\_2 v\_i + c), \\quad s\_g = \\sum\_{i=1}^{n} \\alpha\_i v\_i \\).

Here q is in R^d and W\_1, W\_2 are in R^{d x d}, and the weights come from a sigmoid rather than a softmax.

The authors combine the two parts because the information in each may have different levels of priority, so a single pooled vector would weight them the same way. Local-only and global-only versions are tested later as variants of this embedding.

## Scoring all items and training the model

Each candidate item's score is the inner product of the hybrid embedding and that item's node vector: \\( \\hat{z}\_i = s\_h^\\top v\_i \\). A softmax over all items, \\( \\hat{y} = \\mathrm{softmax}(\\hat{z}) \\), turns the scores into next-click probabilities, and the items with the top K values become the candidates.

Training uses a cross-entropy between \\( \\hat{y} \\) and the one-hot vector of the true next item. Back-propagation through time is used to fit the model, and a small number of training steps is chosen because most sessions are short, which guards against overfitting.

## Data construction and evaluation setup

Yoochoose comes from the RecSys Challenge 2015 and Diginetica from CIKM Cup 2016, where only the transactional data is used. Sessions of length 1 and items appearing fewer than 5 times were removed, which leaves 7,981,580 sessions and 37,483 items for Yoochoose and 204,771 sessions and 43097 items for Diginetica. Each session is split into prefix-label pairs, so every prefix is an input sequence and the next click is its label.

The test sessions are the subsequent days for Yoochoose and the subsequent weeks for Diginetica. Yoochoose is also evaluated on its most recent 1/64 and 1/4 fractions of the training sequences. P@20 is the proportion of correct items among the top 20, and MRR@20 averages reciprocal ranks with the value set to zero when the rank exceeds 20.

The latent dimensionality d is 100 on both datasets, and other hyper-parameters were selected on a random 10% subset of the training set.

## Comparison with the baseline methods

On Yoochoose 1/64, SR-GNN reached 70.57 P@20 and 30.94 MRR@20. On the same split NARM scored 68.32 and 28.63, and STAMP scored 68.74 and 29.67. On Yoochoose 1/4, SR-GNN reached 71.36 P@20 and 31.89 MRR@20.

On Diginetica, SR-GNN reached 50.73 P@20 and 17.59 MRR@20, against 49.70 and 16.17 for NARM and 45.64 and 14.32 for STAMP. Across the three evaluated datasets, SR-GNN has the highest P@20 and MRR@20 among the baselines in the comparison table. FPMC has no value on Yoochoose 1/4 because it could not be initialized within the available memory.

Neural models outperform the conventional baselines, and Item-KNN, which uses no sequential information, scores above FPMC, a Markov-chain model; the authors read this as evidence that the independence of successive items is unrealistic. The authors attribute the gain over NARM and GRU4REC to SR-GNN modeling transitions between items within a session as a graph, instead of modeling each user's sequence separately.

## Global and high-order connection variants

SR-GNN-NGC replaces the connection matrix with edge weights taken from a global graph built over all sessions. SR-GNN-FC adds boolean connections for all higher-order item relationships within a session.

SR-GNN-NGC falls below SR-GNN, and the authors attribute this to global edge weights reducing the influence of edges attached to high-degree nodes within the current session. SR-GNN-FC is slightly below SR-GNN, and the authors describe the difference as small. The authors take this to mean that intermediate steps between high-order items still matter, using browsing pages A, B and C as an example.

## Session embedding variants

The hybrid SR-GNN is compared with local embedding only (SR-GNN-L), with average pooling of node vectors (SR-GNN-AVG) and with attention-based global embedding (SR-GNN-ATT). The hybrid SR-GNN gives the best results on all three datasets. SR-GNN-ATT scores above SR-GNN-AVG on all three datasets, which the authors take to mean that a session contains noisy behaviour that should not be treated independently.

SR-GNN-L still outperforms SR-GNN-AVG and nearly matches SR-GNN-ATT. The authors read this as support for both the current interest and the long-term preference being needed for session-based recommendation.

## Behaviour across session lengths

Sessions are split at length 5, where short means length of at most 5 and long means more than 5. The pivot 5 is the integer closest to the average session length across the datasets, and short sessions make up 0.701 of Yoochoose and 0.764 of Diginetica.

The SR-GNN variants stay stable across the short and long groups, whereas STAMP's performance changes greatly between them. The authors explain STAMP's pattern by replicated actions, which its attention can ignore when building user representations. On Yoochoose, NARM does well on short sessions but drops quickly as sessions grow longer, which the authors partly attribute to RNN difficulty with long sequences.

The authors suggest that SR-GNN-L still does well because it implicitly uses the first-order and higher-order nodes of the session graph.

## Limitations

The evaluation uses two datasets, Yoochoose with its 1/64 and 1/4 fractions and Diginetica. FPMC has no Yoochoose 1/4 result, because of insufficient memory to initialize it.

## Paper info

- **Authors**: Shu Wu, Yuyuan Tang, Yanqiao Zhu, Liang Wang, Xing Xie, Tieniu Tan
- **Venue**: arXiv · Preprint
- **First published**: 2018-11-1
- **Added**: 2026-11-12
- **Updated**: 2019-1-24
- **Version**: v4
- **arXiv**: 1811.00855
- **DOI**: 10.1609/aaai.v33i01.3301346
- **Category**: cs.IR · cs.LG · stat.ML
- **Original paper terms**: [arXiv non-exclusive 1.0](https://arxiv.org/licenses/nonexclusive-distrib/1.0/)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/1811.00855v4) · [PDF ↗](https://arxiv.org/pdf/1811.00855v4)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

Shu Wu, Yuyuan Tang, Yanqiao Zhu, Liang Wang, Xing Xie, Tieniu Tan (2018). Session-based Recommendation with Graph Neural Networks. arXiv:1811.00855v4. https://doi.org/10.1609/aaai.v33i01.3301346

**BibTeX**

```
@article{wu2018session,
  title = {{Session-based Recommendation with Graph Neural Networks}},
  author = {Shu Wu and Yuyuan Tang and Yanqiao Zhu and Liang Wang and Xing Xie and Tieniu Tan},
  year = {2018},
  eprint = {1811.00855},
  archivePrefix = {arXiv},
  doi = {10.1609/aaai.v33i01.3301346},
  url = {https://arxiv.org/abs/1811.00855v4}
}
```

## Other paper commentary

- [RotatE: Knowledge Graph Embedding by Relational Rotation in Complex Space](https://refivu.com/en/papers/6cf7532c-a2b4-4553-a534-0482af8548e2-rotate-knowledge-graph-embedding-by-relational-rotation-in.md)
- [A Comprehensive Survey of Graph Embedding: Problems, Techniques and Applications](https://refivu.com/en/papers/ec23e11b-6984-4611-aa20-93a65865b536-a-comprehensive-survey-of-graph-embedding-problems.md)
- [Graph Neural Networks for Social Recommendation](https://refivu.com/en/papers/3f172e45-3e51-4657-9b43-76ed2fb286e9-graph-neural-networks-for-social-recommendation.md)
- [Graph Convolutional Networks for Text Classification](https://refivu.com/en/papers/3f1e8027-a608-4e71-87f0-2bdbf0fd5a7f-graph-convolutional-networks-for-text-classification.md)
- [Two-Stream Adaptive Graph Convolutional Networks for Skeleton-Based Action Recognition](https://refivu.com/en/papers/34b4bb2a-43de-4874-9031-6b02160d4003-two-stream-adaptive-graph-convolutional-networks-for.md)
- [Simplifying Graph Convolutional Networks](https://refivu.com/en/papers/e44b1726-1294-4944-949a-e3035e872bc5-simplifying-graph-convolutional-networks.md)
- [Inherent Trade-Offs in the Fair Determination of Risk Scores](https://refivu.com/en/papers/839c2aea-2b24-46f2-8b72-8c5fff96e639-inherent-trade-offs-in-the-fair-determination-of.md)
- [End-to-end Recovery of Human Shape and Pose](https://refivu.com/en/papers/da029864-5c93-4c98-a8b5-99aa97d36118-end-to-end-recovery-of-human-shape-and.md)
- [Transformers in Time Series: A Survey](https://refivu.com/en/papers/27ce8af6-dbd0-40be-9dc3-c7b1708ee930-transformers-in-time-series-a-survey.md)
- [InceptionTime: Finding AlexNet for Time Series Classification](https://refivu.com/en/papers/d38dc30f-c8c7-476b-b7e9-0b2838d7c2a1-inceptiontime-finding-alexnet-for-time-series-classification.md)
- [DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligence](https://refivu.com/en/papers/a9b5666a-9125-4553-968a-b6f76e0d19db-deepseek-coder-when-the-large-language-model-meets.md)
- [OpenAI GPT-5 System Card](https://refivu.com/en/papers/678bc558-0d7f-4ee8-9fa0-55c5eb2daf22-openai-gpt-5-system-card.md)

## Terms in this paper

- [Graph Neural Networks](https://refivu.com/en/terms/0650d076a410-graph-neural-networks)
- [GRU4Rec](https://refivu.com/en/terms/5fc0256a0e06-gru4rec)
- [Back-Propagation Through Time](https://refivu.com/en/terms/68cfaefd3a82-back-propagation-through-time)
- [session-based recommendation](https://refivu.com/en/terms/908d9d1db730-session-based-recommendation)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/62d7225d-cbaa-40dd-937a-e1fda19d331d-session-based-recommendation-with-graph-neural-networks)
