Graph External Attention Enhanced Transformer

Jianqing Liang, Min Chen, Jiye Liang

Abstract

Graph Neural Networks (GNNs) and Graph Transformers (GTs) have become the standard for processing relational data. However, existing architectures often treat graphs as isolated entities, failing to capture structural correlations across different graphs in a dataset. Furthermore, the quadratic complexity of standard self-attention limits scalability. This paper presents the Graph External Attention Enhanced Transformer (GEAET), which introduces a novel "external attention" mechanism. By leveraging shared, learnable external memory units, GEAET captures global patterns across graphs with linear computational complexity. Our evaluation across 11 benchmarks, including the Long Range Graph Benchmark (LRGB), demonstrates that GEAET achieves state-of-the-art results while effectively mitigating common issues like over-smoothing and over-squashing.

Introduction

Relational data processing via GNNs faces two primary hurdles: over-smoothing, where node features become indistinguishable in deep networks, and over-squashing, where information is lost when propagated over long distances. While Graph Transformers (GTs) were introduced to address these by allowing all-to-all node attention, they introduce a new set of problems. Primarily, they rely on internal self-attention, treating every graph as an independent "island" and ignoring shared structural motifs (e.g., common functional groups in molecules). Additionally, the $O(N^2)$ complexity of self-attention makes them computationally expensive for large-scale applications.

Methodology

The GEAET Architecture

GEAET utilizes a hybrid "triple-threat" architecture. As shown in the figure below, the model processes graph data through three parallel branches to capture diverse structural information:

  1. Message-passing GNN: Focuses on local neighborhood structures.
  2. Standard Transformer: Captures global interactions within the specific graph instance.
  3. Graph External Attention Network (GEANet): Captures inter-graph correlations using the proposed external attention mechanism.
The GEAET architecture processes node and edge embeddings through three parallel modules: a Transformer, a Message-passing GNN, and the proposed GEANet.

Graph External Attention (GEA)

The core innovation of GEAET is the Graph External Attention (GEA) mechanism. Unlike standard self-attention, which computes attention between nodes in the same graph ($Query \times Key^T$), GEA computes attention between input nodes and a set of external, learnable units ($U$). These units serve as a shared memory that stores global patterns across the entire dataset.

Comparison between (a) standard Transformer self-attention and (b) the proposed Graph External Attention mechanism, which utilizes external learnable units (Us, Unk, etc.) to capture global correlations.

This shift from $N$-to-$N$ attention to $N$-to-$S$ attention (where $S$ is a fixed number of external units) reduces computational complexity from $O(N^2)$ to $O(N)$. To ensure stability, the model employs Double Normalization across both the rows and columns of the attention matrix.

Experimental Results

Performance Benchmarks

GEAET was evaluated on 11 diverse datasets, achieving state-of-the-art (SOTA) performance on CIFAR10 and MNIST (graph-based image benchmarks). On the Long Range Graph Benchmark (LRGB), GEAET significantly outperformed previous models. For instance, on the PascalVOC-SP task, it achieved an F1 score of 0.4585, a substantial improvement over the previous best of 0.3966 held by Exphormer.

Robustness and Interpretability

  • Over-squashing: On the synthetic TreeNeighbourMatch task, GEAET maintained high accuracy even as tree depth increased, whereas standard GNNs failed beyond a depth of 4.
  • Structural Focus: Visualizations indicate that GEAET's attention maps are more chemically intuitive than standard Transformers, focusing on significant heteroatoms (Nitrogen, Oxygen) and functional group bonds.
  • Positional Encodings: Unlike many GTs that require complex Positional Encodings (PE) to function, GEAET remains highly effective even without them, suggesting the external units naturally capture structural essence.

Conclusion

GEAET represents a significant step forward in graph representation learning by moving beyond internal self-attention. By capturing inter-graph correlations through a linear-complexity external attention mechanism, the model achieves superior performance and scalability. While the parallel architecture currently introduces some memory overhead, its ability to learn global structural knowledge makes it a powerful tool for complex relational datasets. Future work will focus on optimizing the implementation to reduce the footprint of the multi-branch design.

Summary updated

BibTeX
@inproceedings{liang2024graph,
  author = {Jianqing Liang and Min Chen and Jiye Liang},
  title = {{Graph External Attention Enhanced Transformer}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=0rV7VIrcjX},
}
Figure