NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Exploring Consistency in Graph Representations: from Graph Kernels to Graph Neural Networks

Xuyuan Liu, Yinghao Cai, Qihui Yang, Yujun Yan

TL;DR

Graph Neural Networks (GNNs) often lose the relative similarity (relational structure) between graphs as data passes through multiple layers, primarily due to the nature of standard classification losses. Inspired by the mathematical properties of successful graph kernels, this paper introduces a novel, model-agnostic "consistency loss" that forces GNNs to maintain the ranking of graph similarities across layers, universally boosting classification performance across various GNN architectures.

Introduction: The Relational Structure Problem

In graph classification, Graph Neural Networks (GNNs) have become the dominant approach. However, standard GNN training relies heavily on cross-entropy loss, which forces graphs of the same class into identical representations. While beneficial for final classification, this process inadvertently destroys the "relational structure" in intermediate layers. For instance, if Graph A is highly similar to Graph B in the first layer, they might appear completely dissimilar by the second or third layer.

Inconsistent similarity rankings across GNN layers

Conversely, traditional Graph Kernel methods—such as the Weisfeiler-Lehman optimal assignment (WLOA) kernel—are excellent at preserving these similarity relationships. Unfortunately, they lack the non-linear flexibility of deep learning and scale poorly to large datasets. The core challenge addressed by this research is bridging this gap: equipping GNNs with the structural consistency of graph kernels without sacrificing their deep learning advantages.

Methodology: Enforcing Structural Consistency

The authors tackle this challenge through a blend of theoretical foundation and practical deep learning application.

1. Theoretical Foundation

The researchers define a class of "Iterative Graph Kernels" (IGKs) and mathematically prove that kernels possessing two specific properties—Monotonic Decrease and Order Consistency (meaning similar graphs stay similar in subsequent iterations)—exhibit better generalization bounds. They demonstrate that the superior performance of certain kernels, like WLOA over the standard WL-subtree kernel, is precisely because they asymptotically maintain this consistency.

2. The Consistency Loss

To port this theoretical insight to GNNs, the authors propose a novel auxiliary loss function. Because directly optimizing the "ranking" of similarities is a non-differentiable operation, they employ a probabilistic approach:

Architecture of the proposed consistency loss
  • At each GNN layer, a pairwise distance matrix is computed for all graphs in a given batch.
  • The model calculates the probability that Graph A is closer to Graph B than it is to Graph C.
  • A cross-entropy loss is applied to ensure that this probability distribution at the current layer matches the distribution from the previous layer.
  • This auxiliary loss is added to the standard classification loss, acting as a powerful structural regularizer.

Key Insights and Experimental Results

The authors evaluated their method across a wide variety of graph benchmarks, covering domains like Chem/Bioinformatics (NCI1, PROTEINS, D&D), Social Networks (IMDB, COLLAB), and large-scale datasets like OGB (ogbg-molhiv) and Reddit-T.

Cross-Entropy as a Double-Edged Sword: While necessary for classification, standard cross-entropy actively harms the preservation of relational structures in the intermediate representation spaces of GNNs.

Relative Ranking Over Absolute Distance: The authors found that it is not necessary to force the absolute distance between two graph embeddings to remain static across layers. Simply preserving the relative ranking of similarities is sufficient to act as a powerful regularizer. Furthermore, applying this consistency loss only between the first and last layers yields almost identical performance gains while saving compute (the "First and Last" trick).

Universal Performance Boost: The consistency loss improved the performance of five different baseline GNNs (GCN, GIN, GraphSAGE, GTransformer, GMT) across almost all tested datasets. The Graph Isomorphism Network (GIN) saw the most dramatic improvements, jumping by +4.51% on the D&D dataset and +4.32% on COLLAB.

Proven Consistency: Using Spearman's rank correlation, the authors verified that their loss functions as intended. For example, the layer-to-layer similarity correlation for GIN on the NCI1 dataset jumped from a baseline of 0.666 to 0.877 with the consistency loss. Despite requiring pairwise distance calculations, training time scales linearly with dataset size, and memory overhead remains negligible (only a 2-5% increase in peak memory usage).

Limitations and Future Directions

Because the consistency loss requires computing pairwise distances within a batch, its time and space complexity scale quadratically with the batch size ($\mathcal{O}(B^2)$). While manageable for standard batch sizes, this could become a computational bottleneck for massive batches.

To mitigate this limitation, future work could explore sampling methodologies. By selectively sampling specific data points or only applying the loss to specific layers (as hinted at by the "First and Last" layer experiment), the computational burden could be further reduced for massive-scale deployments.

Summary updated

BibTeX
@inproceedings{liu2024exploring,
  author = {Xuyuan Liu and Yinghao Cai and Qihui Yang and Yujun Yan},
  title = {{Exploring Consistency in Graph Representations: from Graph Kernels to Graph Neural Networks}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=dg0hO4M11K},
}
Figure