Experiencing session-based recommendation
Session‑based recommendation could be examined from three perspectives: SBR, global context learning, and GSLA (refer to Table of Materials). No human participants or animals were involved in this study. All experimental datasets used in this work are publicly available and submitted as Supplementary File: GSLA4Rec. zip.
Session-based recommendation
The session-based recommendation (SBR) was an artificial intelligence system that interacted with users through multi-turn natural language dialogues to dynamically understand users’ preferences and provide personalized recommendations. SBR evolved from traditional methods to deep learning-based and hybrid approaches, and then advanced towards Large Language Model (LLM)-based solutions.
Traditional session-based recommendation
Traditional SBR was typically represented by Markov Chain-based methods and Collaborative Filtering. The former generated recommendations by decomposing user-specific probabilistic transition matrices. For instance, Guy Shani24 proposed a Markov Decision Process-based recommendation method that produced recommendations by decomposing corresponding matrices; Wanrong Gu25 enhanced recommendation performance by integrating Markov Chains with purchase time intervals. The latter generated recommendations by extracting hidden sequential relationships between adjacent interactive items through matrix factorization. For example, Sarwar B1 calculated item-to-item similarity based on users’ historical behaviors (such as score and clicks) to recommend items that match users’ past preferences. If user A liked item a, and item c was highly similar to a, the system recommends c to A; Rendle S5 proposed FPMC, a sequence recommendation model combining matrix factorization with Markov Chains, to capture hidden sequential relationships between adjacent interactive items. However, such traditional SBR focused on sequential relationships between adjacent items, making it difficult to model complex dependency relationships.
Deep-learning session-based recommendation
Deep-Learning session-based recommendation had evolved through stages involving Convolutional Neural Networks (CNNs)26,27,28,29, RNNs, and GNNs. CNN-based SBR utilized operations such as convolution and pooling to learn representations of each session context, which then used for subsequent recommendations. Caser30 converted the L most recent items that a user had interacted with into d-dimensional vectors via an embedding layer, forming an embedding matrix treated as an "image" mapped in time and latent space. It then used three sequence pattern convolutional filters—point-level, union-level with no skip, and union-level with skip once—to learn sequential patterns for better SBR performance. Tuan et al.31 uniformly modelled session click streams and content features via 3D convolution kernels to form spatio-temporal-content joint representations.
RNNs were a class of neural network architectures specifically designed to process sequential data. The core idea was to capture temporal dependencies through recurrent structures such as long short-term memory networks (LSTM)13 and gated recurrent units (GRUs)32, and they were widely used in fields such as natural language processing (NLP)33, speech recognition34, text translation35, travel36,37, crime38, and future trend prediction39 (e.g., traffic40, stock markets41,42, and meteorology43). GRU4Rec, proposed by Hidasi et al., was a milestone in SBR research, and it first introduced RNNs into SBR and captured users' sequential behavioral patterns via GRU for achieving personalized recommendations.
GNNs44 demonstrated strong expressive power in modeling complex relationships within graph-structured data, and some researchers introduced GNNs to model complex transitions within or between sessions. Depending on different GNNs model architectures, GNNs-based methods for SBR were generally categorized into gated graph neural networks (GGNNs)45, graph convolutional networks (GCNs)46, and graph attention networks (GATs)47. SR-GNN was the first to apply GNNs to SBR by representing session sequences as directed graphs and utilizing GGNNs to capture complex item transition relationships within sessions, combined with attention mechanisms to obtain the final session embedding, thereby improving recommendation performance. Chen L48 proposed a multi view GNNs framework that combines structured attributes and unstructured keywords to model multi-dimensional product associations, improving the accuracy of SBR. Driss E49 designed an innovative session recommendation system adopting capsule graph neural networks to capture complex item features and enhance prediction accuracy for SBR.
The aforementioned deep-learning techniques had enriched the research scope of SBR and effectively improved performance, yet they still had certain limitations, mainly manifested in: 1) For newly emerging items or very sparse sessions, it was difficult for the models to make accurate predictions due to the lack of global context; 2) They couldn't leverage the global patterns contained in all historical sessions.
Hybrid session-based recommendation
Hybrid session-based recommendation integrated the strengths of different techniques, such as collaborative filtering, Deep-Learning, and attention mechanisms, to improve SBR performance. GC-SAN50 incorporated a self-attention mechanism based on SR-GNN to better capture interaction information of important items within a session. FGNN51 further aggregated information from neighboring items through a multi-head attention mechanism to learn multiple relationships of the target item. SR-HetGNN52 belonged to SBR with heterogeneous graphs; by introducing multi-type items (user, item, session) and multi-relational edges (click, purchase, co-occurrence, attribute association), it constructed a global knowledge network, breaking through the limitation of single item sequences, and was an important method for modeling anonymous users’ behavior and cross-session interest associations in recent years. KGSR-SAP53 constructed a knowledge graph by connecting items with edges of multiple relationships to describe various user-item interactions, solving the information loss problem where the global graph only contains edges of one type (user-item interaction). Wang ZH54 proposed DiffSBR, a diffusion-based session recommendation model. It generates reliable next-item preferences by simulating noise denoising, improving modeling of dynamic user click sequences. Qiao ST55 builded a SBR framework combining multi-view intent learning and LLM alignment. It mined user implicit intent from diverse perspectives and leveraged language models to align semantic features for better improving recommendation performance.
Global context
To overcome the shortcoming of "viewing sessions in isolation", researchers realized that global information could be used to enhance the representation capability of the current session, so as to solve problems such as data sparsity, cold start, and semantic gap in traditional SBR. Meanwhile, when constructing global context, integrating global information into a single session while minimizing noise interference was required. CSRM56 optimized session-level representation by integrating collaborative information between the current session and neighboring sessions, using an outer memory encoder (OME) to extract collaborative intent from the collaborative information. CA-TCN57 proposed a cross-session aware temporal convolutional network model, constructing global graphs and session context graphs to simulate the impact of cross-session on items and sessions, while the temporal convolutional network (TCN) expands the receptive field through dilated convolutions, with the number of layers covering sequences of exponential length (receptive field = ), solving the gradient vanishing problem of RNNs. Chen58 proposed a SBR method based on hypergraph neural networks (SR-HGNNs), which integrates mixed-order (low-order and high-order) propagation and attention mechanisms to solve the over-smoothing problem of traditional GNNs in short sessions and distinguish the importance of different propagation orders, and could more accurately capture dependencies and avoid noise interference. GCE-GNN used multi-order co-occurring item pairs to construct an undirected weighted graph, counting item co-occurrence frequencies to reflect the importance of items in the session; AGNN-GC59 used cross-session item transition relationships to construct a global collaborative graph, calculating item transition probabilities in the global graph to reflect interest changes in the session; DA-GCN60 used the shortest path to update the adjacency matrix to construct a dynamic weighted graph, calculating global graph co-occurrence frequency and path distance between items. Inspired by the above literature, this paper proposed constructing a global graph through a neighbor-based method, i.e., using the Jaccard similarity coefficient to calculate similar sessions, which not only utilized global information but also filtered noise (filtering out irrelevant items), achieving the purpose of accurately constructing global context and laying a solid foundation for the subsequent SBR algorithm.
Gated-slot linear attention
Traditional transformers61 incured high spatiotemporal complexity due to the need for fully connected attention operations across the entire sequence as follows:
(1)
Where Q, K, V ∈ RN×d were linear transformations of the input items, M = {Mij = 1 if i ≥ j, o.w. −∞ } was the causal mask to prevent future information leakage, ⊙ denoted element-wise production, and f denoted the activation function softmax.
To achieve linear attention62, the most direct idea was to remove the activation function softmax. However, if the activation function softmax was directly removed, linear attention would definitely lead to some potential problems: Losing the powerful expressive power of neural networks and being unable to solve complex real-world problems.
Slot linear attention with bounded-memory control
Assuming the activation function softmax needed to be retained, K and V were compressed separately into K̃, Ṽ ∈ Rm×d. From the perspective of memory network, K̃ and Ṽ had memory slots whose length increases with the sequence, that is, the number of slots m = N. If m was fixed, linearization was obviously possible. Inspired by Bounded-memory Control63, each token in the input items with a length of N was required to be competitively written into m slots.
,
,
(2)
Where f was the activation function softmax and φi was vector to control effective input for controlling key value ki as follows.
,
(3)
Here, (φi)j represented the writing intensity of the ith token to the jth slot, was obtained using a cumulative softmax function.
To achieve efficient linear computation, formula (2) was rewritten as formula (4), which computed οi from qi, ki, and vi (Eq. 4) by {οi|i=1T, qi, ki, vi)|i=1T} and adopted two-pass sequential computation:
,
(4)
Hence SLA operations could be derived:
,
(5)
Where oi′ ∈ ℝm, οi ∈ ℝd. Therefore, SLA could acquire hardware-efficient linear-time chunk-wise training64.
Gated-slot linear attention
Slot linear attention with bounded-memory control could reduce computational and spatial complexity. However, the accumulation of information could also bring noise information into session interaction, so data-dependent decay was very important for selectively retaining and forgetting information, and this selective mechanism had been revisited in recent selective state-space models65. GSLA with data-dependent could be expressed as:
,
(6)
Here decay gates were parameterized by an outer product form Gi = αi ⊗ βi, αi, βi ∈ [0,1]d. In what follows, GSLA could also be written in the following equivalent form by typically setting βt = 1 and matrix multiplication as in64:
(7)
Where αi and ki separately denoted forget gate and input gate, the two gates could be coupled as ki = 1 − αi, inspired by the literature on gated RNNs. It was evident that GSLA could be formulated with two‑pass sequential computation as shown in Equation (8). The second-order structure supported block parallel training to improve training efficiency, and the insertion of softmax operation in the middle of the second-order structure enhanced the modeling ability of finite slot memory.
,
(8)
Transforming session data
Problem definition
Let the given session sequence be S = {v1s, v2s, ⋯, vns}, where vis denoted the ith clicked item. By analyzing the user's click behavior within this sequence, the system predicted the next item the user may be interested vn+1s.
Graph construction
Session graph construction
For a session S = {v1s, v2s, ⋯, vns}, a directed graph Gs = (Vs, εs) was constructed, where Vs was the item set of the given session S, and εs = {eijlocal|vi, vj, vi, vj ∈ Vs} was the edge set of the given session S. ε(vi-1s, vis) represented the consecutive clicked items in this session. The edge eijlocal could be divided into four types: ein, eout, ein-out, eself. Since the same item might appear repeatedly in the sequence, the weighted value for each edge was counted.
The current session s = [v1, v2, v4, v2, v3] was converted into an SG, as shown in Figure 1A.

