Manuscript Offprint

arXiv:2608.25166

The Changing Geometry of Grammar: Dimensionality and Neighborhood Reorganization across Transformer Layers

Samuele Vallisa, Federico Ravenda, Claudio Palominos, Rui He, Andrea Raballo, Antonietta Mira, Philipp Homan, Wolfram Hinzen

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Transformer representations describe trajectories through high-dimensional vector spaces, which are shaped dynamically as tokens incorporate relational context across layers. Such data tend to concentrate on lower-dimensional sub-manifolds, a form of compression quantified by the Intrinsic Dimensionality (ID), the minimum number of independent variables needed to represent them without significant information loss. In this work, we ask whether the grammatical role of tokens, as marked by their part-of-speech (PoS) tag, shapes the local geometry of this manifold. To this end: (1) We investigate the layer-wise evolution of ID, finding that closed-class items expand earlier and collapse sooner than open-class ones; (2) We show its expansion and contraction to be explained by changes in the neighborhood structure, and hence in the relations between words within a sentence; (3) We compare encoders (ModernBERT, bigbird-roberta-large) and decoders (gamma-2-2B, Llama-3.2-3B), finding that the two families evolve differently across layers, consistently with how each integrates context; (4) We show that geometric features alone recover a token's grammatical role, and use them to interpret how the semantic content of each PoS evolves across layers in a downstream classification task 1^{1}.

1 Introduction & Related Works

Despite their widespread deployment, many properties of transformer models remain poorly understood. A substantial body of work has addressed this opacity through the geometry of inter-

nal representations, which, despite living in high-dimensional spaces, concentrate on or near lower-dimensional manifolds (Cai et al., 2021), with the Intrinsic Dimension (ID) of activations relating to information-theoretic compression (Cheng et al., 2023). The partition between open-class and closed-class items is among the most robust in linguistic typology, and the two classes differ precisely in where their content originates: content words denote lexically, function words contribute relationally and are near/vacuous in isolation. If contextualization is the mechanism by which a transformer resolves grammatical dependencies, the two classes should not traverse the network alike. Two findings support this: function words exhibit low self-similarity across contexts (Ethayarajh, 2019), and ID reveals a high-dimensional abstraction phase in decoders at the sequence level (Cheng et al., 2025). We bring the analysis to the token level and condition it on parts-of-speech (PoS) distinctions, asking whether function and content words trace distinct geometric trajectories through the network. The main contributions of this work are: (1) PoS-conditional variants of two geometric descriptors: a new closed-form conditional ID estimator for arbitrary token subsets, and a token-level Information Imbalance (II) (Glielmo et al., 2022) tracking how neighborhood structure is reorganized across layers. (2) Evidence that content and function words trace distinct trajectories, and that contractions and expansions of the conditional ID trace back to identifiable reorganizations of the local neighborhood. (3) A comparison of encoders and decoders (ModernBERT, bigbird, Gemma-2-2B, Llama-3.2-3B) showing

∗^{*}The first two authors contributed equally to this work.

1^{1}Github Repository

♡ the coupling between ID and neighborhood reorganization anchored to the last layer in the former and to the input layer in the latter, consistently with their training objectives. (4) A demonstration that these trajectories are predictive of grammatical role: a logistic regression on geometric features alone separates content from function words and recovers fine-grained PoS categories, while layer-wise accuracy on a downstream task tracks the ID and II profiles, tying gains in semantic informativeness to identifiable geometric reorganizations.

References (15)