Graph Convolutions Enrich the Self-Attention in Transformers!

Jeongwhan Choi, Hyowon Wi, Jayoung Kim, Yehjin Shin, Kookjin Lee, Nathaniel Trask, Noseong Park

TL;DR

Deep Transformers often suffer from "oversmoothing," where token representations become nearly identical across layers, limiting model depth and performance. This paper introduces Graph-Filter-based Self-Attention (GFSA), which redesigns attention as a learnable graph filter that incorporates high-frequency components to preserve feature diversity. By adding just a few parameters, GFSA consistently boosts performance across computer vision, NLP, speech, and graph tasks.

What Problem Does This Paper Address?

Despite their success, deep Transformers hit a wall: as you add more layers, the output representations of different tokens tend to converge toward a single, indistinguishable value. This phenomenon, known as oversmoothing (or rank collapse), is a well-known issue in Graph Neural Networks (GNNs) but is equally problematic for Transformers.

The authors argue that standard self-attention acts primarily as a low-pass filter. It averages information from neighboring tokens, which effectively smooths out the "signal." While some smoothing is good for learning general features, too much of it destroys the unique information each token carries. The challenge is to enrich the attention mechanism so it can capture both local similarities and complex, high-order dependencies without exploding the computational cost.

Methods

The researchers bridge the gap between Transformers and Graph Signal Processing (GSP). They interpret the attention matrix $\bar{A}$ as a graph adjacency matrix and the self-attention operation as a simple graph convolution.

To fix the oversmoothing, they propose a more sophisticated graph filter:

  1. Polynomial Filtering: Instead of just using $\bar{A}$, they use a polynomial expression: $H = w_0I + w_1\bar{A} + w_K\bar{A}^K$. This includes an identity term ($I$) to preserve original features and a high-order term ($\bar{A}^K$) to capture long-range dependencies.
  2. Taylor Approximation: Calculating $\bar{A}^K$ is computationally expensive ($O(n^3)$). To keep the model efficient, the authors use a first-order Taylor approximation. This allows them to estimate the high-order effects using only $\bar{A}$ and $\bar{A}^2$, keeping the complexity manageable.
  3. Learnable Weights: The coefficients ($w_0, w_1, w_K$) are learnable. This allows each attention head to decide whether it needs to "smooth" (low-pass) or "sharpen" (high-pass) the features.

To further mitigate runtime overhead, they introduce a selective strategy, applying GFSA only to even-numbered layers, which maintains most of the performance gains while significantly reducing training time.

Datasets

The authors evaluated GFSA across a massive range of benchmarks to prove its generality:

  • NLP: GLUE benchmark (including CoLA, SST-2, MNLI), Penn Treebank, and WikiText.
  • Computer Vision: ImageNet-1k using DeiT, CaiT, and Swin Transformer backbones.
  • Graph Tasks: ZINC (molecular property regression), PCQM4Mv2, and the Long-Range Graph Benchmark (LRGB).
  • Speech: LibriSpeech (100h and 960h).
  • Code: Devign (defect detection) and Java clone detection.

Key Insights and Ideas

  • Attention is a Filter: The most profound insight is the formal treatment of self-attention as a low-pass graph filter. This allows researchers to apply decades of signal processing theory to Transformer architecture.
  • High-Frequency Matters: By visualizing the filter response, the authors show that standard Transformers almost entirely discard high-frequency information. GFSA restores these frequencies, which is key to preventing oversmoothing.
  • High-Order Dependencies: The $\bar{A}^K$ term captures "friends of friends" relationships. In a sentence, this helps the model understand relationships between words that aren't directly connected but are linked through a common context.
  • Minimal Overhead: The entire GFSA mechanism adds only tens to hundreds of parameters to models that already have millions. It is an extremely "cheap" upgrade in terms of memory.
Figure 1: Performance improvements (%) of our GFSA when integrated with different Transformer backbones in various domains. We achieve these results with only tens to hundreds of additional parameters to Transformers.

Key Results

GFSA delivered impressive gains across the board:

  • Image Classification: Improved DeiT-S top-1 accuracy on ImageNet-1k by 1.63%.
  • Natural Language Understanding: Boosted RoBERTa's performance on the CoLA dataset by 6.25%.
  • Speech Recognition: Achieved a 4.55% improvement in Word Error Rate (WER) on LibriSpeech.
  • Graph Regression: Reduced error (MAE) on the ZINC dataset by 4.03%.

Crucially, the visualizations in the paper confirm that GFSA successfully mitigates oversmoothing. As shown in Figure 2, the cosine similarity between token representations stays much lower in GFSA-equipped models compared to vanilla Transformers as the layers get deeper.

Figure 2: Visualizing how GFSA preserves feature diversity (lower cosine similarity) and high-frequency signals compared to standard DeiT.

Limitations and Future Work

  • Computational Complexity: While the Taylor approximation helps, calculating $\bar{A}^2$ still adds a slight overhead to the $O(n^2)$ attention mechanism. For very long sequences, this could become a bottleneck.
  • Environmental Impact: The authors briefly mention the carbon footprint of training larger models and suggest that future work should optimize GFSA for even better energy efficiency.
  • Advanced Filters: This paper uses a relatively simple polynomial filter. The authors suggest that exploring more complex graph filters (like ChebNet or Cayley filters) could yield even higher accuracy, albeit at a higher computational cost.

Summary updated

Abstract

Transformers, renowned for their self-attention mechanism, have achieved state-of-the-art performance across various tasks in natural language processing, computer vision, time-series modeling, etc. However, one of the challenges with deep Transformer models is the oversmoothing problem, where representations across layers converge to indistinguishable values, leading to significant performance degradation. We interpret the original self-attention as a simple graph filter and redesign it from a graph signal processing (GSP) perspective. We propose a graph-filter-based self-attention (GFSA) to learn a general yet effective one, whose complexity, however, is slightly larger than that of the original self-attention mechanism. We demonstrate that GFSA improves the performance of Transformers in various fields, including computer vision, natural language processing, graph-level tasks, speech recognition, and code classification.
BibTeX
@inproceedings{choi2024graph,
  author = {Jeongwhan Choi and Hyowon Wi and Jayoung Kim and Yehjin Shin and Kookjin Lee and Nathaniel Trask and Noseong Park},
  title = {{Graph Convolutions Enrich the Self-Attention in Transformers!}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=ffNrpcBpi6},
}
Figure