Spectral Geometry of Attention: From Information Routing to Uncertainty

Giulio Viganò, Simone Melzi, Maks Ovsjanikov

TL;DR

This paper introduces a novel framework for analyzing Transformer attention using spectral geometry. By treating attention heads as functional maps between geometric domains, the authors derive the Token Difference Operator (TDO), which successfully disentangles "attention sinks" from actual information routing. This theoretical grounding leads to a new unsupervised uncertainty estimator, SAUQ, which significantly outperforms existing methods on long-context tasks like summarization.

What Problem Does This Paper Address?

Interpreting what happens inside a Transformer’s attention heads is notoriously difficult. Researchers often look at "attention maps" to see which tokens are talking to each other, but these maps are frequently biased by attention sinks—initial tokens (like the [CLS] or first token) that receive massive amounts of attention mass simply to serve as a "null" or "trash" bin for the softmax, rather than because they are semantically important.

Standard spectral analysis (looking at the eigenvalues of the attention matrix) fails because it adopts a uniform Euclidean metric. In this "biased" view, a sink looks like a major information highway, even if the head isn't actually routing any useful token-dependent data. This makes it hard to distinguish between a head that is actively processing information and one that has "collapsed" into a state of uncertainty.

Methods

The authors propose moving from a Euclidean view to an intrinsic probability geometry.

  1. Functional Maps: They model each attention head as a linear operator between two Hilbert spaces of functions defined on the token sequence.
  2. The Token Difference Operator (TDO): They define a new operator, $D_{\mu,\pi} = A^*A$, where the input measure $\mu$ is "pulled back" from the attention map itself. This choice of geometry ensures that the "constant mode" (the average attention) is separated from the "routing modes" (the actual differences between tokens).
  3. Spectral Metrics: They use the Normalized Participation Ratio (PR) of the TDO spectrum to quantify routing capacity. A high PR means information is being spread across many dimensions; a low PR indicates "routing collapse."
  4. SAUQ (Spectral Attention Uncertainty Quantification): They integrate this spectral signal into a recursive confidence estimator. If the routing capacity in key middle-layer heads collapses, the model's uncertainty score increases.
The TDO framework recasts attention into an intrinsic geometry to separate sink effects from genuine routing.

Datasets

The authors evaluated their framework and the SAUQ estimator across several benchmarks and models:

  • Models: Llama-3.1-8B, Qwen2.5-7B, GPT-2, and Pythia-410m.
  • Question Answering (QA): TriviaQA, TruthfulQA, MMLU, and CoQA.
  • Summarization: SAMSum and XSum (chosen specifically to test long-context performance).
  • Controlled Tasks: A synthetic "copy task" used to test sensitivity to small perturbations in long sequences.

Key Insights and Ideas

  • Sinks are a Geometric Bias: The paper proves that Euclidean spectra are structurally biased by sinks. In the extreme case of a pure sink, the Euclidean spectrum suggests high energy, while the intrinsic TDO spectrum correctly shows zero routing capacity.
  • Mean-Routing Decomposition: The intrinsic geometry allows for a clean mathematical split: $AV = 1m + AV_c$. Here, $1m$ is the transported mean (position-independent), and $AV_c$ is the token-dependent routing. The TDO spectrum specifically controls the dimensionality of this second, useful component.
  • Uncertainty is "Upstream": Most uncertainty metrics look at the final output probabilities (logits). However, by the time information reaches the logits, task-relevant distinctions might already be compressed or lost. SAUQ looks "upstream" at the routing capacity of internal layers, catching uncertainty before it's hidden by the final softmax.
Figure 2: Representative attention heads and how different metrics classify their routing behavior. The intrinsic TDO score separates sink collapse from sink-biased routing, assigning high routing scores to copying, shifting, and sink-biased heads while distinguishing them from pure sink heads.

Key Results

  • Better Diagnostics: TDO-based metrics show a much stronger correlation with the actual dimensionality of the head's output ($H(AV)$) compared to raw attention entropy or previous-token scores.
  • SOTA Unsupervised Uncertainty: On the XSum summarization task, SAUQ achieved a Normalized Prediction Rejection Ratio (PRR) of 0.4214, a significant jump over the previous best attention-based method, RAUQ (0.3008).
  • Robustness to Long Context: In the controlled copy task, while standard perplexity and entropy became "blind" to errors as the sequence length $N$ grew, the spectral signal remained sensitive to perturbations.
Scatterplots showing that TDO-based diagnostics (right) correlate much more strongly with output entropy than standard baselines (left).

Limitations and Future Work

  • Scope of Analysis: The current work is "per-head" and "single-step." It doesn't yet account for how information evolves across multiple layers or how heads interact with the MLP (Feed-Forward) blocks.
  • Computational Cost: While the Participation Ratio is efficient to compute, calculating the full spectrum for every head in a massive model during every generation step is currently too expensive for real-time deployment without further optimization.
  • Architecture Dependence: The authors noted that the gains were more pronounced in Llama-3.1 than in Qwen2.5, suggesting that different pre-training regimes or architectural choices (like the presence of registers) might influence how much "sink bias" exists to be corrected.

Summary updated

Abstract

In this work, we study transformer attention through the lens of spectral geometry and operator theory. We view each attention head as a functional map between Hilbert spaces of functions on the token sequence and derive a Token Difference Operator, whose spectral structure controls how token-space information is routed to the output. We show that standard Euclidean spectra are structurally biased by sinks, conflating mass concentration with genuine routing capacity. By recasting token space in the intrinsic probability geometry induced by attention, the token difference spectrum disentangles sink effects from routing capacity and provides a spectral description of the dimensionality of the head output. This yields a unified framework for analyzing attention maps, explaining sinks, routing collapse, and output dimensionality within a single operator-theoretic framework. In practice, by grounding attention heuristics in spectral geometry, we develop a novel attention-based uncertainty estimator that complements probability-based scores, with the largest gains on long-context inputs.
BibTeX
@inproceedings{vigano2026spectral,
  author = {Giulio Viganò and Simone Melzi and Maks Ovsjanikov},
  title = {{Spectral Geometry of Attention: From Information Routing to Uncertainty}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=TXNoJp3DRA},
}
Figure