SimCGNN: Simple Contrastive Graph Neural Network for Session-based
  Recommendation
Session-based recommendation (SBR) problem, which focuses on next-item
prediction for anonymous users, has received increasingly more attention from
researchers. Existing graph-based SBR methods all lack the ability to
differentiate between sessions with the same last item, and suffer from severe
popularity bias. Inspired by nowadays emerging contrastive learning methods,
this paper presents a Simple Contrastive Graph Neural Network for Session-based
Recommendation (SimCGNN). In SimCGNN, we first obtain normalized session
embeddings on constructed session graphs. We next construct positive and
negative samples of the sessions by two forward propagation and a novel
negative sample selection strategy, and then calculate the constructive loss.
Finally, session embeddings are used to give prediction. Extensive experiments
conducted on two real-word datasets show our SimCGNN achieves a significant
improvement over state-of-the-art methods.
Yuan Cao, Xudong Zhang, Fan Zhang, Feifei Kou, Josiah Poon, Xiongnan Jin, Yongheng Wang, Jinpeng Chen
# SimCGNN: Simple Contrastive Graph Neural Network for Session-based Recommendation

###### Abstract

Session-based recommendation (SBR) problem, which focuses on next-item prediction for anonymous users, has received increasingly more attention from researchers. Existing graph-based SBR methods all lack the ability to differentiate between sessions with the same last item, and suffer from severe popularity bias. Inspired by nowadays emerging contrastive learning methods, this paper presents a Simple Contrastive Graph Neural Network for Session-based Recommendation (SimCGNN). In _SimCGNN_, we first obtain normalized session embeddings on constructed session graphs. We next construct positive and negative samples of the sessions by two forward propagation and a novel negative sample selection strategy, and then calculate the constructive loss. Finally, session embeddings are used to give prediction. Extensive experiments conducted on two real-word datasets show our _SimCGNN_ achieves a significant improvement over state-of-the-art methods.

## 1 Introduction

With the progressive development of the contemporary internet and the explosion of information on the Internet, recommender systems have become an essential component. Sequential recommender systems consider the dynamic preference development and take both user-level information and item-level information into consideration. In certain scenarios, however, the user can be anonymous, which means that we only have access to item-level features and user-level features are not visible. Session-based recommender, which observes only the current session rather than sufficient historical user-item interaction records, has drawn attention in recent years.

To capture the sequential relationship, Markov Chain (MC)-based sequential recommenders[1][1] are the first to be proposed. However, due to limited representation ability and the strong reliance upon the last interacted item in each session, their performances are limited. Recurrent neural networks (RNNs) are then introduced into session-based recommendation thanks to their natural ability for modeling sequential information. With the introduction of GRU4Rec[1], RNN turned out to be the structure of choice for solving the session recommendation problem, for example, NARM[1] designs two RNNs to capture user's global and local sequential preference correspondingly. It was not until the existence of SR-GNN[21], which utilized a gated graph neural network (GGNN) to extract sequential information on a session graph. Since then, works following the basic schema of SR-GNN have been proposed. TAGNN[21] added a target-attentive mechanism onto SR-GNN and gain promising performance. Also, as SR-GNN focuses only on a local session, methods like FGNN[22]

Figure 1: We trained SR-GNN on the diginetate dataset and selected a set of sessions (127 in total) with the same last-interacted item (_item 33889_, the most commonly occurred last-item) from the diginetica dataset for prediction. This line graph counts the number of occurrences of different items on the ground truth and model predicted values.
and GCE-GNN[20] both utilize global information in session-based recommendation but in different ways.

Although all methods mentioned above have favorable results, they maintain a drawback inherited from the MC-based approach to the present day. That is the strong dependency upon the last interacted item. Take the classical SR-GNN as an example, when assembling the final session, it simply takes linear transformation over the concatenation of the embedding vector of the last-item and the global embedding vector. And as a result, these methods may have trouble in distinguishing between sessions that have the same last interacted item. As shown in Fig.1, we first trained an SR-GNN on the Diginetica dataset and then visualized the distribution of predicted labels and ground-truth labels of sessions that shares the same last-interacted item. This indicates a phenomenon that methods with this assembling techniques tends to predict the same items for sessions with the same last-item, despite of the underlying diversity. As we have mentioned earlier, a large branch of existing graph-based methods ([23, 20] for example) refers to the same approach as SR-GNN in the final assembly of the session embedding, resulting in this phenomenon will also be widespread in the current advanced graph-based SBR method. In this paper, we refer to this phenomenon as the "same last-item confusion" problem. Apart from this, Fig.1 also proved the hypothesis proposed by [1] that the prediction of SR-GNN is likely to be affected by popularity bias.

