The Shape of Learning: Anisotropy and Intrinsic Dimensions in Transformer-Based Models (2024)

Abstract: In this study, we present an investigation into the anisotropy dynamics and intrinsic dimension of embeddings in transformer architectures, focusing on the dichotomy between encoders and decoders. Our findings reveal that the anisotropy profile in transformer decoders exhibits a distinct bell-shaped curve, with the highest anisotropy concentrations in the middle layers. This pattern diverges from the more uniformly distributed anisotropy observed in encoders. In addition, we found that the intrinsic dimension of embeddings increases in the initial phases of training, indicating an expansion into higher-dimensional space. This fact is then followed by a compression phase towards the end of training with dimensionality decrease, suggesting a refinement into more compact representations. Our results provide fresh insights to the understanding of encoders and decoders embedding properties.

## introduction introduced by @xcite , the transformers have underpinned many breakthroughs, ranging from language modeling to text-to-image generation. as the adoption of transformers has grown, so has the pursuit to understand the intricacies of their internal mechanisms, particularly in the realm of embeddings. embeddings in transformers are intricate structures, encoding vast amounts of linguistic nuances and patterns. historically, researchers have mainly examined embeddings for their linguistic capabilities @xcite @xcite . yet, more nuanced properties lie beyond these traditional scopes, like anisotropy and intrinsic dimensionality, which can offer critical insights into the very nature and behavior of these embeddings. anisotropy, essentially representing the nonuniformity of a distribution in space, provides a lens, through which we can study orientation and concentration of the embeddings @xcite . a higher degree of anisotropy suggests that vectors are more clustered or directed in specific orientations. in contrast, the intrinsic dimension offers a measure of the effective data dimensionality, highlighting the essence of information that is captured by the embeddings. together, these metrics can serve as pivotal tools to probe into the black-box nature of transformers. our investigation uncovers the striking contrast in the anisotropy dynamics between transformer encoders and decoders. by analyzing the training phases of various transformer models, we shed light on the consistent yet previously unrecognized patterns of the anisotropy growth. even more, our analysis reveals a unique dynamic of the averaged intrinsic dimension across layers in decoders: an initial growth during the early stages of training is followed by a decline towards the end. this suggests a two-phase learning strategy, where the model initially tries to unfold information in higher dimensional spaces and subsequently compresses it into more compact concepts, possibly leading to more refined representations. ## results in this section, we present our empirical findings concerning the anisotropy dynamics and intrinsic dimensionality of transformer embeddings at different layers. our results span various pretrained transformer models, showcasing clear patterns in the behavior of encoders versus decoders, and illuminating the transformation of their properties during training. ## conclusion our exploration into the anisotropy dynamics and intrinsic dimensionality of transformer embeddings has brought significant distinctions between encoder and decoder transformers to light. notably, the intrinsic dimensionality showcases a twophased training behaviour, where models initially expand information into higher-dimensional spaces and then refine it into compact concepts towards the end of training. these insights not only deepen our understanding of transformer architectures but also suggest new avenues for tailoring training approaches in future nlp research.