Supervised Graph Contrastive Learning for Few-shot Node Classification

Zhen Tan, Kaize Ding, Ruocheng Guo, Huan Liu · DOI

Abstract

Graphs are present in many real-world applications, such as financial fraud detection, commercial recommendation, and social network analysis. But given the high cost of graph annotation or labeling, we face a severe graph label-scarcity problem, i.e., a graph might have a few labeled nodes. One example of such a problem is the so-called few-shot node classification. A predominant approach to this problem resorts to episodic meta-learning. In this work, we challenge the status quo by asking a fundamental question whether meta-learning is a must for few-shot node classification tasks. We propose a new and simple framework under the standard few-shot node classification setting as an alternative to meta-learning to learn an effective graph encoder. The framework consists of supervised graph contrastive learning with novel mechanisms for data augmentation, subgraph encoding, and multi-scale contrast on graphs. Extensive experiments on three benchmark datasets (CoraFull, Reddit, Ogbn) show that the new framework significantly outperforms state-of-the-art meta-learning based methods.

The Challenge of Few-Shot Node Classification

In many real-world graph scenarios—like fraud detection or social network analysis—labels are expensive to obtain. This leads to the few-shot node classification problem: how do we classify nodes in "novel" classes when we only have a handful (e.g., 1 or 5) of labeled examples?

The current "status quo" solution is episodic meta-learning. This approach mimics the few-shot task during training by creating thousands of tiny "episodes." However, this approach has two major flaws:

  1. Piecemeal Knowledge: Because each episode only looks at a tiny subset of nodes and classes, the model fails to capture the broader topological patterns of the graph.
  2. Inefficiency: To compensate for this fragmented view, meta-learning requires a massive number of episodes to converge, making it slow and difficult to scale to large graphs.
The standard episodic meta-learning setup for few-shot node classification, contrasting meta-training on base classes with testing on novel classes.

The G-SupCon Framework

This paper proposes a decoupled framework that separates representation learning from classification, challenging the dominance of episodic meta-learning by proposing a simpler, more efficient alternative: Supervised Graph Contrastive Learning (G-SupCon).

The proposed G-SupCon framework: (a) supervised contrastive training using subgraph sampling and multi-scale loss, (b) fine-tuning on few-shot labeled nodes, and (c) the subgraph sampling process for augmentation.

Key Methodological Components

  1. Connectivity-Based Data Augmentation: Instead of random noise, the framework uses graph topology to create "views." For every node, it samples a contextualized subgraph based on connectivity scores (using Node Algebraic Distance or Personalized PageRank). This ensures the "augmented" view is semantically relevant.
  2. Subgraph Encoding: Unlike standard methods that process the entire graph, the GNN encoder ($g_\theta$) only processes these small, sampled subgraphs. This makes the model highly scalable and avoids the "neighborhood explosion" problem.
  3. Multi-scale Contrastive Learning: The core is a supervised contrastive loss (G-SupCon) that pulls together representations of nodes belonging to the same class while pushing different classes apart. It contrasts at three levels: node-to-node, subgraph-to-subgraph, and node-to-subgraph.
  4. Simple Fine-tuning: Once the encoder is pre-trained on "base classes," it is frozen. A simple linear classifier (like Logistic Regression) is then trained on the few labeled nodes of the "novel" classes.

Experimental Results

The framework was evaluated on three widely used benchmark datasets: CoraFull (citation network), Reddit (social network), and Ogbn-arxiv (massive citation network).

  • Accuracy: G-SupCon significantly outperformed meta-learning baselines. For example, on CoraFull (10-way 5-shot), G-SupCon achieved 86.13% accuracy, compared to 62.02% for GPN (a top meta-learning method).
  • Speed: The efficiency gains were dramatic. On the CoraFull dataset, training time dropped from 1352 seconds (GPN) to only 10 seconds. On Ogbn-arxiv, training time fell from 2562 seconds to just 54 seconds.
  • Robustness: The method proved more robust to "extreme" few-shot scenarios (like 1-shot classification) than traditional meta-learning approaches.

Conclusion

The most striking insight of this work is that meta-learning is not a "must." A well-designed pre-training strategy focusing on structural patterns across the entire base dataset can outperform complex meta-learning architectures. By shifting the focus from the whole graph to localized subgraphs, G-SupCon achieves state-of-the-art accuracy while reducing training time from hours to seconds.

Summary updated

BibTeX
@inproceedings{tan2022supervised,
  author = {Zhen Tan and Kaize Ding and Ruocheng Guo and Huan Liu},
  title = {{Supervised Graph Contrastive Learning for Few-shot Node Classification}},
  booktitle = {ECML/PKDD},
  year = {2022},
  url = {https://openreview.net/forum?id=RRw29XQfQU},
}
Figure