Figure 1: Transform interactive items into graph structures. (A) Illustration of session graph (SG) construction by transforming a session into a graph. (B) Illustration of neighbor global graph (NGG) construction by combining many sessions into a graph. This figure was self-drawn via Visio with fully customized elements. No copyrighted external graphic resources were used, hence no additional third-party copyright licensing was needed. Figure copyright was owned by the authors and would comply with the journal's copyright rules upon acceptance. Please click here to view a larger version of this figure.
Neighbor global graph construction
Based on the current session S, the corresponding NGG Gg = (Vg, εg) was constructed to enrich the representation learning of the current session in a cross-session manner. Vg was the item set containing all items in Gg, and εg = {eijglobal|vi, vj, vi, vj ∈ Vg} was the edge set of Gg. ε(vi-1g, vig) represented the directly interacting items vi-1g and vig in the NGG Gg. This process consisted of two steps: neighbor session acquisition and NGG construction.
Neighbor session acquisition
Across the entire dataset, sessions with the maximum number of co-occurring items with the current session were searched. The top-N sessions with the highest co-occurrence counts were selected to construct a candidate neighbor session set S. Subsequently, the Jaccard similarity coefficient was employed to calculate the similarity between the current session cu and a session Sr ∈ S from the candidate set S, as shown in Equation (9).
(9)
Here, co(Scu, Sr) denoted the number of items co-occurring in both Scu and Sr, while l(Scu) and l(Sr) respectively represented the lengths of Scu and Sr, and Scu and Sr denoted current session and a neighbor session. Sessions with similarity below a certain threshold (which could be set as a hyperparameter) were filtered out, and the remaining sessions constituted the neighbor session set Ns for the current session.
Neighbor global graph construction
Based on the neighbor session set Ns, the NGG was constructed, as illustrated in Figure 1B. During the adjacency matrix construction, if two items (vi, vj) had an interaction, the corresponding entry Aij was set to 1, otherwise, it was set to 0. Additionally, the interactions between items were processed as undirected and were equipped with self-loops, followed by normalization, as shown in Table 1.
| 1 | 2 | 3 | 4 | 5 | 6 |
| 1 | 1/2 | 1/2 | 0 | 0 | 0 | 0 |
| 2 | 0 | 1/4 | 1/4 | 1/2 | 0 | 0 |
| 3 | 0 | 0 | 1 | 0 | 0 | 0 |
| 4 | 0 | 1/4 | 1/2 | 1/4 | 0 | 0 |
| 5 | 0 | 0 | 0 | 0 | 1/3 | 2/3 |
| 6 | 0 | 1/3 | 0 | 1/3 | 0 | 1/3 |
Table 1: Normalized adjacency matrix of the neighbor global graph. The table presents the normalized adjacency matrix describing the weighted connections among nodes in the constructed neighbor global graph.
Designing session-based recommendation algorithm
This section elaborates on the proposed innovative model GSLA4Rec, which enhanced SBR performance by introducing the GSLA mechanism over the joint feature representation of SG and NGG.

