Shared Global and Local Geometry of Language Model Embeddings

Andrew Lee, Fernanda Viégas, Martin Wattenberg

TL;DR

This paper reveals that token embeddings in large language models (LLMs) from the same family share surprisingly similar global and local geometric structures. This geometric alignment allows for the transfer of "steering vectors" – vectors that control model behavior – between different LLMs, even those with varying dimensions, opening new avenues for model interpretability and efficiency.

What Problem Does This Paper Address?

As LLMs grow in size and complexity, understanding their internal representations and how they encode information becomes increasingly challenging. Researchers have hypothesized that models might converge on similar representations, but empirical evidence for this across different LLMs, especially contemporary ones, has been limited. Specifically, the geometric properties of token embeddings – the numerical representations of words or sub-word units – and how these properties are shared or differ across models are not well understood. This lack of understanding hinders our ability to interpret model behavior, transfer knowledge between models, and develop more efficient training strategies. The paper aims to bridge this gap by systematically analyzing the geometric similarities in token embeddings across various LLMs.

Methods

The authors employ two primary methods to analyze the geometry of token embeddings:

  1. Global Geometry Analysis: They measure the "global" similarity by computing pairwise cosine similarities between token embeddings from different models and then calculating the Pearson correlation between these similarity matrices. This approach assesses if tokens maintain similar relative orientations across models.
  2. Local Geometry Analysis:
    • Locally Linear Embeddings (LLE): They use LLE to approximate the local structure of token embeddings. LLE reconstructs each token embedding as a weighted sum of its k-nearest neighbors. By comparing the LLE weights across models, they can determine if local neighborhoods are preserved.
  3. Intrinsic Dimension (ID): They define a simple measure for the intrinsic dimension of token embeddings. This involves using PCA on a token's k-nearest neighbors and determining the number of principal components needed to explain a certain percentage of variance. This metric helps understand the dimensionality of the local embedding space.

Based on these findings, they introduce EMB2EMB, a method to transfer steering vectors. This involves fitting a linear transformation between the unembedding spaces of two models and applying this transformation to a steering vector from the source model to use it in the target model.

Datasets

The paper uses publicly available language models and their associated tokenizers. The specific models analyzed are from three families:

  • GPT2: (small, medium, large, xl)
  • Llama3: (1B, 3B, 8B, 11B-Vision, 70B)
  • Gemma2: (2B, 9B, 27B)

The authors also leverage ConceptNet, a large knowledge graph, to measure the semantic coherence of token clusters.

Key Insights and Ideas

  • Shared "Global" Orientation: Token embeddings within the same LLM family (e.g., different sizes of GPT2 or Llama3) tend to have similar relative orientations. This suggests a common underlying structure in how these models represent words globally.
  • Shared "Local" Structure: The local geometric relationships between tokens are also remarkably similar across models within a family. This is evidenced by both LLE weight comparisons and intrinsic dimension analysis.
  • Intrinsic Dimension and Semantic Coherence: Tokens with lower intrinsic dimensions tend to form more semantically coherent clusters. This implies that the "simpler" or lower-dimensional representations are more tightly organized around specific meanings.
  • Untied Embeddings Reveal Hidden State Convergence: For models with "untied" embeddings (where embedding and unembedding matrices are separate), global similarity is strong in the unembedding space but weaker in the embedding space. This suggests that while initial embeddings might differ, the final hidden states before unembedding converge across models.
  • Steering Vector Transferability: The geometric alignment of unembedding spaces is sufficient to linearly transfer steering vectors between models, even if they have different dimensions. This is a significant finding for model interpretability and control.

Key Results

  • High Pearson Correlations: Pairwise distance matrices of token embeddings from models within the same family show high Pearson correlations (often near 1.0), indicating strong global geometric similarity.
  • LLE Similarity: Cosine similarities between LLE weights for tokens across models are generally high, suggesting similar local embedding structures.
  • Negative Correlation between ID and Coherence: A significant negative Spearman correlation is observed between intrinsic dimension and semantic coherence score, particularly for GPT2 and Llama3 models. This confirms that lower intrinsic dimensions lead to more semantically coherent clusters. For example, GPT2-Medium shows a correlation of -0.67 (p < 1e-66).
  • Successful Steering Vector Transfer: Experiments demonstrate that steering vectors transferred from one Llama3 model to another (e.g., from 1B to 8B) produce similar behavioral changes as original steering vectors. Similarly, transferred steering vectors for GPT2 models also show comparable effects to original ones.

Limitations and Future Work

  • Gemma2 Anomaly: Gemma2 models showed lower global and local similarity compared to GPT2 and Llama3. The authors speculate this might be due to a higher number of special tokens, emojis, and non-English tokens in Gemma2's vocabulary, making it less suitable for comparison with ConceptNet.
  • Understanding ID Drivers: The paper identifies that tokens with lower intrinsic dimensions are more semantically coherent but does not fully explain why certain tokens acquire lower IDs. This is suggested as an exciting area for future work.
  • Training Data Influence: While the authors speculate that training data plays a role in global similarity, they only provide preliminary evidence by comparing models with different tokenizers trained on different datasets. Further investigation is needed.
  • Model Efficiency: The authors suggest that their findings could inform more efficient pre-training by reusing token embeddings across models, but this remains a speculative application.
  • Hidden State Geometry: The relationship between the geometry of embeddings and hidden states is highlighted as a promising future research direction.

Summary updated

Abstract

Researchers have recently suggested that models share common representations. In this work, we find similar global and local geometric properties of token embeddings across language models of the same family. First, we find that often, the token embeddings of models within the same family share similar relative orientations. We empirically demonstrate that this allows steering vectors from one language model to be reused for another model, despite the two models having different dimensions. Next, we study the local geometry by first defining a simple metric for the intrinsic dimension of each token embedding. We find that tokens take on a range of different intrinsic dimensions, giving us hints as to what the embedding space looks like. We qualitatively show that tokens with lower intrinsic dimensions often have semantically coherent clusters, while those with higher intrinsic dimensions do not. Using intrinsic dimension, we again find that the local geometry of each token is similar across language models.
BibTeX
@inproceedings{lee2025shared,
  author = {Andrew Lee and Fernanda Viégas and Martin Wattenberg},
  title = {{Shared Global and Local Geometry of Language Model Embeddings}},
  booktitle = {COLM},
  year = {2025},
  url = {https://openreview.net/forum?id=aJDykpJAYF},
}
Figure