To cope with the last-item, intuitively we tend to increase the discrepancy between sessions with the same last-item, which naturally fits the schema of constructive learning methods by considering sessions with the same last-item as negative samples. However, as positive samples are hard to define, we simply follows the idea of [1] by treating the session itself as a positive sample through dropout[21] techniques. To this end, we proposed a novel session-based recommender namely Simple Contrastive Graph Neural Network for Session-based Recommendation (_SimCGNN_). Firstly, in order deal with the "same last-item confusion" problem, we designed a novel contrastive module to increase the discrepancy between sessions with the same last interacted item. Secondly, to eliminate the advantage of popular items in the final prediction and to predict the underlying interest of the users themselves as much as possible, we normalised both the embedding of items and sessions.

Our main contributions in this paper are listed as follows.

1) We introduce a contrast learning approach to solve the last-item interaction confusion problem and propose a novel negative sample selection strategy.

2) To alleviate the popularity bias, we proposed normalized item embeddings and session embeddings.

3) Extensive experiments conducted on real-world datasets show that SimCGNN outperforms the sota methods and additional experiments also demonstrate the effectiveness of our approach for both of these two problems.

## 2 Related Work

### Traditional Methods

A series of approaches [19, 2, 18] based on matrix factorization (MF) are representatives of the traditional methods. MF-based methods consider that the user-item interaction matrix is too sparse and then decompose the matrix into two low-rank dense matrices, which correspond to users and items respectively. However, MF-based approaches do not model users' sequential interaction behavior, and therefore not suitable for making sequential recommendations.

Given that static matrix decomposition methods do not model sequence behavior, FPMC[1] models user behavior as a Markov Chain and combines Markov Chains with MF. FOSSIL[17] improves on FPMC by introducing factorized sequential prediction with an item similarity model and higher-order Markov Chains, thus both long-term and short-term user behaviour are taken into account. However, due to expressive capability limitation of their shallow network, they do not perform well in nowadays more complex recommendation scenarios.

### Deep Learning-Based Methods

In recent years, as deep-learning methods emerge, deep learning-based recommendation methods[19, 20] utilizing recurrent neural networks (RNNs) are on the rise. GRU4Rec[1] is a typical pioneer in utilizing RNN structure for making sequential recommendations. After that, more attempts have been made to perform sequential recommendations on RNNs. Tan et al.[18] improved the performance of RNN recommendation models by proposing several data enhancements and training tricks. Li et al.[19] proposed a neural attentive recommendation machine with an encoder-decoder structure based on RNN to capture the user's sequential preference. STAMP[14], which deposits the RNN structure by using simple MLPs and attention mechanisms, proved to be efficient in capturing both users' static and dynamic interests. Although deep learning-based models have more powerful representation capabilities than traditional methods, these approaches caanot still model complex item relationships, for example, non-adjacent item transitions.

### Neural Network on Graphs

Recently, thanks to the rise of graph neural networks[21, 22, 23, 24], many approaches[25, 19, 18] use GNN-based network structures to solve SBR problems. SR-GNN[20] is one of the earliest and most representative ones, which models each session as a session graph, and applies a gated-GNN[17] to finally get a representative embedding of the session. After the great success of SR-GNN, many variants of SR-GNN have been proposed. For example, TAGNN[20] proposed a target-aware attention mechanism upon SR-GNN, which adaptively
activates different user interests concerning varied target items. FGNN[21] takes both sequence order and the latent order in the session graph into consideration. Disen-GNN[11] constructs a disentangled session graph to discover underlying session purpose. \(S^{2}\)-DHCN[14] leverages hypergraph techniques to represent each session and utilizes constructive learning techniques to perform self-supervised learning. Instead of utilizing local session graphs only, methods such as GCE-GNN[20] construct global graphs to obtain global information on the dataset. However, as mentioned in the previous section, all of these methods have serious "same last-item confusion" problem and thus suffer from performance degradation.

## 3 Methodology

### Problem Formulation

A session-based recommender is supposed to give recommendations to users based on the inputs of their anonymous historical interaction sequences, e.g. clicks or purchases. Given \(\mathcal{V}=\{v_{1},v_{2},...,v_{m}\}\) as the item set, an anonymous interaction session \(s\) is an item sequence \(s_{i}=[v_{1}^{i},v_{2}^{i},...,v_{|s_{i}|}^{i}],s_{i}\in\mathcal{S}\), where \(v_{j}^{i}\) is the \(j\)-th interacted item of the \(i\)-th session. Given session \(s_{i}\), our goal is to predict \(v_{|s_{i}|+1}^{i}\).