Figure 2: GSLA4Rec framework. This framework integrated session graph and neighbor global graph structure learning, filtered interaction noise with a gating mechanism, balanced storage and efficiency with a memory slots mechanism, and captured item relevance with a linear attention mechanism to predict the user's next click preference. This figure was self-drawn via Visio with fully customized elements. No copyrighted external graphic resources were used, hence no additional third-party copyright licensing was needed. Figure copyright was owned by the authors and would comply with the journal's copyright rules upon acceptance. GSLA4Rec represented gated-slot linear attention graph neural networks for SBR. Please click here to view a larger version of this figure.
Figure 2 presented the framework of GSLA4Rec, which comprised four main components: 1) Session-level item representation. It employed a GNNs model on SG to learn session-level item embeddings within the current session; 2) Neighbor global-level item representation. It learned global-level item embeddings over all sessions by employing a GRU to recursively incorporate the neighbor embeddings of each item based on the NGG; 3) GSLA. It modelled the users’ preference of the current session by aggregating the learnt item representations at both session-level and global-level; 4) Prediction layer. It outputed the predicted probabilities over candidate items. The four components were presented in detail in the following.
Session representation
In SBR, understanding users’ interaction behaviors was crucial. To this end, a SG and a NGG were constructed for session representation learning, aiming to comprehensively understand users’ interaction behaviors and thereby capture the users’ more authentic intent.
Session-level item representation
Based on the SG in Figure 1A, a Weighted Bidirectional Graph Attention (WBGAT) method was employed to extract features of the SG. This method introduced edge weights and item directionality (In-neighbor and Out-neighbor) based on the standard GAT mechanism, achieved the effect of strengthening important edges and capturing bidirectional dependencies, thereby addressed the shortcomings of traditional GAT regarding asymmetric item relationships and interaction strength. The calculation process was as follows:
First, calculation of item in-degree normalization weights.
(10)
where eij indicated the first-order in-neighbor weight of item j’s features to item i,
was the relation between item i and item j, β* ∈ ℝd was weight vectors, hi and hj was respectively representation of item i and j, Wi(in) ∈ ℝd*d and Wj(in) ∈ ℝd*d were trainable parameters, || represented concatenation operation. To distinguish different in-degree relations, two weight vectors, namely rin and rin-self, were trained. LeakyReLU was adopted as the activation function.
(11)
To make coefficients comparable across different items, the attention weights were normalized via the softmax function. Where Ni(in) was the first-order in-neighbor set of item i,
was the in-neighbor weight of directed edge (i←j) in SG, this method enabled the model to learn item feature correlations while retaining the inherent connection strength information of the graph structure by taking the logarithm of the edge weights and adding them to the original attention score eij.
Second, calculation of item out-degree normalization weights.
(12)
where ẽij indicated the first-order out-neighbor weight of item j’s features to item i,
was the relation between item i and j, two weight vectors, namely rout and rout-self, were trained.
(13)
Where Ni(out) was the first-order out-neighbor set of item i,
was the out-neighbor weight of directed edge (i→j) in SG.
Third, information aggregation. The updated embedding of item could be obtained after weighting and summing the first-order in-degree and out-degree embeddings of item i.
(14)
Where
and α̃ij respectively denoted in-degree and out-degree weights of item i,
denoted the updated representation of item i.
Neighbor global-level item representation
Recent research consistently agreed that constructing a global graph could enhance data representation and thereby improve SBR performance, this was beyond doubt. However, globally enhancing data might also introduce irrelevant information such as noise. In the proposed model, to achieve global data augmentation while minimizing noise to the greatest extent possible, a near-neighbor global graph was constructed.
Based on the NGG in Figure 1B and the normalized adjacency matrix in Table 1, the current session and its neighbor sessions were transformed into an NGG, and a GGNNs45 method was applied to extract features of the NGG. The learning process of item vectors in the NGG was shown in Equation (15).




