Uncovering hidden geometry in Transformers via disentangling position and context

Abstract

Transformers are widely used to extract semantic meanings from input tokens, yet they usually operate as black-box models. In this paper, we present a simple yet informative decomposition of hidden states (or embeddings) of trained transformers into interpretable components. For any layer, embedding vectors of input sequence samples are represented by a tensor h ∈ RC × T × d. Given embedding vector hc,t ∈ Rd at sequence position t T in a sequence (or context) c C, extracting the mean effects yields the decomposition \[ hc,t = μ + post + ctxc + residc,t \] where μ is the global mean vector, post and ctxc are the mean vectors across contexts and across positions respectively, and residc,t is the residual vector. For popular transformer architectures and diverse text datasets, empirically we find pervasive mathematical structure: (1) (post)t forms a low-dimensional, continuous, and often spiral shape across layers, (2) (ctxc)c shows clear cluster structure that falls into context topics, and (3) (post)t and (ctxc)c are mutually nearly orthogonal. We argue that smoothness is pervasive and beneficial to transformers trained on languages, and our decomposition leads to improved model interpretability.

0

Turn this paper into a full lesson

ArcXiv compiles a staged curriculum from this paper: 8-12 lessons across beginner → advanced, synthesised section guides, visuals, flashcards, a quiz, exercises, and on-demand deep dives per section. Grounded in the abstract, never invented.

Discussion (0)

Sign in to join the discussion.

Loading comments…