### Overview

The overall workflow of our proposed SimCGNN is illustrated in Fig.2.

### Session Feature Extraction Module

**Normalized Item Embedding**

Since the one-hot vectors of items are sparse and high-dimensional and do not carry pairwise distance information, we first embed each item \(v_{i}\in\mathcal{V}\) into a \(d\)-dimensional representation \(\mathbf{v}_{i}\in\mathbb{R}^{d}\).

As some existing methods directly utilize \(\mathbf{v}_{i}\) for downstream tasks, we argue that the direct use of embedded vectors would lead to popularity bias [1]. To this end, we intuitively add \(L_{2}\) normalization to the raw feature vector. Apart from this, we also add Dropout directly on embedding layer for the downstream contrastive module. The normalized vectors \(\hat{\mathbf{v}}_{i}\) are given as follows:

\[\hat{\mathbf{v}}_{i}=Dropout(Norm(\mathbf{v}_{i}),p) \tag{1}\]

where \(p\) is the dropout probability, \(Norm(\cdot)\) is the L2-normalization function.

**Session Graph Construction**

To explore rich transitions among items and generate accurate latent vectors of items, we model each session \(s\) as a directed graph \(\mathcal{G}_{s}=(\mathcal{V}_{s},\mathcal{E}_{s})\), where each node \(v_{s,i}\in\mathcal{V}_{s}\) represents an item and each edge \((v_{s,i-1},v_{s,i})\in\mathcal{E}_{s}\) represents a user interact \(v_{s,i}\) after the interaction of \(v_{s,i-1}\). To deal with items that occurs multiple times in sessions, we assign a normalized weight to each edge. The weight is calculated by the occurrence of the corresponding interaction (\((v_{s,i-1},v_{s,i})\)) divides the out-degree of the starting node (\(v_{s,i-1}\)). We use the previously obtained embedding vector \(\hat{\mathbf{v}}_{i}\) as the initial state of the nodes in the constructed session graph. After the construction, we obtain the outgoing adjacency matrix \(\mathbf{A}_{i}^{out}\in\mathbb{R}^{d\times d}\) and incoming adjacency matrix \(\mathbf{A}_{i}^{in}\in\mathbb{R}^{d\times d}\), where \(n=|V|\). By concatenating \(\mathbf{A}_{i}^{out}\) and \(\mathbf{A}_{i}^{in}\), we obtain the final connection matrix \(\mathbf{A}_{s}\in\mathbb{R}^{d\times 2d}\) of the session graph.

**Learning Graph-based Item Embeddings**

Once the corresponding session graph has been constructed, we will then need to use a graph neural network to extract the structured information from the graph. In _SimCGNN_, we leverage a gated graph neural network (GGNN) to learn node vectors in a session graph. Formally, for node \(v_{s,i}\) in graph \(\mathcal{G}_{s}\), the update function can be formulated as,

\[\mathbf{a}_{s,i}^{t} =\mathbf{A}_{s,i}\colon\left[\mathbf{v}_{1}^{t-1},\mathbf{v}_{2}^{t-1},...,\mathbf{v}_{|s_{i}|}^{t-1}\right]^{\top}\mathbf{H}+\mathbf{b}, \tag{2}\] \[\mathbf{z}_{s,i}^{t} =\sigma\left(\mathbf{W}_{z}\mathbf{a}_{s,i}^{t}+\mathbf{U}_{z}\mathbf{v}_ {i}^{t-1}\right),\] (3) \[\mathbf{r}_{s,i}^{t} =\sigma\left(\mathbf{W}_{r}\mathbf{a}_{s,i}^{t}+\mathbf{U}_{r}\mathbf{v} _{i}^{t-1}\right),\] (4) \[\overline{\mathbf{v}}_{i}^{t} =\tanh\left(\mathbf{W}_{o}\mathbf{a}_{s,i}^{t}+\mathbf{U}_{o}\left( \mathbf{r}_{s,i}^{t}\odot\mathbf{v}_{i}^{t-1}\right)\right),\] (5) \[\mathbf{v}_{i}^{t} =\left(1-\mathbf{z}_{s,i}^{t}\right)\odot\mathbf{v}_{i}^{t-1}+\mathbf{z}_{s, i}^{t}\odot\overline{\mathbf{v}}_{i}^{t}, \tag{6}\]

