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

Towards Measuring Representational Similarity of Large Language Models

Max Klabunde, Mehdi Ben Amor, Michael Granitzer, Florian Lemmerich

TL;DR

This paper investigates whether modern 7-billion-parameter large language models (LLMs) learn similar internal representations in their final layer across different tasks. By adapting representational similarity metrics (like Procrustes alignment and CKA) to decoder-only transformers, the authors find that LLM representations vary considerably across architectures and benchmarks. Crucially, they caution that representational similarity measures frequently disagree with one another, meaning researchers must be careful when drawing conclusions about model similarity.

What Problem Does This Paper Address?

While open-source LLMs proliferate rapidly, we know surprisingly little about whether they solve language tasks using fundamentally similar internal computational structures. Most model comparisons rely on downstream benchmark scores (functional similarity), which can conceal whether two models arrive at identical predictions via completely different mechanisms.

Prior work evaluated representational similarity on smaller, encoder-based models like BERT or ELMo, but modern decoder-only LLMs present distinct challenges:

  1. Autoregressive text generation introduces non-deterministic representations.
  2. Distinct tokenizers mean representations do not align row-for-row across models.

Understanding representational similarity could help identify model copying/reuse, inform ensemble learning, and explain why certain architectures generalize better.

Methods

To compare representations without suffering from generation non-determinism or mismatched tokenization lengths, the authors extract the representation matrix $R \in \mathbb{R}^{N \times D}$ of the final token in the last layer across $N$ fixed input prompts. The final token's final hidden state directly feeds into next-token prediction, ensuring comparable semantic grounding.

The authors evaluate representations under specific mathematical symmetries:

  • Invariance Properties: Invariance to Orthogonal Transformations (OT: rotations/reflections), Isotropic Scaling (IS: scalar factor shifts), and optionally Translation (TR: shift by a constant bias).
  • Similarity Measures Evaluated:
  • Orthogonal Procrustes & Aligned Cosine Similarity (alignment-based)
  • Norm RSM-Difference (comparing pairwise internal similarity matrices via Frobenius norm)
  • Jaccard Similarity ($k$-nearest neighbors overlap in representation space, $k=10$)
  • Representational Similarity Analysis (RSA) (correlation of pairwise similarity matrices)
  • Centered Kernel Alignment (CKA) (kernel-target alignment using the Hilbert-Schmidt Independence Criterion)

Datasets

The authors evaluated zero-shot representations on two benchmark datasets (no new datasets were introduced):

  • Winogrande (validation set): A commonsense reasoning task where models determine which noun fill-in resolves an ambiguous blank.
  • HumanEval: A Python code completion benchmark where models receive a function signature and docstring prompt to predict the implementation.

Evaluated Models: Eleven open base LLMs (~7B parameters): RedPajama, BLOOM, Falcon, Galactica, GPT-J, LLaMA, MPT, OpenLLaMA, OPT, Pythia, and StableLM Alpha. For code generation on HumanEval, CodeLlama and CodeLlama-Python were added.

Key Insights and Ideas

  • Representations are not universal: LLMs do not converge to the same internal representational geometry. Certain models deviate starkly from the pack (e.g., StableLM Alpha on commonsense reasoning, and CodeLlama-Python on coding prompts).
  • Metric disagreement is widespread: Measures designed with the exact same mathematical invariances often disagree on which models are similar. For instance, Falcon appears as an outlier under Procrustes and Jaccard on Winogrande, but appears moderately similar under Aligned Cosine Similarity and RSM-Difference. Anisotropic "rogue dimensions" (a few dimensions dominating variance) can distort angle-based metrics.
  • Similarity is strictly task-dependent: How similar two models appear depends heavily on the evaluation domain. Models that match closely on natural language reasoning can diverge sharply on code generation.

Key Results

  • Low cross-measure agreement: On Winogrande, the average Spearman rank correlation ($\rho$) between similarity heatmaps generated by different metrics with OT and IS invariance was only 0.35. Agreement improved on HumanEval, reaching an average $\rho = \mathbf{0.65}$.
  • Low cross-domain consistency: The average Spearman correlation between metric heatmaps on Winogrande versus HumanEval was only 0.34, proving that representational similarity does not transfer broadly across domains.
  • Model outliers:
  • On Winogrande, StableLM Alpha showed the lowest similarity relative to nearly all other models, followed by Falcon on select metrics.
  • On HumanEval, OPT, OpenLLaMA, and CodeLlama-Python showed clear divergence from standard language and general code base models.

Limitations and Future Work

  • Sample size vs. dimensionality ($N < D$): Benchmark prompt counts are smaller than model hidden dimensions ($D \approx 4096$), which risks overfitting in alignment methods like Orthogonal Procrustes.
  • Single-scale restriction: Only 7B parameter models were tested; results may not generalize to larger 13B–70B+ scales.
  • Prompt formatting dependence: Zero-shot prompt templates were static; altering prompt templates or including few-shot demonstrations may significantly warp representational alignment.
  • Interpretability of absolute scores: Metrics without normalized, interpretable bounds make it impossible to determine whether a low score reflects mild drift or orthogonal conceptual representations.

Summary updated

BibTeX
@inproceedings{klabunde2023towards,
  author = {Max Klabunde and Mehdi Ben Amor and Michael Granitzer and Florian Lemmerich},
  title = {{Towards Measuring Representational Similarity of Large Language Models}},
  booktitle = {UniReps @ NeurIPS},
  year = {2023},
  url = {https://openreview.net/forum?id=gG5UGgUzDR},
}
Figure