Manuscript Offprint

arXiv:2610.17117

Gluing Local Contexts into Global Meaning: A Sheaf-Theoretic Decomposition of Transformer Representations

Bryce Grant, Peng Wang

Abstract

Existing interpretability tools do not test whether a representation keeps the same content when only the phrasing changes. We treat each paraphrase pair as a local witness that two activations should agree and build a cellular sheaf over the paraphrase graph; its Laplacian LFL_{\mathcal{F}} answers the question on a frozen model with no training. The kernel H0H^0 is a content subspace: at 20 dimensions it beats the preserved subspace of the concept eraser LEACE on held-out CounterFact fact retrieval across eight architectures by a mean +17.1 pp, and constraining all paraphrases of a fact jointly adds a further +6.5 pp. The spectral complement concentrates causal influence: ablating the most paraphrase-variable coordinates, a coordinate-wise proxy for it, changes model outputs 5.6 to 26.5× more than ablating coordinates of matched per-coordinate variability, across nine models from 124M to 13B parameters. Stacking layers into a grid creates b1=N(L−1)b_1 = N(L - 1) algebraic 1-cycles, and the resulting model-derived harmonic mass varies by nearly three orders of magnitude across six architectures and ranks them as their steering fragility does (Spearman ρ=0.90\rho = 0.90, exact one-sided permutation p=0.014p = 0.014). The same paraphrase graph yields the content subspace, the influence directions, and the fragility measure. Project page: https://cwru-aism.github.io/gluing-lc-page/.

1 Introduction

Transformer representations entangle what a sentence means with how it is phrased. The hidden state for “The Eiffel Tower is in Paris” differs from “Paris is home to the Eiffel Tower” despite identical semantic content. Existing tools decompose one activation into features [7, 12], test the linear decodability of attributes already chosen [4], or relate two activation spaces to each other [40, 52]. None of them tests cross-context consistency, meaning whether a feature encodes the same information when the phrasing changes and the meaning does not. The gap shows up in steering, where methods improve some models and fail or degrade others [14], and even within one model steerability varies widely across inputs [57]; no existing tool predicts which regime a model is in. We treat the problem as local-to-global agreement. Each paraphrase pair is a local witness that two activations should agree, and together the witnesses should determine one global answer.

In the cellular sheaf we build on the paraphrase graph, hidden states sit on the nodes, edges connect paraphrase pairs, and a learned restriction map P⊤P^\top ( P∈Rd×kP \in \mathbb{R}^{d \times k}) projects each pair into a shared k-dimensional comparison space. The coboundary δ0\delta^0 measures pairwise disagreement, and the sheaf Laplacian LF=(δ0)⊤δ0L_{\mathcal{F}} = (\delta^0)^\top \delta^0 has a kernel H0=ker⁡(δ0)H^0 = \ker(\delta^0) of globally consistent sections together with a spectral complement of high-disagreement directions. We call the spectral complement the “ H1H^1 directions” (Remark 3.3 explains the name). Section 3 defines the construction, and Section 5 tests it on nine models.

40th Conference on Neural Information Processing Systems (NeurIPS 2026).

Figure

H1H^{1} directions

(top eigenspace of LFL_{F})

Figure 1: Sheaf decomposition of a paraphrase pair. Hidden states hah_a, hbh_b pass through P⊤P^\top into the edge stalk Rk\mathbb{R}^k, where the coboundary measures their disagreement, (δ0h)e=P⊤(hb−ha)(\delta^0 h)_e = P^\top(h_b - h_a). The bottom and top eigenspaces of the sheaf Laplacian LFL_{\mathcal{F}} split the edge stalk Rk\mathbb{R}^k into H0H^0 (blue, content stable across phrasing) and the H1H^1 directions (red, context-dependent variation).

A single-layer matching graph has no cycles, so algebraic H1=0H^1 = 0 and the construction reduces to projected within-pair covariance (Proposition 3.1). Stacking the same activations across layers creates cycles. The grid has one node per (sentence, layer) pair, with horizontal edges between paraphrases in the same layer and vertical edges between adjacent layers along each sentence. It carries b1=N(L−1)b_1 = N(L - 1) algebraic 1-cycles ( b1b_1, the first Betti number, counts the independent cycles in the graph), one per elementary square, and each square asks whether the layer-l-to-layer-l+1 transformation commutes with paraphrase equivalence. The model-derived Hodge harmonic mass (the fraction of a model-derived edge cochain's energy in the harmonic subspace, the part supported on cycles that is neither a gradient nor a curl) at L=2L = 2 varies by nearly three orders of magnitude across six architectures ( 10−410^{-4} to 0.08; Table 1) against a 0.25 topological reference, and §5.4 tests it as a diagnostic of steering fragility. Richer paraphrase graphs also improve H0H^0: constraining all paraphrases of a fact jointly beats pair-only H0H^0 by +6.5 pp on all eight architectures, and an edge-count-matched control attributes the gain to the joint constraint, with the cycle itself retrieval-neutral (§5.2). The coboundary of a cellular sheaf on a paraphrase graph yields LFL_{\mathcal{F}}, whose kernel is the content subspace (§5.2), whose spectral complement concentrates functional influence (§5.3), and whose harmonic mass on the depth-induced cycles is tested as a diagnostic of steering fragility (§5.4).

Our contributions are:

• Content from the kernel. Sheaf H0H^{0} at 20 dimensions beats LEACE’s preserved subspace at full hidden dimension on held-out CounterFact retrieval across eight architectures (mean +17.1 pp; 85.3% vs. 43.1% on GPT-2). Random or identity restriction maps keep most of the gain, and constraining all of a fact’s paraphrases jointly adds +6.5 pp (§5.2).

• Influence from the spectral complement. Ablating the most paraphrase-variable coordinates, a coordinate-wise proxy for the top eigenspace of LFL_{\mathcal{F}}, changes model outputs 5.6 to 26.5×26.5 \times more than ablating coordinates of matched per-coordinate variability on nine architectures from 124M to 13B parameters. Projecting out the sheaf H1H^{1} eigenbasis shifts next-token distributions 17.8–398×17.8–398 \times more than random subspaces and collapses fact recall to 0–5%, while matched random ablation leaves recall at baseline on the 7B models (§5.3, Appendices B.6 and B.7).

• Fragility from harmonic mass. Multi-layer grids carry b1=N(L−1)b_1 = N(L - 1) algebraic 1-cycles and a model-derived harmonic mass spanning [10−4,0.08][10^{-4}, 0.08] that ranks six architectures by steering fragility ( ρ=0.90\rho = 0.90, p=0.014p = 0.014). On Llama-2-7B, contrastive sheaf steering preserves 31.0% of facts against 4.2% for random steering (§5.4).

References (65)