(15)
W ∈ ℝd×2d denoted control weights, zg,i and rg,i represented the update gate and reset gate, respectively. [h1t-1, ⋯, hnt-1] represented the list of all item vectors in session s. σ(x) = 1/(1 + e-x) was the logistic sigmoid function, ⊙ denoted element-wise multiplication, and hi ∈ ℝd represented the vector after gated updating. The adjacency matrix As ∈ ℝn×n indicated the connectivity between items in neighboring sessions, and As,i: ∈ ℝ1×n represented a column block As corresponding to item vs,i in the adjacency matrix. For the current session s = [v1, v2, v4, v2, v3], the NGG and the normalized adjacency matrix were shown in Figure 1B and Table 1, respectively.
Item representation
The item representation was obtained by summing the session-level item vector and the neighbor global-level item vector, as shown in Equation (16):

(16)
Where dropout was utilized on global-level neighbor item representations to alleviate overfitting.
Gated-slot linear attention
The gated-slot linear attention (GSLA) in this paper integrated linear attention with bounded-memory control and a data-dependent gating mechanism. On one hand, it inherited the finite memory slot mechanism of the attention-based controller (ABC) model, compressed key-value pairs that originally grew with sequence length into a fixed number of slots, and each slot was updated via competitive writing, addressing the computational complexity issue of transformer global attention. On the other hand, it introduced a fine-grained gating mechanism similar to GLA, where input data dynamically adjusted the retention ratio of historical information through a forget gate αi, resolving the noise problem caused by the lack of a forgetting mechanism in ABC.

