TL;DR
This paper introduces a simple yet effective "centering" modification to the self-attention mechanism in Transformers and Graph Neural Networks (GNNs) to combat the "oversmoothing" problem. By adjusting the softmax output to sum to zero instead of one, they demonstrate significant improvements in performance for weakly supervised semantic segmentation and enable the training of much deeper GNNs.
What Problem Does This Paper Address?
Deep learning models, particularly Transformers and GNNs, often suffer from a phenomenon called "oversmoothing." In Transformers, this means that as data passes through many layers, the representations of different input tokens become increasingly similar, losing their distinctiveness. Similarly, in GNNs, node embeddings tend to converge to a similar state after multiple message-passing steps, hindering performance. This oversmoothing is particularly problematic for tasks requiring fine-grained detail, like semantic segmentation, and limits the depth of GNNs that can be effectively trained. Existing solutions often involve complex architectural changes or multiple training phases, which this paper aims to simplify.
Methods
The core contribution of this paper is a novel "centering" term applied to the softmax function within the self-attention mechanism. The standard softmax function ensures that the output probabilities for a given token sum to 1. The authors propose modifying this by adding an offset, specifically setting the sum to 0 (achieved by a $\gamma = -1$ offset). This seemingly small change has a significant impact on the singular values of the attention matrices.
Mathematically, the standard self-attention is expressed as $S(X; W) = \text{softmax}(\frac{XW_Q(XW_K)^T}{\sqrt{d}})XW_V$. The proposed modification is $S(X; W) = \text{softmax}(\frac{XW_Q(XW_K)^T}{\sqrt{d}} + \gamma \mathbf{1})XW_V$, where $\mathbf{1}$ is a matrix of ones and $\gamma$ is the offset parameter. By setting $\gamma = -1$, the authors effectively center the softmax output.
This modification is applied to both Transformer architectures (Pre-LN, Post-LN, and ResiDual variants) and GNNs, where the self-attention matrix is analogous to a normalized adjacency matrix.
Datasets
The paper evaluates its method on several standard datasets:
- Weakly Supervised Semantic Segmentation (WSSS):
- PASCAL VOC 2012 dataset, augmented with the SBD dataset. This dataset consists of 10,582 training images, 1,449 validation images, and 1,456 test images, using only image-level labels for training.
- Graph Neural Networks (GNNs):
- Citation Networks: Cora and CiteSeer.
- Wikipedia Article Networks: Chameleon and Squirrel.
The paper also mentions using randomly initialized Transformers for simulations.
Key Insights and Ideas
- Oversmoothing as a Rank Collapse: The paper provides a theoretical analysis suggesting that oversmoothing in Transformers is linked to the attention matrices converging to a low-rank matrix (specifically, rank 1) as the network depth increases. This is due to the properties of the softmax function and the singular values of the attention matrices.
- The Power of Centering: The simple act of centering the softmax output (making the sum of probabilities zero instead of one) is shown to be remarkably effective in mitigating oversmoothing. This modification directly impacts the spectral properties of the attention matrices, preventing them from collapsing to a low rank.
- Unified Solution: The proposed centering term is shown to be beneficial for both Transformers and GNNs, addressing a common problem across different architectures that utilize similar aggregation mechanisms.
- Simplicity is Key: The paper emphasizes that their solution is a simple correction term that can be easily integrated into existing architectures without requiring complex architectural changes or multiple training stages.
Key Results
- Weakly Supervised Semantic Segmentation (WSSS): The proposed method achieves state-of-the-art results on the PASCAL VOC 2012 dataset, outperforming elaborate baseline methods. Specifically, they report an mIoU of 72.5 and 72.9 on validation and test sets, surpassing the previous state-of-the-art single-stage method. Qualitative results show improved object boundaries in segmentation masks.
- Graph Neural Networks (GNNs): The centering term enables the training of much deeper GNNs (up to 32 layers) with improved accuracy compared to vanilla GCNs and existing methods designed to combat oversmoothing, such as LayerNorm, PairNorm, and ContraNorm. For instance, on the Cora dataset with 32 layers, their method achieves 52.12% accuracy, significantly better than other methods.
- Simulations: Experiments with randomly initialized Transformers (Pre-LN, Post-LN, ResiDual) demonstrate that the rank of the output matrix collapses to 1 as depth increases when $\gamma > -1$, but this is avoided when $\gamma \le -1$, validating the effectiveness of the centering term.
Limitations and Future Work
- Theoretical Analysis Scope: The theoretical analysis of oversmoothing primarily focuses on the initialization phase and simpler Transformer architectures without normalization layers and residual connections. While simulations show the problem's presence in more complex variants, a deeper theoretical understanding throughout training would be beneficial.
- Offset Parameter Analysis: While the paper focuses on $\gamma = -1$, they suggest that other values of the offset might also be effective, and further simulations were conducted to understand the degree of oversmoothing.
- Inductive Bias: Future work could explore the effect of the centering term on the inductive bias and priors of the resulting models using tools like NNGP and NTK kernels.
- Training Dynamics: Analyzing the effect of the offset parameter on oversmoothing throughout the entire training process, not just at initialization, is suggested as an interesting future direction.
Summary updated