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

The geometry of hidden representations of large transformer models

Lucrezia Valeriani, Diego Doimo, Francesca Cuturello, Alessandro Laio, Alessio Ansuini, Alberto Cazzaniga · DOI

Abstract: Large transformer models, despite their success, remain difficult to interpret. This study analyzes the geometric properties of hidden representations across various architectures and modalities, including protein sequences, images, and text. By measuring the intrinsic dimension (ID) of data manifolds at each layer, the researchers identify a universal three-phase computational strategy: expansion, compression into a "semantic bottleneck," and reconstruction. This geometric signature provides an unsupervised method for identifying the most semantically rich layers for downstream tasks, often outperforming the standard practice of using the final hidden layer.

Introduction

Despite the massive success of transformers in natural language processing, computer vision, and bioinformatics, they are often treated as "black boxes." A fundamental challenge in the field is understanding where and how these models store semantic information. Practitioners frequently default to using the final hidden layer for downstream tasks, but in models trained via self-supervision—such as Masked Language Modeling—the final layer is often specialized for reconstructing specific input tokens rather than maintaining abstract concepts. This paper, presented at NeurIPS 2023, explores whether a geometric signature exists that can identify which layers have learned the most meaningful representations of data.

Methodology

The researchers utilize two primary geometric metrics to probe the hidden layers of models like ESM-2 (proteins), iGPT (images), and Llama-2 (text):

  1. Intrinsic Dimension (ID): Using the TwoNN estimator, the authors calculate the minimum number of variables required to describe the data manifold at each layer. For example, if a 1024-dimensional vector space only requires 10 variables to describe the data's shape, its ID is 10. A lower ID suggests that the data has been compressed into a more structured, abstract form.
  2. Neighborhood Overlap ($\chi$): This metric measures the stability of the data's local structure. It tracks how much the "neighbors" of a data point change from one layer to the next. A low overlap signals a major rearrangement of the data as it passes through the network.

The Three-Phase Computational Strategy

The study uncovers a universal "arc" in the transformation of data as it moves through a transformer's layers. This journey consists of three distinct phases:

  • Phase 1: Expansion. In the early layers, the ID peaks. The model acts similarly to a kernel method, projecting data into a high-dimensional space to resolve complex features and "unfold" the input.
  • Phase 2: Compression. The ID drops significantly, reaching a local minimum or plateau. This is the "semantic bottleneck," where the model discards noise and retains abstract concepts (e.g., identifying the category of an object rather than its raw pixel values).
  • Phase 3: Reconstruction. The ID rises again as the model prepares to satisfy its training objective, such as predicting a missing token or pixel. The representations become more specialized to the input format and less abstract.

Key Insights and Results

The "Sweet Spot" for Downstream Tasks

The layers corresponding to the lowest ID (the semantic bottleneck) are consistently the most semantically rich. In protein models (ESM-2), these intermediate layers captured remote homology—evolutionary relationships between proteins—much better than the final layer. Utilizing these bottleneck layers improved homology search accuracy by approximately 6% without any additional training.

Scale and Symmetry

As models increase in parameter count, the initial expansion peak becomes higher, yet the ID within the semantic bottleneck remains remarkably stable. This suggests a "consensus" dimensionality for specific types of data regardless of model size. Furthermore, in large-scale models like iGPT-L, the ID profile is nearly symmetric, suggesting that these transformers function like sophisticated autoencoders where the first half encodes and the second half decodes.

Modality Differences

While proteins and images follow a relatively clean expansion-compression-reconstruction arc, preliminary analysis of Llama-2-70b on text data revealed a more complex "triple peak" structure. This suggests that human language may require multiple levels of abstraction and reconstruction compared to other data types.

Conclusion

This research offers a powerful, unsupervised diagnostic tool for AI engineers. By identifying the geometric bottleneck of a model, researchers can select the most effective features for downstream tasks without relying on labeled data or trial-and-error. The discovery of a universal geometric strategy across diverse modalities suggests that the "bottleneck" is a fundamental requirement for transformers to learn abstract meaning.

Summary updated

BibTeX
@inproceedings{valeriani2023geometry,
  author = {Lucrezia Valeriani and Diego Doimo and Francesca Cuturello and Alessandro Laio and Alessio Ansuini and Alberto Cazzaniga},
  title = {{The geometry of hidden representations of large transformer models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=cCYvakU5Ek},
}
Figure