Anisotropy Is Inherent to Self-Attention in Transformers

Nathan Godey, Éric Villemonte de la Clergerie, Benoît Sagot

Introduction

Anisotropy—the phenomenon where hidden representations in a model reside within a narrow cone—is a recognized "degeneration" problem in Transformer-based models. Historically, this clustering was attributed to the nature of natural language data, specifically the "long tail" of rare tokens that supposedly forces representations away from the origin during cross-entropy optimization. This study challenges that view, demonstrating that anisotropy is an inherent feature of the self-attention mechanism itself, emerging across diverse modalities as a byproduct of learning "sharp" attention patterns.

Methodology

The researchers conducted a multi-faceted empirical investigation:

  1. Cross-Modality Audit: Measuring anisotropy in models where "rare token" issues are minimized or absent, including character-level language models (e.g., CANINE, ByT5) and non-textual models for Speech (wav2vec 2.0) and Vision (ViT, BEiT).
  2. Untrained Stress Test: Analyzing a single, randomly initialized Transformer block's response to manual input "drift" to observe how the architecture's mathematical structure amplifies clustering.
  3. Training Dynamics Tracking: Utilizing the MultiBERT suite to observe the evolution of Query ($Q$) and Key ($K$) distributions via Singular Value Decomposition (SVD) over millions of training steps.

Key Findings

Cross-Modality Prevalence

The investigation revealed that anisotropy is not confined to natural language processing. Speech and vision Transformers consistently exhibited high average cosine similarity across their layers, as shown in the following figure.

Average cosine similarity across layers for speech and vision Transformer models, demonstrating widespread anisotropy.

Crucially, this phenomenon appears specific to the Transformer architecture. When examining standard Convolutional Neural Networks (CNNs) such as ResNet and ConvNeXt, the representations remained largely isotropic, with cosine similarities dropping toward zero after the initial layers.

Average cosine similarity in CNN-based vision models, showing significantly lower anisotropy compared to Transformers.

The Role of "Sharp" Attention

The study identifies a fundamental link between anisotropy and the functional requirements of self-attention. To achieve high performance, Transformers must learn "sharp" attention maps—focusing intensely on specific tokens rather than blurring across many. Mathematically, this is achieved by aligning Query and Key vectors in specific directions to increase their scalar products. This parallel "drifting" of $Q$ and $K$ distributions during training is what manifests as anisotropy in the final hidden states.

Conclusion

By demonstrating that anisotropy persists in character-level models and across modalities like speech and vision, this work refutes the "rare token" theory. Instead, anisotropy is revealed as a structural consequence of the self-attention mechanism's drive toward sharp attention patterns. Future research may focus on architectural revisions that decouple high-performance attention from geometric representation distortion, potentially leading to more efficient latent spaces.

Summary updated

BibTeX
@inproceedings{godey2024anisotropy,
  author = {Nathan Godey and Éric Villemonte de la Clergerie and Benoît Sagot},
  title = {{Anisotropy Is Inherent to Self-Attention in Transformers}},
  booktitle = {EACL},
  year = {2024},
  url = {https://openreview.net/forum?id=IYO6MBlfLv},
}
Figure