Improving Graph Collaborative Filtering with Neighborhood-enriched Contrastive Learning

Zihan Lin, Changxin Tian, Yupeng Hou, Wayne Xin Zhao · DOI

Abstract

Recently, graph collaborative filtering methods have been proposed as an effective recommendation approach, which can capture users' preference over items by modeling the user-item interaction graphs. In order to reduce the influence of data sparsity, contrastive learning is adopted in graph collaborative filtering for enhancing the performance. However, these methods typically construct the contrastive pairs by random sampling, which neglect the neighboring relations among users (or items) and fail to fully exploit the potential of contrastive learning for recommendation. To tackle the above issue, we propose a novel contrastive learning approach, named Neighborhood-enriched Contrastive Learning (NCL), which explicitly incorporates the potential neighbors into contrastive pairs. Specifically, we introduce the neighbors of a user (or an item) from graph structure and semantic space respectively. For the structural neighbors on the interaction graph, we develop a novel structure-contrastive objective that regards users (or items) and their structural neighbors as positive contrastive pairs. Furthermore, to excavate the potential neighbor relation in semantic space, we assume that users with similar representations are within the semantic neighborhood, and incorporate these semantic neighbors into the prototype-contrastive objective. Extensive experiments on five public datasets demonstrate the effectiveness of the proposed NCL, notably with 26% and 17% performance gain over a competitive graph collaborative filtering base model on the Yelp and Amazon-book datasets respectively.

Introduction

Graph Neural Networks (GNNs) have become a cornerstone of modern collaborative filtering by representing user-item interactions as a bipartite graph. Despite their success, these models are highly sensitive to the inherent sparsity and noise of real-world interaction data. Contrastive Learning (CL) has recently been introduced as a self-supervised auxiliary task to improve representation robustness. However, early graph CL methods like SGL rely on stochastic augmentations—such as random edge dropping or node masking—to generate contrastive pairs, which often ignores the intrinsic relationships between similar nodes.

Conceptual overview comparing traditional random augmentation (SGL) with NCL's structural and semantic neighborhood-based contrastive learning.

To address this, we propose Neighborhood-enriched Contrastive Learning (NCL). Instead of random corruption, NCL explicitly identifies and leverages structural and semantic neighbors to provide a more meaningful self-supervised signal for recommendation.

Methodology

NCL is a model-agnostic framework designed to enhance GNN-based recommenders, using LightGCN as a representative backbone. It introduces two novel contrastive objectives that operate alongside the standard recommendation task.

1. Structural Neighbor Contrastive Learning

In a bipartite graph, nodes of the same type (e.g., two users) are connected via an even number of hops. NCL exploits this structural property by treating the outputs of even-numbered GNN layers as positive contrastive pairs for the original node embedding. This approach effectively pulls a node closer to its multi-hop structural neighbors. Experiments indicate that using the 2-hop layer (the first even layer) provides the optimal balance between effectiveness and efficiency.

2. Semantic Neighbor Contrastive Learning

To account for users or items that share latent preferences but lack direct graph proximity, NCL incorporates semantic neighbors via a prototype-contrastive objective. The model employs an Expectation-Maximization (EM) algorithm, specifically K-means clustering, to identify latent "prototypes" (cluster centroids) in the embedding space. A node and its assigned prototype are then treated as a positive contrastive pair. Setting the number of prototypes ($k$) to approximately 1,000 yielded the best results in our evaluations.

The NCL architecture illustrating the integration of structural and semantic contrastive losses with the GNN-based recommendation pipeline.

The final training objective combines the Bayesian Personalized Ranking (BPR) loss with the two contrastive terms: $\mathcal{L} = \mathcal{L}_{BPR} + \lambda_1 \mathcal{L}_{struc} + \lambda_2 \mathcal{L}_{proto}$.

Experimental Results

The effectiveness of NCL was evaluated across five diverse public datasets: MovieLens-1M, Yelp, Amazon-Books, Gowalla, and Alibaba-iFashion. For Yelp and Amazon-Books, datasets were filtered to retain users and items with at least 15 interactions to ensure baseline quality.

  • State-of-the-Art Performance: NCL consistently outperformed baselines including BPRMF, NGCF, LightGCN, and SGL. It achieved a 26% improvement on Yelp and a 17% improvement on Amazon-Books over the base LightGCN model.
  • Ablation Study: Removing either the structural or semantic contrastive loss resulted in a performance decline, confirming that both signals provide complementary information.
  • Robustness to Sparsity: NCL provides the most significant gains for inactive users, demonstrating its ability to mitigate the "cold-start" problem through neighborhood enrichment.

Discussion and Insights

A primary takeaway is that domain-aligned self-supervision is superior to generic random augmentations. By leveraging the graph's even-hop structure and latent semantic clusters, the model captures a more nuanced view of user-item relationships. Furthermore, visualization of the learned embeddings shows that NCL promotes greater uniformity on the hypersphere, which is theoretically linked to better feature diversity and recommendation quality.

Conclusion

Neighborhood-enriched Contrastive Learning (NCL) addresses the limitations of random graph augmentations by explicitly modeling structural and semantic neighborhoods. By integrating these signals into a multi-task learning framework, NCL significantly improves recommendation accuracy, particularly in sparse data scenarios. Future research will explore the application of NCL to sequential recommendation and more unified neighborhood modeling techniques.

Summary updated

BibTeX
@inproceedings{lin2022improving,
  author = {Zihan Lin and Changxin Tian and Yupeng Hou and Wayne Xin Zhao},
  title = {{Improving Graph Collaborative Filtering with Neighborhood-enriched Contrastive Learning}},
  booktitle = {The Web Conference},
  year = {2022},
  doi = {10.1145/3485447.3512104},
}
Figure