Gophormer: Ego-Graph Transformer for Node Classification

Jianan Zhao, Chaozhuo Li, Qianlong Wen, Yiqi Wang, Yuming Liu, Hao Sun, Xing Xie, Yanfang YearXiv 2021

Abstract

Gophormer is a novel Transformer-based model designed for node classification that shifts the focus from the entire graph to localized "ego-graphs." By combining a neighborhood sampling strategy (Node2Seq) with proximity-enhanced attention, it overcomes the scalability and data-scarcity issues that have previously hindered Transformers in the graph mining domain.

Introduction

While Transformers have revolutionized Natural Language Processing and Computer Vision, they have struggled to outperform Graph Neural Networks (GNNs) in graph-related tasks. Standard GNNs often suffer from "over-smoothing," where node features become indistinguishable after a few layers, and "over-squashing," which limits their ability to capture long-range interactions.

Existing "Graph Transformers" attempt to address these issues by treating the entire graph as a sequence. However, this approach faces two major hurdles:

  1. Scalability: Global self-attention has a quadratic complexity relative to the number of nodes, making it impractical for large-scale graphs.
  2. Structural Noise and Data Scarcity: Treating all nodes as fully connected can introduce noise from irrelevant distant neighbors. Furthermore, node classification often involves only a single graph, providing few sequences for a data-hungry Transformer to learn from.

Methodology

Gophormer introduces several architectural innovations to adapt Transformers for graph data effectively.

Overview of the Gophormer architecture, illustrating the Node2Seq sampling process, proximity encodings, and the Transformer-based classification pipeline.

Node2Seq (Ego-Graph Sampling)

Instead of processing the entire graph, Gophormer samples an "ego-graph" (a local neighborhood) for each node. This transforms the graph into a set of sequences, serving as a natural data augmentation technique. Different samples of the same neighborhood can be generated during training, increasing the diversity of the training data and helping the model generalize better.

Proximity-Enhanced Multi-Head Attention (PE-MHA)

Standard Transformers rely solely on feature similarity. Gophormer introduces a structural bias by encoding the "proximity" between nodes using normalized adjacency matrices of different orders. This allows the model to consider both feature relevance and topological distance, effectively weighing neighbors based on how close they are in the graph topology.

Global Nodes and Consistency Regularization

To maintain global context and prevent the model from becoming too localized, virtual global nodes are added to every ego-graph. These nodes are shared across all samples and act as a repository for graph-wide context. Additionally, the model employs consistency regularization during training to ensure that different samples of the same node yield similar predictions, enhancing stability.

Experiments and Results

The model was evaluated on six benchmark datasets, including citation networks (Cora, Citeseer, Pubmed, DBLP) and social networks (Blogcatalog, Flickr).

Performance and Stability

Gophormer consistently outperformed state-of-the-art GNNs (e.g., GCN, GAT, and APPNP) and existing Graph Transformers (e.g., SAN, Graphormer). Notably, on the Blogcatalog social network, Gophormer achieved an accuracy of 96.03%, a significant improvement over GCN's 78.81%.

Comparison of training and validation accuracy over epochs for full-graph training versus the proposed Node2Seq paradigm on Cora and Citeseer datasets.

As shown in the training trajectories, the Node2Seq paradigm provides much smoother and higher-performing results compared to traditional full-graph training. This approach also improves scalability, as it operates on fixed-size ego-graphs rather than the full graph, avoiding memory limitations on large datasets where traditional Transformers might fail.

Conclusion

Gophormer provides a scalable, high-performance framework for applying Transformers to graphs. By focusing on local neighborhoods and utilizing sampling as a form of data augmentation, it addresses the core challenges of scalability and data scarcity in graph mining. While the model shows sensitivity to hyperparameters like the number of global nodes, it represents a significant step forward in hybridizing structural and feature-based learning for node classification.

Summary updated

BibTeX
@misc{zhao2021gophormer,
  author = {Jianan Zhao and Chaozhuo Li and Qianlong Wen and Yiqi Wang and Yuming Liu and Hao Sun and Xing Xie and Yanfang Ye},
  title = {{Gophormer: Ego-Graph Transformer for Node Classification}},
  year = {2021},
  eprint = {2110.13094},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2110.13094},
}
Figure