where \(t\) is the training step, \(\mathbf{A}_{s,i}\). is the \(i\)-th row of matrix \(\mathbf{A}_{s}\) corresponding to \(v_{s,i}\), \(\mathbf{H}\in\mathbb{R}^{d\times 2d}\) is trainable parameter, \(\mathbf{z}_{s,i}^{t}\) and \(\mathbf{r}_{s,i}^{t}\) are the reset and update gates respectively, \(\left[\mathbf{v}_{1}^{t-1},\mathbf{v}_{2}^{t-1},...,\mathbf{v}_{|s_{i}|}^{t-1}\right]\) is the list of item vectors in \(s\), \(\sigma(\cdot)\) is the sigmoid function and \(\odot\) is the Hadamard product operator.

In order to add the necessary noise to the resulting graph item representation vector, we also applied Dropout to the final output vector \(\mathbf{v}_{i}^{l}\) after \(l\)-layers GNN. Also, since there is no location information embedded in the graph neural network, we do the usual positional embedding on the generated item vectors. The final graph-based item embeddings \(\widetilde{\mathbf{v}}_{i}\) can be calculated as,

\[\widetilde{\mathbf{v}}_{i}=\mathbf{w}_{pos(v_{i})}+Dropout(\mathbf{v}_{i},p), \tag{7}\]

where \(\mathbf{w}_{t}\in\mathbb{R}^{d}\) is the trainable positional embedding, \(pos(v_{i})\) is the absolute position of the item in the session., \(p\) is the Dropout probability.

**Generating Session Embeddings**

In this section, we consider constructing the session representation vector by combining long-term preference and short-term preference.

First, intuitively, we can represent the session's short-term preference by its last-interacted item \(\mathbf{v}_{s,|s_{i}|}\). Thus, for session \(s_{i}=[v_{s,1},v_{s,2},...,v_{s,n}]\), the short-term session embedding \(\mathbf{s}_{i,s}\) of session \(s\) can be defined as \(\widetilde{\mathbf{v}}_{n}\).

As for the long-term preference, we consider the long-term session embedding of session graph \(\mathcal{G}_{s}\) by aggregating all node vectors. Meanwhile, as different interaction records may own different levels of priority, we utilize the attention mechanism to gain the long-term session preference \(\mathbf{s}_{i,l}\) as
follows,

\[\alpha_{i} =\mathrm{softmax}(\mathbf{q}^{\top}\sigma(\mathbf{W}_{1}\widetilde{\mathbf{ v}}_{n}+\mathbf{W}_{2}\widetilde{\mathbf{v}}_{i}+\mathbf{b})), \tag{8}\] \[\mathbf{s}_{i,l} =\sum_{i=1}^{n}\alpha_{i}\widetilde{\mathbf{v}}_{i}, \tag{9}\]

where \(\mathbf{q}\in\mathbb{R}^{d}\) and \(\mathbf{W}_{1},\mathbf{W}_{2}\in\mathbb{R}^{d\times d}\) are trainable weights.

Finally, we get the final hybrid embedding \(\mathbf{s}_{i,h}\) by simply linear transform over the concatenation of the short-term and the long-term session embeddings.

\[\mathbf{s}_{i,h}=\mathbf{W}_{3}[\mathbf{s}_{i,l};\mathbf{s}_{i,s}], \tag{10}\]

where \(\mathbf{W}_{3}\in\mathbb{R}^{2d\times d}\) is trainable parameter and \([\cdot;\cdot]\) represents concatenation operation.

### Prediction Module

After extracting session hybrid embeddings, we adopt an MF layer to predict the relevance between the given session \(s_{i}\) and each candidate item \(v_{n}\in V\) by multiplying the normalized session representation \(Norm(\mathbf{s}_{i,h})\) and normalized item embedding \(Norm(\mathbf{v}_{n})\) for the avoidance of popularity bias, which can be defined as,

\[\hat{h_{n}}=r*Norm(\mathbf{s}_{i,h})*Norm(\mathbf{v}_{n}), \tag{11}\]

As \(Norm(\mathbf{s}_{i,h})*Norm(\mathbf{v}_{n})\) is equal to the cosine similarity between \(\mathbf{s}_{i,h}\) and \(\mathbf{v}_{n}\), the predicted logits are restricted to \([-1,1]\), and the softmax score is likely to get saturated at high values for the training set. To this end, we add a scaling factor \(r>1\), which is useful in practice to allow for better convergence.

Then we apply a softmax function on the output logit to get the final scaled output probability vector \(\hat{\mathbf{y}}\),

