Introduction
Graph Neural Networks (GNNs) have traditionally operated under the assumption of homophily, where connected nodes are expected to share similar features or labels. This "birds of a feather flock together" principle leads many models to act as low-pass filters, smoothing node representations across edges. However, real-world graphs often exhibit heterophily, where connected nodes are dissimilar (e.g., in dating networks or molecular structures). In these scenarios, standard GNNs and Graph Transformers—which typically use purely positive attention weights via the softmax function—fail to capture the essential "high-frequency" information that distinguishes neighboring nodes.
To address this, we introduce SignGT, a Graph Transformer architecture featuring a novel Signed Self-Attention (SignSA) mechanism. By allowing attention weights to take both positive and negative values, SignGT can effectively represent complex relationships in heterophilous graphs, preserving critical differences between nodes.
Methodology: Embracing the Negative
The core innovation of SignGT lies in its ability to learn signed relationships between nodes, enabling it to act as both a low-pass and a high-pass filter as needed.
Signed Self-Attention (SignSA)
Standard self-attention mechanisms use softmax(QK^T), which constrains all attention weights to be positive. SignGT replaces this with Signed Self-Attention (SignSA). SignSA decouples the sign of the interaction from its magnitude. It uses the sign of the dot product between query and key vectors to determine semantic relevance: positive weights indicate similarity, while negative weights signify dissimilarity. By applying softmax to the absolute values of these scores and then re-applying the signs, the model maintains numerical stability while gaining the flexibility to push representations of dissimilar nodes apart.
Structure-aware Feed-Forward Network (SFFN)
While global self-attention captures long-range dependencies, it can sometimes overlook local graph topology. SignGT incorporates a Structure-aware Feed-Forward Network (SFFN) to inject neighborhood structural bias. Unlike standard feed-forward layers that treat nodes in isolation, SFFN utilizes a pre-computed $k$-hop propagation matrix to integrate local connectivity information. This hybrid approach ensures the model benefits from both global context and local structural cues without significantly increasing the number of learnable parameters.
Experimental Evaluation
SignGT was rigorously tested across 17 benchmark datasets, spanning node classification (e.g., Cora, Pubmed, Squirrel, Chameleon) and graph classification (e.g., NCI1, Mutagenicity).
Performance on Heterophilous Graphs
The model's strengths are most evident on datasets with high heterophily, such as Squirrel and Chameleon. In these cases, SignGT outperformed its unsigned counterpart by 27.99% and 31.09%, respectively. This dramatic improvement underscores the importance of signed weights in capturing high-frequency signals that standard "smoothing" models miss.
Comparison with State-of-the-Art
SignGT consistently outperformed recent advanced Graph Transformers, including NodeFormer and Specformer, as well as specialized GNNs like FAGCN and GloGNN. Qualitative analysis using t-SNE visualizations further confirmed that SignGT learns more discriminative representations, producing tighter and more distinct clusters of node labels compared to competing methods.
Conclusion and Future Directions
SignGT demonstrates that "negative" attention is a powerful tool for graph representation learning, particularly in heterophilous environments. By allowing the model to learn signed interactions and incorporating local structural bias, SignGT achieves state-of-the-art performance across a wide range of tasks.
A current limitation of the model is its $O(N^2)$ computational complexity due to global self-attention, which poses challenges for scaling to massive graphs. Future research will focus on developing linear-complexity variants of signed attention and exploring sampling strategies to bring the benefits of SignGT to web-scale datasets.
Summary updated