Figure 3: Schematic diagram of GSLA. The input vector was mapped to the query vector, keyword vector, and value vector, respectively, and then processed by linear attention with bounded-memory control and a data-dependent gating mechanism to obtain the updated query vector, keyword vector, value vector, and output vector. This figure was self-drawn via Visio with fully customized elements. No copyrighted external graphic resources were used, hence no additional third-party copyright licensing was needed. Figure copyright was owned by the authors and would comply with the journal's copyright rules upon acceptance. GSLA represented gated-slot linear attention. Please click here to view a larger version of this figure.
As specifically implemented in Figure 3, the input vector was separately mapped into the query vector, key vector, and value vector64:
(17)
Where Wq, Wk, Wv ∈ ℝd×d represented the transformation weight matrices respectively corresponding to the query, key, and value, and ht denoted the embedding vector at the tth time step in the session input sequence. The Swish function was defined as Swish(x) = x · σ(x) and was a self-gated activation function, where σ was the Sigmoid function, it outperformed the traditional ReLU activation function in multiple Deep-Learning tasks.
GSLA utilized a forget gate αi and an input gate 1 − αi, depending on input data, to dynamically update the information in the ith memory slot. The process was as follows64:
(18)
(19)
Here, K̃t and Ṽt represented the key vector slots and value vector slots at time step t, while K̃t-1 and Ṽt-1 represented the key vector slots and value vector slots at time step t−1. The forget gate αi = σ(Wαht)1/τ, where Wα ∈ ℝd was the transformation weight matrix, σ was the Sigmoid function, and τ was the damping coefficient (typically set to 8), used to control the softness of the forget gate. This allowed GSLA to smoothly adjust the forgetting rate of historical information: the larger the αi, the more GSLA relied on historical information, the smaller the αi, the more GSLA focused on the current input.
The key vector slots K̃t and value vector slots Ṽt of the slots at the tth step were written in matrix form, as shown65 in Equations (20) and (21):
(20)
(21)
Then, the GSLA with second-order properties (refer to Equation (8)) was utilized to calculate the output oi |i=1T for each time step i ∈ [1, …, T]. A linear transformation was applied to the output of each time step to obtain the result h̃t. Finally, the average value of the representations of all items in the session sequence was computed to generate the session embedding S̃e with dynamic memory updates:
(22)
(23)
Here, ot represented the output of Gated-Slot at time step t, h̃t denoted the result of implementing linear transformation on ot. S̃e denoted the average value of h̃t at all time steps.
Prediction layer
Based on the obtained session representation S̃e and the initial embedding of item i, a dot product operation was performed to calculate the score for each candidate item hi. Subsequently, the softmax function was used to obtain the recommendation probabilities of candidate item i:
(24)
Here, ỹ represented the recommendation probabilities of the candidate item, hi denoted vector of candidate item, and the cross-entropy loss function was employed for model training.
(25)
Here, y was the one-hot encoded representation of the ground truth.