\[\hat{\mathbf{y}}=\mathrm{softmax}(\hat{\mathbf{h}}), \tag{12}\]

where \(\hat{\mathbf{h}}\) denotes the recommendation scores of all candidate items \(v_{n}\in V\).

The prediction loss \(\mathcal{L}_{pred}\) is defined by calculating the cross-entropy of the prediction and ground truth,

\[\mathcal{L}_{pred}=-\sum_{i=1}^{|D|}\mathbf{y}_{i}\log(\hat{\mathbf{y}})+(1-\mathbf{y}_{i })\log(1-\hat{\mathbf{y}}), \tag{13}\]

where \(\mathbf{y}\) denotes the one-hot encoding vector for the ground truth item.

### Contrastive Module

As we mentioned before, simply using the hybrid session embedding \(\mathbf{s}_{i,h}\) for item prediction inevitably leads to the same last-item confusion problem.

To address this, the most intuitive idea is to separate session representations with the same last-item as much as possible. Naturally, we came up with the idea of using comparative learning to solve this problem. We refer to the schema of [1], and since we have added the Dropout

Figure 2: The overall network architecture of _SimCGNN_.
layer above, we can simply perform twice forward propagation for each session \(s_{i}\) to produce two hybrid embeddings. For the embedding vector obtained by the first forward propagation, we denote it by \(\mathbf{s}_{i,h}^{1}\) and the second by \(\mathbf{s}_{i,h}^{2}\), which constructs a "positive pair". We use all embeddings of sessions with the same last item as negative samples, which can be represented by \(\mathbf{s}_{j,h}^{-},j\in{1,2,...,N}\), \(N\) indicates the number of negative samples. In this way, the contrastive loss \(\mathcal{L}_{con}\) can be calculated as,

\[\mathcal{L}_{con}=-\sum_{i=1}^{|D|}\log\frac{e^{\sin(\mathbf{s}_{i,h}^{1},\mathbf{s}_ {i,h}^{2})/\tau}}{\sum_{j=1}^{N}\Big{(}e^{\sin(\mathbf{s}_{i,h}^{1},\mathbf{s}_{i,h}^{2 })/\tau}+e^{\sin(\mathbf{s}_{i,h}^{1},\mathbf{s}_{j,h}^{-})/\tau}\Big{)}}, \tag{14}\]

where \(\tau\) is the temperature hyperparameter, \(D\) is the training dataset, and we utilize cosine similarity for \(\sin(\cdot,\cdot)\) as follows,

\[\sin(\mathbf{s}_{1},\mathbf{s}_{2})=\frac{\mathbf{s}_{1}\mathbf{s}_{2}}{||\mathbf{s}_{1}||||\mathbf{s }_{2}||} \tag{15}\]

However, unlike [1], since there are not always adequate negative sessions with the same last-item in the same training batch, we cannot directly use sessions in the same training batch as negative samples. And if we forward the corresponding negative sessions each time we calculate the contrastive loss, it would result in a huge waste of computational resources. As a result, instead of exhaustively computing these representations, similar to [21], we maintain a memory bank \(M=\{(\mathbf{f}_{i}^{1},\mathbf{f}_{i}^{2})\}\). During each learning iteration, the two hybrid embeddings \(\mathbf{s}_{i,h}^{1},\mathbf{s}_{i,h}^{2}\) are updated to \(M\) at the corresponding session entry \(\mathbf{s}_{i,h}^{1}\longrightarrow\mathbf{f}_{i}^{1},\mathbf{s}_{i,h}^{2}\longrightarrow \mathbf{f}_{i}^{2}\), and negative session embeddings can be sampled from \(M\), i.e., \(\mathbf{s}_{j,1,h}^{-}\longleftarrow\mathbf{f}_{j}^{1},\mathbf{s}_{j,2,h}^{-}\longleftarrow \mathbf{f}_{j}^{2}\). This allows us to compute the comparison loss without additional forward propagation, but only with the corresponding vector in the memory bank \(M\).

### Model Optimization

In the previous section, we defined the prediction loss \(\mathcal{L}_{pred}\) and the contrastive loss \(\mathcal{L}_{con}\), we define our final loss function with the integration of both of them as follows:

\[\mathcal{L}=\mathcal{L}_{pred}+\beta\mathcal{L}_{con}+\lambda||\Theta||_{2}^{ 2}, \tag{16}\]

where \(\Theta\) is all trainable parameters, \(\beta\) is the hyper-parameter for balancing the contrastive module, \(\lambda\) is the regularization hyper-parameter.

