Too Much in Common: Shifting of Embeddings in Transformer Language Models and its Implications

Daniel Bis, Maksim Podkorytov, Xiuwen LiuNAACL 2021

Abstract

Transformer-based language models exhibit "anisotropy," where word embeddings cluster into a narrow cone rather than utilizing the full vector space. This paper demonstrates that this phenomenon is not an inherent degeneration but a "drift" caused by the common enemies effect during training. By simply centering these embeddings, their geometric spread is restored, leading to significant performance gains in word similarity tasks.

Introduction

Recent studies have identified a peculiar geometric property in models like BERT and GPT-2: their word embeddings are highly anisotropic. Instead of spreading uniformly across the high-dimensional space, vectors tend to point in a similar direction, occupying a "narrow cone." This is particularly detrimental for rare words, which often end up looking more like each other than the concepts they represent. While previous theories attributed this to "representation degeneration" from softmax loss, this work argues that the geometry is better described as a collective shift or drift.

The Common Enemies Effect

The authors propose the Common Enemies Effect as a theoretical explanation for this drift. During training with cross-entropy loss, the model attempts to "pull" the target word embedding toward the output state while "pushing" all other words in the vocabulary away. Because language follows Zipf’s Law, most words are rarely targets and are instead repeatedly pushed in the same direction. Over millions of steps, these embeddings drift together along a dominant axis.

Restoring Isotropy through Centering

To counteract this drift, the authors explore simple post-processing techniques including centering (subtracting the mean vector), scaled-centering, and principal component removal.

Figure 1: Singular value distribution for RoBERTa-lg. Centering the embeddings significantly flattens the singular value spectrum, indicating a more isotropic distribution.

As shown in Figure 1, the original embeddings for RoBERTa-lg have a highly skewed singular value distribution, dominated by a few directions. Centering the matrix (red line) restores a much more uniform spectrum, effectively "opening" the narrow cone and making the space more isotropic.

Visualizing the Drift

The impact of this drift is visible when projecting embeddings into lower dimensions. Rare words, which spend the most time being "pushed" due to their low frequency, exhibit distinct clustering patterns.

Figure 6: Visualization of embedding drift in RoBERTa-lg and GPT-2-12L. The color indicates the word's index in the vocabulary, with rare words (higher indices) appearing in yellow/green.

Figure 6 illustrates how embeddings for both masked (RoBERTa) and causal (GPT-2) models are shifted. Rare words (yellow/green) are often pushed to the periphery or clustered together, confirming that the observed "narrow cone" is an artifact of this uncentered cloud rather than a fundamental loss of representational capacity.

Key Results and Implications

The findings suggest that anisotropy is remarkably simple to fix. For RoBERTa-large, centering improved word similarity scores from 44.79 to 63.78 without any additional training. Furthermore, the isotropy score for BERT-base-uncased jumped from 0.39 to 0.98 (where 1.0 is perfectly spherical).

These results imply that the underlying semantic relationships are present but obscured by a global translation. Simple geometric normalization can unlock better performance and more meaningful representations, especially for the long tail of rare vocabulary terms. This suggests that future training objectives might benefit from mean-minimization regularizers to prevent this drift from occurring in the first place.

Conclusion

The "representation degeneration" in Transformers is largely a reversible geometric shift. By understanding the training dynamics that cause this drift—the common enemies effect—researchers can apply simple post-hoc corrections to restore the intended geometry of the embedding space, significantly improving the utility of these models for semantic tasks.

Summary updated

BibTeX
@inproceedings{bis2021too,
  author = {Daniel Bis and Maksim Podkorytov and Xiuwen Liu},
  title = {{Too Much in Common: Shifting of Embeddings in Transformer Language Models and its Implications}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2021},
  doi = {10.18653/v1/2021.naacl-main.403},
}
Figure