NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

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

Anton Razzhigaev, Matvey Mikhalchuk, Elizaveta Goncharova, Ivan V. Oseledets, Denis Dimitrov, Andrey Kuznetsov

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

Despite the ubiquity of Transformer models like BERT (encoders) and GPT (decoders), the internal geometry of their embedding spaces remains a "black box." Specifically, two properties are poorly understood: anisotropy (how much embeddings cluster in specific directions rather than filling space uniformly) and intrinsic dimension (the actual number of variables needed to represent the data). Previous research often treated these models as similar, but this paper investigates the dichotomy between encoders and decoders, seeking to understand how these geometric properties evolve during the training process.

Methodology

The authors employed two primary metrics to probe the models:

  1. Anisotropy via SVD: Singular Value Decomposition (SVD) was applied to embedding matrices. A high anisotropy score indicates that embeddings are "collapsed" into a narrow cone, whereas a low score suggests a more uniform, spherical distribution.
  2. Intrinsic Dimension (ID) via TWO-NN: To find the "true" dimensionality of the embeddings, the Two-Nearest Neighbors estimator was used. This method calculates ID based on the ratio of distances between a point and its two closest neighbors, avoiding the pitfalls of traditional PCA in high-dimensional manifolds.

Analysis was conducted using the enwik8 dataset, a 100-million-byte subset of English Wikipedia, across a wide range of pretrained models including BERT, RoBERTa, GPT-2, Llama-2, and Falcon.

The Anisotropy Dichotomy

A fundamental difference exists in how transformer encoders and decoders shape their data. Transformer decoders (generative models) show a unique "bell-shaped" anisotropy profile. Anisotropy is low at the input and output layers but peaks sharply in the middle layers, often approaching values of 1.0. In contrast, encoders maintain a much lower and more uniform anisotropy throughout, typically staying below 0.2.

Anisotropy profiles of decoders vs. encoders across normalized depth.

This suggests that the "clustering" of representations is a feature of the generative learning process itself. Anisotropy isn't static; it grows progressively as the model learns and eventually stabilizes, indicating that the model is actively organizing information into specific directional clusters in its middle layers.

The Expansion-Compression Cycle

The most striking finding is the "unfold then compress" dynamic observed during training. During the early stages of pretraining, the intrinsic dimension of embeddings increases (expansion). As training nears completion, the ID drops (compression). For example, in the Bloom-7B model, the averaged intrinsic dimension peaked at approximately 55 mid-training before compressing down to roughly 45 by the end of the pretraining phase.

Evolution of intrinsic dimension across pretraining steps for various transformer models.

This suggests models first try to map features to a complex, high-dimensional space to capture nuances before refining them into more efficient, compact concepts. These patterns were remarkably consistent across different model sizes, from 125M to 13B parameters.

Conclusion

Our analysis reveals that transformer decoders and encoders utilize fundamentally different geometric strategies. While decoders rely on a middle-layer anisotropy peak and a universal expansion-compression cycle, encoders maintain a more isotropic distribution. These insights into the "shape" of learning open new avenues for tailoring training approaches—perhaps by regularizing anisotropy or ID—to create more efficient models or to better understand the critical periods of representation learning.

Summary updated

BibTeX
@inproceedings{razzhigaev2024shape,
  author = {Anton Razzhigaev and Matvey Mikhalchuk and Elizaveta Goncharova and Ivan V. Oseledets and Denis Dimitrov and Andrey Kuznetsov},
  title = {{The Shape of Learning: Anisotropy and Intrinsic Dimensions in Transformer-Based Models}},
  booktitle = {EACL (Findings)},
  year = {2024},
  url = {https://openreview.net/forum?id=z09DI5CUuW},
}
Figure