## 4 Experiments

### Datasets

Following previous work, we choose two commonly used session recommendation datasets, that is, Yoochoose 1/641 and Diginetica2. The Yoochoose dataset is from the RecSys Challenge 2015 and consists of six months of interaction sessions from an E-commercial website. We only make use of the most recent fractions 1/64 of the training sequences of Yoochoose denoted. The Diginetica dataset comes from CIKM Cup 2016, and only the transaction data is used.

Footnote 1: [http://2015.recsyschallenge.com/challenge.html](http://2015.recsyschallenge.com/challenge.html)

Footnote 2: [http://cikm2016.cs.iupui.edu/cikm-cup](http://cikm2016.cs.iupui.edu/cikm-cup)

For fairness consideration, we use the same preprocessing techniques as [21], which filter out all sessions of length 1 and items that appears less than 5 times in both datasets. Moreover, we do data augmentation on a session to obtain sequences and corresponding labels. For example, for session \(s=[v_{1},v_{2},...,v_{n}]\), we split it in to \(([v_{1}],v_{2},([v_{1},v_{2}],v_{3}),...,([v_{1},v_{2},...,v_{n-1}],v_{n})\). The statistics of the two datasets are shown in Table 1.

### Evaluation Metrics

According to previous works, **Recall@20** and **MRR@20** are selected to evaluate the performance of our method and baselines.

### Baselines

To evident the effectiveness of our proposed _SimCGNN_, we compare it with the following representative baselines.

* _POP_ and _SPOP_ recommend the top-K popular item in training dataset and in the current predicting session respectively.
* _Item-KNN[17]_ leverages item-to-item collaborative filtering techniques, which recommends items similar to the previously interacted items by cosine similarity.
* _BPR[1]_ is a classical matrix factorization (MF) methods, and is optimized by a pairwise ranking loss function.
* _FPMC[1]_ is a sequential prediction method combining the Markov chain and MF.
* _GRU4REC[11]_ utilizes the RNN structure to model the sequential interaction of users and leverages multiple tricks to help the RNN converge to the session recommendation problem.
* _NARM[18]_ improves GRU4REC by incorporating an attention mechanism into RNN.
* _STAMP[19]_ replaces the RNN structures by employing attention mechanism.
* _SR-GNN[21]_ first introduces session graph structure into a session-based recommendation. By utilizing a Gated GNN to extract on-graph item embeddings, the last item together with a weighted sum of all the session embeddings are concatenated for prediction.

\begin{table}
\begin{tabular}{l l l} \hline \hline Dataset & Yoochoose 1/64 & Diginetica \\ \hline \#click & 557,248 & 982,961 \\ \#training sessions & 369,859 & 719,470 \\ \#test sessions & 55,898 & 60,858 \\ \#items & 16,766 & 43,097 \\ Average Length & 6.16 & 5.12 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Statistic of the Datasets
* _FGNN_[20] formulates the next item recommendation within the session as a graph classification problem.
* _GCE-GNN_[21] constructed a global graph using session data and modifies the model structure to introduce the global information learned from the global graph.
* _Disen-GNN_[11] proposes a disentangled graph neural network to capture the session purpose.
* \(S^{2}\)_-DHCN_[22] constructs each session as a hypergraph and utilizes contractive learning methods.

### Implementation Details

To align with the previous work, we set the hidden size \(d=100\), while model parameters are initialized using Gaussian distribution with a mean of 0 and deviation of 0.1. The mini-batch Adam optimizer is utilized to optimize model parameters. The initial learning rate is set to 1e-3 and decays by 0.1 every 3 epochs. Dropout probabilities for all dropout layers are set to 0.1. For the contrastive module, the temperature parameter \(\tau\) is set to 12, and \(\beta\) is set to 0.1 for Yoochoose 1/64 and 1 for Diginetica. All the hyperparameters are tuned on the validation set.

### Experiment Results

To further demonstrate the overall performance of our proposed SimCGNN, we compare it with the selected baselines described above. The experimental results are shown in Table 2. From Table 2, we can say that our _SimCGNN_ achieves the best performance on all two datasets, especially in **MRR@20**, which illustrates the superior ranking capability compared with other baseline methods.

Among traditional methods, the Item-KNN achieves the best performance, although the overall performance of all traditional methods is relatively poor. To our surprise, the simple yet effective S-POP shows better performance than those of BPR and FPMC. Notably, the S-POP takes only item popularity into consideration, which means both the Yoochoose 1/64 dataset and the Diginetica dataset are suffered from popularity bias. It's also vital to point out that, the Item-KNN utilizes pairwise item similarities only and performs better than FPMC, which is an MC-based approach with the assumption that only the last interacted items are needed to perform sequential recommendation. This phenomenon indicates that the simple MC assumption is not suitable for such complex sessions.

As for Deep learning-based methods, all DL-based methods consistently outperform traditional methods. GRU4REC and NARM are both based on RNN structure, and they together achieved decent performances. However, since NARM adds an attention mechanism to the original RNN to give different weights to items at different positions in the session, the performance of NARM has a significant improvement over GRU4REC. STAMP, which replaces RNN with attentional MLPs, shows comparative performance over NARM. At last, all DL-base methods share better performance over FPMC, which shows the importance of modeling the whole interaction sequence instead of considering merely the last click. However, both RNNs and MLPs are not suitable for capturing complex transitions among sessions. This may be the reason why they perform worse than graph-based methods.

Graph-based methods outperform all other baselines by a large margin. More specifically, GCE-GNN outperforms SR-GNN as it effectively leverages global information in different ways. FGNN also shows competitive results by rethinking item order and replacing the assembling method by a well-designed readout function. Disen-GNN gains decent performance on both datasets, showing the importance of disentangled session graphs. The \(S^{2}-DHCN\), however, performs the worst on Yoochoose 1/64, which does not match the capacity of hypergraph neural networks. Compared with these state-of-the-art methods, our methods achieve comparative performances or even better performances without explicitly applying global information. Expanding on this, our method has optimal **MRR@20** on both datasets. The **Recall@20** of our method is higher than GCE-GNN and lower than FGNN on the Yoochoose 1/64 dataset and the opposite on the Diginetica dataset. We must also point out that the number of parameters used in our _SimCGNN_ is consistent with the SR-GNN. This means that we have achieved a top-level performance using the least parameters among all graph-based methods, which strongly demonstrates the superiority of our network structure. In conclusion, graph-based methods have an inherent advantage over traditional methods and DL-based methods in modeling complex sessions.

### Ablation Study

To further validate the effectiveness of each module in our _SimCGNN_, we compare our _SimCGNN_ with the following four variants.

* **SimCGNN-Contrast**. We removed the contrastive module of _SimCGNN_ to prove its effectiveness.
* **SimCGNN-WeakNeg**. We randomly sample negative

\begin{table}
\begin{tabular}{c c c c c} \hline \hline \multirow{2}{*}{Method} & \multicolumn{2}{c}{Yochoose 1/64} & \multicolumn{2}{c}{Diginetica} \\  & Recall@20 & MRR@20 & Recall@20 & MRR@20 \\ \hline POP & 6.71 & 1.65 & 0.89 & 0.20 \\ S-POP & 30.44 & 18.35 & 21.06 & 13.68 \\ Item-KNN & 51.60 & 21.81 & 35.75 & 11.57 \\ BPR & 31.31 & 12.08 & 5.24 & 1.98 \\ FPMC & 45.62 & 15.01 & 26.53 & 6.95 \\ \hline GRU4REC & 60.64 & 22.89 & 29.45 & 8.33 \\ NARM & 68.32 & 28.63 & 49.70 & 16.17 \\ STAMP & 68.74 & 29.67 & 45.64 & 14.32 \\ \hline SR-GNN & 70.57 & 30.94 & 50.73 & 17.59 \\ FGNN & **71.75** & 31.71 & 51.36 & 18.47 \\ GCE-GNN & 70.91 & 30.63 & **54.22** & **19.04** \\ Disen-GNN & 71.46 & 31.36 & 53.79 & 18.99 \\ \(S^{2}\)-DHCN & 70.39 & 29.92 & 53.66 & 18.51 \\ \hline _SimCGNN_ & 71.61 & **31.99** & 54.01 & **19.04** \\ \hline \hline \end{tabular}
\end{table}
Table 2: Recommendation performance on two datasets. The best performing method in each column is **boldfaced**, and the second best method is underlined.
sessions instead of choosing sessions with the same last item.
* **SimCGNN-Norm**. We removed all normalizations to prove the effectiveness of normalized session embeddings.
* **SimCGNN-PE**. We removed positional embeddings to validate whether the positional information is useful for session graphs.

The results of the proposed ablation studies are shown in Table 3.

As the most essential component of our approach, we first verified the effectiveness of the proposed contrastive module. It is not difficult to see from the experimental results that _SimCGNN_-Contrast performs weaker than the original _SimCGNN_ on both datasets. This demonstrates the effectiveness of using the contrastive related approach to enhance the representation ability of session embeddings.

In _SimCGNN_-WeakNeg, we did not emphasize the importance of negative sessions with the same last-item, which greatly affected the ranking performance of the model on both datasets. In terms of recall metrics, the model was not affected too much, and there was even a marginal increase on the Yoochoose 1/64 dataset. This illustrates that our sampling method can give more favorable rankings to items that are more suitable for the target session in a relatively similar set of candidate items.

As shown in Table 3, the overall performance of _SimCGNN_-Norm is severely damaged. This is not only because normalization is effective in suppressing popularity bias, but also because removing normalization makes it more difficult for the contrastive module to learn the intrinsic discrepancies between sessions.

We finally verified the effectiveness of introducing positional information into the session graph. Experimental results demonstrate that the ranking performance of the model, especially on the Yoochoose 1/64 dataset, is greatly affected after the removal of the positional embedding.

### Case Study

**Effect on Solving Same Last-Item Confusion**

Consistent with the Introduction section, we still take sessions with the same last-item (item _33889_) and utilize the trained SR-GNN and _SimCGNN_ to provide predictions. For each session, 20 items are recommended and counted. The relationship between the number of occurrences of an item in the prediction candidate set and its corresponding occurrence ranking is shown in Fig.3. From the figure we can see that _SimCGNN_ predicts a lower curve of item occurrences compared to SR-GNN, which shows that SimCGNN can provide different recommendations for sessions with the same last-item. At the same time, _SimCGNN_ recommended a total of 142 kinds of items, 20 more than the 122 kinds of items in SR-GNN, which also demonstrates the effectiveness of our method in solving the same last-item confusion.

**Effect on Solving Popularity Bias**

To measure the popularity of recommended items, we calculated **Average Recommendation Popularity (ARP)** on SR-GNN and _SimCGNN_ to compare the difference in popularity of recommended items between the two methods. The ARP can be calculated as follows,

\[ARP=\frac{1}{|S|}\sum_{s\in S}\frac{\sum_{i\in L_{s}}\phi(i)}{K}, \tag{17}\]

where \(\phi(i)\) is the number of times that item \(i\) appears in the training dataset, \(L_{s}\) is the recommended item list for session \(s\), and \(S\) is the set of sessions in the test dataset.

From Table 4, it is easy to see that our _SimCGNN_ method has a huge difference in the popularity of recommended items on both datasets compared to SR-GNN. This proves that our method can indeed solve the problem of popularity bias to some extent.

## 5 Conclusion

In this paper, to address the session-based recommendation problem, we proposed a novel Simple Contrastive Graph Neural Network (_SimCGNN_), which introduces a contrastive module to deal with the "same last-item confusion" problem and normalized item and session embeddings to cope with

\begin{table}
\begin{tabular}{l c c} \hline \hline Method & Yoochoose 1/64 & Diginetica \\ \hline SR-GNN & 4128.54 & 495.25 \\ _SimCGNN_ & **2678.64** & **285.85** \\ \hline \hline \end{tabular}
\end{table}
Table 4: _SimCGNN_ versus SR-GNN in terms of Average Recommendation Popularity (ARP). Lower ARP value indicates lower popularity bias.

\begin{table}
\begin{tabular}{l c c c c} \hline \hline \multirow{2}{*}{Method} & \multicolumn{2}{c}{Yochoose 1/64} & \multicolumn{2}{c}{Diginetica} \\  & Recall@20 & MRR@20 & Recall@20 & MRR@20 \\ \hline SR-GNN & 70.57 & 30.94 & 50.73 & 17.59 \\ \hline _SimCGNN_ & 71.61 & **31.99** & **54.01** & **19.04** \\ -Contrast & 71.31 & 31.80 & 53.49 & 19.01 \\ -WeakNeg & **71.65** & 31.16 & 53.99 & 18.92 \\ -Norm & 71.01 & 31.55 & 51.77 & 17.58 \\ -PE & 71.39 & 30.92 & 53.80 & 18.94 \\ \hline \hline \end{tabular}
\end{table}
Table 3: Performance of variants of _SimCGNN_.

Figure 3: Predicted results of SimCGNN and SR-GNN on sessions with the same last-item (_item 33889_).
popularity bias. Experiments on two real-world datasets validate that our _SimCGNN_ outperforms the state-of-the-art approaches with a significant margin in terms of **Recall@20** and **MRR@20**. In future work, we aim to propose a new combination approach that can eliminate the impact of the last item to a greater extent.
