Abstract
Session-based recommendation is a challenging problem in real-world scenarios such as e-commerce and music platforms, aiming to predict the next click action based on anonymous session data. While Graph Neural Networks (GNNs) have become state-of-the-art for this task, they suffer from two primary limitations: item transition relations are not explicitly modeled, and long-range dependencies are difficult to capture due to over-smoothing in deep GNNs. To address these issues, we propose Transition Relation Aware Self-Attention (TRASA). TRASA converts sessions into graphs and encodes shortest paths between items using a Gated Recurrent Unit (GRU) to explicitly model transition relations. It then employs a self-attention mechanism to capture long-range dependencies, incorporating these transition relations into the attention scores. Extensive experiments on three real-world datasets demonstrate that TRASA consistently outperforms existing state-of-the-art methods.
Introduction
In the digital landscape of e-commerce and content platforms, session-based recommendation (SBR) is vital for engaging users whose long-term history is unknown. The goal is to predict the next item a user will interact with based solely on their current sequence of actions.
Traditional approaches have shifted towards Graph Neural Networks (GNNs) because they can model complex item transitions. However, GNNs often treat transitions implicitly through graph topology and struggle with long-range dependencies. For instance, a user might revisit a category viewed much earlier in a session; a shallow GNN might fail to connect these distant but related events due to the limited number of layers that can be applied before node representations become indistinguishable (over-smoothing).
The TRASA Framework
To overcome these limitations, the Transition Relation Aware Self-Attention (TRASA) model introduces a novel architecture that explicitly models structural relationships and leverages self-attention for global dependency capture.
1. Graph Construction
The process begins by transforming a session into a directed graph. Edges are categorized into four distinct types—NXT (next), PRE (previous), NPL (both), and SELF (self-loop)—to preserve the temporal and structural context of the session.
2. Relation Encoder
The core innovation of TRASA is the explicit modeling of item transitions. For any pair of items, the model identifies the shortest path between them in the session graph. This path, represented as a sequence of edge types, is processed by a bi-directional Gated Recurrent Unit (GRU) to generate a "transition relation" vector. This provides the model with a rich, structural map of how items are connected beyond simple adjacency.
3. Relation Aware Self-Attention
Unlike standard self-attention, TRASA's mechanism incorporates the transition relation vectors when calculating attention scores. This allows the model to weight the importance of an item not just by its content, but by its specific structural relationship to the target item. This approach effectively captures long-range dependencies without the over-smoothing issues common in deep GNNs, as it creates a direct connection between any two items in the session.
4. Session Representation and Prediction
The final stage aggregates item representations into a session-level vector. TRASA utilizes reversed position embeddings, which prioritize the most recent interactions—a critical factor in session-based contexts. A soft-attention mechanism then produces the final scores for candidate items.
Experimental Evaluation
TRASA was evaluated against three benchmark datasets: Diginetica (e-commerce), Gowalla (social check-ins), and Last.fm (music).
Key Results
The model consistently outperformed state-of-the-art baselines like GCE-GNN, LESSR, and GC-SAN.
- Diginetica: Achieved a P@20 of 55.15 and MRR@20 of 19.47.
- Last.fm: Showed significant gains in MRR@20 (9.35), highlighting TRASA's effectiveness in longer sessions where capturing distant dependencies is paramount.
Insights
- Explicit Modeling: Ablation studies confirmed that explicitly incorporating transition relations into the self-attention layer is the primary driver of performance gains. Without the self-attention layer, performance dropped by over 35% on some metrics.
- Recency Matters: The use of reversed position embeddings proved superior to standard forward embeddings, confirming that the user's most recent actions are the strongest indicators of their next move.
- Structural Context: Using shortest paths as a context provides a more nuanced understanding of item relationships than simple graph adjacency, effectively bypassing the "squashing" problem where information is lost as it travels through many intermediate nodes.
Conclusion and Future Work
TRASA offers a robust solution for session-based recommendation by bridging the gap between structural graph modeling and long-range sequence modeling. While highly effective, future work could explore integrating global transition patterns from across all user sessions to further enrich the local session representations. Additionally, optimizing the computational overhead of shortest-path calculations remains an area for potential improvement in large-scale deployments.
Summary updated