How Language Models Compress and Compare: Understanding Selection with Token Covariance Maps

Moshe Eliasof

TL;DR

When you give a language model a multiple-choice question, how does it actually weigh the options? By mapping how tokens co-vary layer by layer, this paper uncovers a universal "compress-then-compare" choreography: models first squeeze the entire prompt into a tight, low-dimensional bottleneck in their middle layers, and only re-expand it in the late layers to pit candidate answers against one another. It’s a clean, intuitive lens into the hidden geometry of decision-making inside transformers.

What Problem Does This Paper Address?

Asking a language model to pick the best option from a list—whether in a benchmark exam or a production reranking pipeline—is one of the most common ways we use AI. Yet, we lack a holistic picture of how a decoder-only transformer organizes an entire prompt as that choice unfolds across its layers.

Existing interpretability tools tend to zoom in on specific parts of the elephant: attention maps show how tokens pass messages, linear probes test what facts live in a specific layer, and mechanistic circuits hunt down individual heads. What’s been missing is a single, prompt-level view that shows how instructions, context, and candidate answers are jointly arranged in hidden space from start to finish.

Methods

The author introduces token covariance maps, a straightforward geometric object computed for a single prompt at a single layer. Given a layer’s hidden states (a matrix of $T$ tokens by $D$ hidden features), you center the vectors across token positions and compute their $T \times T$ covariance matrix. Because the rows and columns correspond directly to token indices, you can draw boxes right over the map to see how the context, instructions, and individual answer choices are interacting.

Figure 1: Token covariance maps across depth for one PIQA prompt in Pythia-410M. Colored rectangles mark prompt segments. The key visual trajectory is broad early geometry, a low-rank mid-layer bottleneck, and late recovery of off-diagonal context-option and option-option interactions.

From these maps, the paper extracts two novel diagnostic views alongside standard behavioral readouts:

  • Compression tracking: Using effective rank (a measure of how many dimensions the variance is spread across), the author locates the exact depth where the prompt representation is squeezed the tightest.
  • Block summaries: By averaging covariance mass inside and between prompt segments, they measure how strongly options couple with the context (CtxOpt), within themselves (OptSelf), or against competing options (OptCross).
  • Causal interventions: To prove this geometry actually matters, the author performs low-rank truncations (wiping out minor directions at the bottleneck) and "candidate-state patching" (swapping the hidden states of one option with a new, length-matched option right at the bottleneck).

Datasets

The core evaluation spans 12 established structured-selection benchmarks: PIQA, BoolQ, HellaSwag, ARC-Easy, ARC-Challenge, COPA, WinoGrande, OpenBookQA, CommonsenseQA, Social IQa, SciQ, and LogiQA.

To test generalization beyond standard English multiple-choice, the study also incorporates multilingual aligned examples from XCOPA (five languages) and open-ended generation tasks using GSM8K, TriviaQA, MBPP, and QASPER. No new datasets are introduced, though existing prompts are systematically rewritten and manipulated to test robustness.

Key Insights and Ideas

  • The "Compress-then-Compare" Law: Across models and tasks, early layers represent tokens diffusely. Middle layers crush the entire prompt into a shared, low-rank bottleneck (where a single dominant mode often captures most of the variance). Late layers then re-expand the representation—not randomly, but specifically along blocks that compare the context and candidate answers.
  • The bottleneck is learned, not wired-in: Looking at Pythia training checkpoints, an untrained model at initialization has a flat effective-rank profile across layers. The mid-layer squeeze is something the network actively discovers during training.
  • Compression precedes decision: Models don't actually "know" the right answer during the middle bottleneck. Intermediate layer readouts show that answer discrimination peaks well after the compressed stage, during the late re-expansion.
  • Inside the squeeze, MLPs and Attention play tug-of-war: Right at the bottleneck, attention sublayers consistently act to raise the effective rank, while MLP sublayers push it back down.

Key Results

The analysis covers 14 open-weight models across 4 families (Pythia, SmolLM, Qwen, Mistral), totaling 19,880 prompt–model observations in the main setup.

Figure 2: Robust compression and re-expansion on representative datasets. Rows show effective rank, top-1 eigenvalue fraction, and band-4 energy; columns show datasets; curves show Pythia scales. The same mid-layer compression and late re-expansion appear in aggregate trajectories, not only in single-prompt heatmaps.
  • Universal trajectory: All 14 models exhibit the interior bottleneck and late re-expansion. Rewriting prompt templates or permuting option orders preserves the effective-rank trajectory with correlations above $0.999$.
  • Timing: In Qwen2.5-7B, the geometric bottleneck occurs early (around relative depth $0.11$), whereas peak intermediate answer accuracy doesn't arrive until relative depth $0.74$.
  • Perturbation sensitivity: Truncating low-rank directions at the bottleneck disrupts final-layer option-comparison geometry significantly more than doing the exact same truncation 3 layers earlier or later. Furthermore, replacing a plausible wrong option with an irrelevant distractor leaves the bottleneck intact, but drops the final cross-option/self-option comparison ratio by about $0.11$.
  • Shifting preferences: When patching in the residual states of a replacement candidate right at the bottleneck, the model shifts its preference toward that new candidate—making it the top prediction in roughly $1$ in $10$ examples, with a statistically positive margin shift in $70$ out of $72$ controlled comparisons.

Limitations and Future Work

Because covariance is inherently symmetric, these maps show that token positions co-vary, not the causal direction of information flow. Additionally, surface factors like option length, formatting, and hidden-state norms can skew raw covariance magnitudes (even if the bottleneck's location stays put). Finally, while perturbations prove that the compressed region as a whole is functionally vital for building late comparison geometry, pinpointing exact causal responsibility down to individual layers or specific eigenvectors remains an open challenge for future mechanistic work.

Summary updated

Abstract

Many language-model tasks reduce to selecting among structured alternatives, yet we still lack a simple picture of how a decoder-only transformer organizes an entire selection prompt across depth. We introduce token covariance maps, a prompt-level geometric view that tracks how token positions co-vary in hidden-state space at each layer. This turns a structured prompt into a depth-indexed sequence of maps whose spectral and block structure can be aligned with instructions, context, and candidate answers. Across 14 decoder-only models from 4 families and 12 structured-selection benchmarks, token covariance maps reveal a robust compress-then-compare organization. Early layers represent prompts diffusely, middle layers compress them into a shared low-rank bottleneck, and late layers re-expand into context-option and option-option geometry. This organization recurs across larger fixed-template samples, deterministic prompt rewrites, pairwise reranking reformulations, and controlled answer-set manipulations, while also emerging during training from an initially flat depth profile. Its timing aligns with behavior: useful answer discrimination appears well after the bottleneck, and low-rank intervention around the bottleneck preferentially disrupts late comparison geometry. We additionally show that the same geometric profile appears in instruction-tuned models, across several languages, and during open-ended generation. We further show that changing the internal representation of one candidate around the compressed region can shift which candidate the model later prefers. These results show that token covariance maps are a diagnostic tool for comparing how models organize information across prompts, model families, and stages of training.
BibTeX
@inproceedings{eliasof2026how,
  author = {Moshe Eliasof},
  title = {{How Language Models Compress and Compare: Understanding Selection with Token Covariance Maps}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=AW5VdyuenU},
}
Figure