Structure-Aware Hard Negative Mining for Heterogeneous Graph Contrastive Learning

Yanqiao Zhu, Yichen Xu, Hejie Cui, Carl Yang, Qiang Liu, Shu WuarXiv 2021

Abstract

Heterogeneous Graph Contrastive Learning (HGCL) has emerged as a powerful self-supervised paradigm for learning node representations without manual labels. However, existing methods often suffer from the "hard negative problem," where nodes with similar structural roles or neighborhood contexts are incorrectly treated as negative samples, degrading the quality of the learned embeddings. We present HORACE (HeterOgeneous gRAph Contrastive learning), a framework that leverages structural metrics like Personalized PageRank and Laplacian Positional Embeddings to identify and synthesize truly informative hard negatives. By decoupling negative mining from evolving semantic embeddings, HORACE achieves performance that rivals or exceeds supervised baselines on benchmark datasets.

Introduction

Heterogeneous Graphs (HGs), which incorporate diverse node and edge types (e.g., authors, papers, and venues in an academic network), provide a rich substrate for modeling complex real-world systems. While Graph Neural Networks (GNNs) excel at capturing these relationships, they typically require extensive labeled data. Contrastive Learning (CL) offers a solution by teaching models to maximize similarity between positive pairs (different views of the same node) and minimize it between negative pairs (different nodes).

The Hard Negative Problem in GNNs

A significant challenge in graph-based CL is the selection of negative samples. In GNNs, the process of neighborhood aggregation naturally "smooths" the representations of nearby nodes, making them semantically similar in the embedding space.

The hard negative problem: (a) shows how nodes sharing labels (false negatives) are often closer to the anchor than true negatives. (b) illustrates the resulting overlap in similarity scores, where many false negatives have higher similarity than true negatives.

As shown in Figure 1, standard CL often selects "false negatives"—nodes that are close to the anchor in the graph and likely share the same class label. When the model is forced to "pull apart" these similar nodes, it learns suboptimal features that fail to capture the underlying class boundaries. This is particularly problematic in the early stages of training when embeddings are noisy and unreliable for similarity-based mining.

The HORACE Framework

To address these limitations, HORACE introduces a structure-aware approach to negative mining that relies on fixed topological properties rather than fluctuating semantic embeddings.

1. Multiview Generation and Aggregation

HORACE begins by generating multiple "semantic views" of the heterogeneous graph based on predefined metapaths (e.g., Author-Paper-Author). These views capture different relational nuances. The framework employs a teacher-student distillation architecture where embeddings from specific semantic views (teachers) are aggregated into a unified student representation.

The HORACE architecture: Heterogeneous graphs are decomposed into multiple semantic views via metapaths, which are then aggregated into a comprehensive representation.

2. Structure-Aware Hard Negative Mining

Instead of using learned embeddings to find hard negatives, HORACE utilizes two structural metrics calculated during preprocessing:

  • Personalized PageRank (PPR): This measures the relative importance and reachability of nodes from a specific anchor, identifying nodes that are structurally close but not necessarily neighbors.
  • Laplacian Positional Embeddings (PE): These capture the global geometric structure of the graph, providing a coordinate system that reflects the graph's overall topology.

By selecting negatives that are structurally distant yet potentially confusing to the model, HORACE avoids the smoothing trap of neighborhood-based similarity.

3. Hard Negative Synthesis

Finding hard negatives is only half the battle. HORACE further enhances the training signal by creating synthetic negatives. By interpolating (mixing) the top-$T$ hardest structural negatives, the model generates a continuous range of challenging samples. This forces the encoder to learn finer-grained distinctions, preventing the model from taking "shortcuts" during the contrastive task.

Experimental Results

The framework was evaluated on three major benchmarks: DBLP, ACM, and IMDb.

  • Superiority over Unsupervised Baselines: HORACE consistently outperformed state-of-the-art unsupervised methods like DGI and GRACE. On the ACM dataset, it achieved significant gains in Micro-F1 scores.
  • Competitive with Supervised Models: Remarkably, HORACE (unsupervised) surpassed the performance of supervised versions of GCN and GAT on the ACM and IMDb datasets. This indicates that the structure-aware contrastive objective captures more robust, generalizable features than traditional label-driven training.
  • Ablation Studies: Removing the synthetic negative component (referred to as HORACE-) resulted in a measurable performance drop, confirming that the combination of structural mining and interpolation is the primary driver of the model's efficacy.

Conclusion

HORACE demonstrates that structural information is a more reliable proxy for "hardness" in graph contrastive learning than learned semantic embeddings. By bypassing the neighborhood smoothing effect and synthesizing challenging negative samples, HORACE sets a new standard for self-supervised representation learning on heterogeneous graphs. Future work will explore the scalability of these structural metrics for web-scale graphs and their applicability to link prediction tasks.

Summary updated

BibTeX
@misc{zhu2021structure,
  author = {Yanqiao Zhu and Yichen Xu and Hejie Cui and Carl Yang and Qiang Liu and Shu Wu},
  title = {{Structure-Aware Hard Negative Mining for Heterogeneous Graph Contrastive Learning}},
  year = {2021},
  eprint = {2108.13886},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2108.13886},
}
Figure