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

Enhancing Size Generalization in Graph Neural Networks through Disentangled Representation Learning

Zheng Huang, Qihui Yang, Dawei Zhou, Yujun Yan

Abstract

Graph Neural Networks (GNNs) frequently encounter performance degradation when applied to graphs significantly larger than those seen during training—a challenge known as size generalization. This paper introduces DISGEN, a model-agnostic framework designed to mitigate feature entanglement where models rely on graph size as a proxy for task labels. DISGEN employs dual-view augmentations and a theoretically-grounded decoupling loss to explicitly separate size-related information from task-relevant features. Experimental results across diverse datasets and GNN backbones demonstrate that DISGEN consistently outperforms state-of-the-art methods, particularly on large-scale test graphs.

Introduction

While GNNs are theoretically designed to handle graphs of any size, they suffer from a significant performance drop when test graphs are substantially larger than training graphs. This is a major hurdle because training on massive graphs is often computationally prohibitive or limited by data availability.

The core issue is feature entanglement. GNNs often inadvertently learn to use graph size as a shortcut for classification. For example, if most "toxic" molecules in a training set happen to be small, the model might learn that "small = toxic." When it encounters a large toxic molecule at test time, it fails. Existing methods try to simulate size shifts or use causal modeling, but they often fail to fully strip size information from the hidden representations, leading to sub-optimal generalization.

Methodology: The DISGEN Framework

DISGEN (Disentangled representation learning for size Generalization) is a training framework that can be applied to various GNN backbones. It consists of three main pillars designed to isolate task-relevant features from size-related biases.

1. Dual-View Augmentations

To teach the model what "size" and "task" look like independently, DISGEN creates two augmented views for every input graph:

  • Size-invariant view ($\mathcal{G}_i^{(1)}$): This view keeps the number of nodes the same but removes edges that most significantly change the label. By using a graph explainer tool (like PGExplainer), the framework identifies and removes task-critical edges, forcing the model to see the same size with a different semantic meaning.
  • Task-invariant view ($\mathcal{G}_i^{(2)}$): This view keeps the label the same but removes "insignificant" nodes to change the graph's size. This teaches the model that the task label remains constant regardless of the graph's scale.

2. Disentangled Representation Learning

As shown in the architecture below, the model uses shared GNN encoders to produce graph representations. These are then split into task-related ($t_i$) and size-related ($s_i$) components using separate neural network heads (NN1 and NN2).

The DISGEN framework architecture, illustrating the disentanglement of task-related and size-related representations using shared GNN backbones and a decoupling loss.

3. The Decoupling Loss ($L_d$)

The mathematical heart of DISGEN is the decoupling loss. To ensure that $t_i$ and $s_i$ do not share information, the authors introduce a loss based on the residual of a linear projection. If one representation can be easily predicted from the other using a linear map, they share too much information. DISGEN minimizes this shared information, providing theoretical guarantees that maximizing this residual effectively prevents the model from "cheating" by using size info to predict the task.

Experimental Setup

The framework was evaluated on six diverse real-world datasets, split specifically to test size generalization by training on the smallest 50% of graphs and testing on the largest 10%:

  • Molecules/Bio: BBBP, PROTEINS, NCI1, and FRANKENSTEIN.
  • NLP: GraphSST2 (sentiment analysis on grammar trees).
  • Social Networks: REDDIT-BINARY.

In these experiments, the "Large test" sets featured graphs up to ten times larger than those seen during training.

Key Results and Insights

DISGEN demonstrates superior generalization capabilities across all tested scenarios. By explicitly separating size from task features, the model avoids the "lazy learning" trap where size is used as a shortcut.

Performance comparison of DISGEN against various baselines across different GNN backbones (GCN, GIN, GT) on multiple datasets, highlighting significant improvements in size generalization.
  • Superior Generalization: DISGEN outperformed state-of-the-art baselines (like SSR and CIGAV2) by up to 6% on large test graphs.
  • Model Agnostic: The framework proved effective across various backbones, including GCNs, GINs, and Graph Transformers. On average, DISGEN provided an improvement of 2.50% on small test graphs and 6.64% on large test graphs.
  • Ablation Success: Ablation studies confirmed that both the dual-view augmentations and the decoupling loss are necessary; removing either led to significant performance drops.

Conclusion

DISGEN addresses the critical challenge of size generalization in GNNs through a principled disentanglement approach. While the framework currently relies on a pre-trained explainer for augmentations and focuses on linear decoupling, it sets a strong foundation for future work. Potential extensions include non-linear decoupling methods (such as Mutual Information minimization) and applying the framework to more complex tasks like link prediction or regression.

Summary updated

BibTeX
@inproceedings{huang2024enhancing,
  author = {Zheng Huang and Qihui Yang and Dawei Zhou and Yujun Yan},
  title = {{Enhancing Size Generalization in Graph Neural Networks through Disentangled Representation Learning}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=0NdU4y9dWC},
}
Figure