Do We Really Need Contrastive Learning for Graph Representation?

Yulan Hu, Sheng Ouyang, Jingyu Liu, Ge Chen, Zhirui Yang, Junchen Wan, Fuzheng Zhang, Zhongyuan Wang, Yong Liu

Abstract

Graph contrastive learning (GCL) has emerged as a representative graph self-supervised method, achieving significant success. The currently prevalent optimization objective for GCL is InfoNCE. Typically, it employs augmentation techniques to obtain two views, where a node in one view acts as the anchor, the corresponding node in the other view serves as the positive sample, and all other nodes are regarded as negative samples. The goal is to minimize the distance between the anchor node and positive samples and maximize the distance to negative samples. However, due to the lack of label information during training, InfoNCE inevitably treats samples from the same class as negative samples, leading to the issue of false negative samples. This can impair the learned node representations and subsequently hinder performance in downstream tasks. While numerous methods have been proposed to mitigate the impact of false negatives, they still face various challenges. For instance, while increasing the number of negative samples can dilute the impact of false negatives, it concurrently increases computational burden. Thus, we propose GraphRank, a simple yet efficient graph contrastive learning method that addresses the problem of false negative samples by redefining the concept of negative samples to a certain extent, thereby avoiding the issue of false negative samples. The effectiveness of GraphRank is empirically validated through experiments on the node, edge, and graph level tasks.

Introduction

Graph contrastive learning (GCL) has become the standard for self-supervised learning on graphs. Most GCL methods rely on the InfoNCE loss, which works by pulling a node and its "positive" counterpart (an augmented version of itself) together while pushing it away from all other nodes in the batch (the "negatives").

However, this approach suffers from two major flaws. First is the False Negative Problem: since labels aren't available during pre-training, InfoNCE accidentally treats nodes from the same class as negatives. Forcing the model to push these similar nodes apart distorts the learned representations. Second is Computational Complexity: to dilute the impact of false negatives, researchers often use a massive number of negative samples, pushing computational costs toward $O(N^2)$ and making models difficult to scale.

Methodology

We propose GraphRank, which simplifies the GCL pipeline significantly. Like standard methods, it creates two augmented views of the graph using random node and edge masking. A standard Graph Neural Network (GNN) encoder, such as GCN or GAT, is then used to produce node embeddings.

The core innovation is the Margin-based Rank Loss: $$L_{rank} = \max\{0, \text{margin} - (\text{sim}(anchor, pos) - \text{sim}(anchor, neg))\}$$

Instead of using InfoNCE to push negatives as far away as possible, this objective only cares that the positive sample is "more similar" to the anchor than the negative sample by a certain margin. If the condition is met, the loss is zero and optimization for that pair stops. By shifting from "maximum separation" to "relative ranking," the model no longer aggressively pushes away false negatives. Consequently, GraphRank only needs one randomly sampled negative per anchor.

Overview of the GraphRank framework showing the ranking logic and optimization stop conditions.

Experimental Setup

GraphRank was evaluated across 14 diverse datasets to ensure broad applicability:

  • Node Classification & Link Prediction: Cora, CiteSeer, PubMed (citation networks); Photo, Computer (Amazon co-purchase); CS, Physics (co-author networks).
  • Graph Classification: MUTAG, IMDB-B, IMDB-M, PROTEINS, COLLAB, REDDIT-B.

Discussion and Insights

A central insight of this work is that "good enough" is often better than "maximum." We don't need to push negative samples to the opposite side of the embedding space; simply ensuring they are less similar than the positive sample is enough to learn high-quality boundaries.

This approach results in tighter clusters. Because GraphRank doesn't force same-class nodes apart, it naturally results in much lower intra-class variance. Nodes of the same category huddle closer together in the embedding space, which directly improves classification accuracy.

GraphRank achieves lower intra-class variance compared to GRACE across multiple datasets, leading to tighter clusters.

Furthermore, the rank loss is axiomatically robust. Even if the single negative sample chosen is a "false negative" (same class as the anchor), it remains true that a node should be more similar to its own augmented version than to a different node of the same class.

Key Results

  • Performance: GraphRank outperformed or matched state-of-the-art (SOTA) supervised and self-supervised baselines on 6 out of 7 node classification tasks.
  • Efficiency: On the CS dataset, GraphRank was 27.5x faster than BGRL while achieving higher accuracy. Compared to GRACE, it achieved a 10x speedup on the PubMed dataset.
  • Scalability: Its time and space complexity are $O(N)$, whereas many InfoNCE-based methods struggle at $O(N^2)$. The model achieves peak performance using only one negative sample, drastically reducing memory overhead.

Conclusion

GraphRank demonstrates that complex contrastive objectives may not be necessary for high-quality graph representations. While it reduces intra-class variance, it also results in smaller inter-class distances compared to InfoNCE. Future research will focus on exploring GraphRank on massive-scale industrial graphs where its linear efficiency can be fully leveraged.

Summary updated

BibTeX
@misc{hu2023do,
  author = {Yulan Hu and Sheng Ouyang and Jingyu Liu and Ge Chen and Zhirui Yang and Junchen Wan and Fuzheng Zhang and Zhongyuan Wang and Yong Liu},
  title = {{Do We Really Need Contrastive Learning for Graph Representation?}},
  year = {2023},
  eprint = {2310.14525},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2310.14525},
}
Figure