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

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

Bryce Grant, Peng WangNeurIPS 2026

TL;DR

Transformers tangle what a sentence means with how it is phrased, making it famously unpredictable when we try to "steer" or interpret their internal states. By treating paraphrase pairs as local witnesses of shared meaning and connecting them using mathematical structures called cellular sheaves, researchers can cleanly slice a frozen model’s activations into pure semantic content versus surface-level style—no training required. Better yet, extending this geometry across layers acts like an X-ray for model fragility, predicting whether a given architecture will cooperate or break when you try to steer it.

What Problem Does This Paper Address?

Say "The Eiffel Tower is in Paris," and then say "Paris is home to the Eiffel Tower." To you, it's the exact same fact. To a transformer, those two sentences produce noticeably different internal activations.

Modern interpretability tools (like sparse autoencoders or linear probes) are great at finding features inside a single representation, or comparing whole spaces, but they don't test whether a feature stays consistent when you rephrase the prompt. This entanglement of meaning and phrasing becomes a major headache in activation steering—where engineers add vectors to hidden states to control model behavior (like changing tone while keeping facts straight). Steering works like magic on some architectures, fails miserably on others, and fluctuates wildly depending on how a prompt is worded. Until now, we haven't had a principled way to disentangle invariant meaning from context-dependent phrasing, nor a diagnostic tool to tell us ahead of time if a model is "steerable" or fragile.

Methods

To untangle meaning from phrasing, the authors borrow a tool from algebraic topology designed specifically to glue local agreements into global consensus: a cellular sheaf.

Imagine a graph where every node is a sentence carrying its hidden state from a frozen transformer, and edges connect sentences that paraphrase each other. A linear projection ($P^\top$, found via standard PCA, CCA, or a contrastive Fisher objective) maps these high-dimensional states into a shared, compact comparison space along the edges (say, 128 dimensions).

Figure 1: Sheaf decomposition of a paraphrase pair. Hidden states ha, hb pass through P ⊤into the edge stalk Rk, where the coboundary measures their disagreement, (δ0h)e = P ⊤(hb −ha). The bottom and top eigenspaces of the sheaf Laplacian LF split the edge stalk Rk into H0 (blue, content stable across phrasing) and the H1 directions (red, context-dependent variation).

On each edge, a "coboundary operator" ($\delta^0$) simply subtracts one projected paraphrase from the other to measure their disagreement. Squaring this gives the sheaf Laplacian ($L_{\mathcal{F}}$), a tiny $128 \times 128$ matrix whose eigenspaces give us a clean split:

  • The Kernel ($H^0$): The bottom eigenvectors where disagreement is near zero. This is the subspace of pure, paraphrase-invariant content.
  • The Spectral Complement ("$H^1$ directions"): The top eigenvectors where paraphrases disagree the most—capturing syntax, word choice, and surface form.

To diagnose steering fragility, the authors stack these paraphrase graphs across adjacent network layers to form a multi-layer grid. Every square in this grid represents a cycle asking a fundamental geometric question: Does moving from layer $l$ to $l+1$ commute with paraphrasing? If a fact takes inconsistent paths through the network depending on how it's phrased, going around the square doesn't sum to zero. Using Hodge decomposition, the authors measure this leftover energy—the harmonic mass—as a zero-training diagnostic of architectural fragility.

Datasets

No new benchmarks were introduced; instead, the authors repurpose standard NLP datasets on frozen models (ranging from 124M to 13B parameters, including GPT-2, Llama-2/3, Mistral, Qwen, Phi-2, Gemma-2, and OLMo-2):

  • MRPC (Microsoft Research Paraphrase Corpus): 200 pairs are used to learn the projection maps, and just 30 pairs are needed to compute multi-layer harmonic mass.
  • PAWS: Combined with MRPC (1,000 sentences total) for coordinate ablation tests.
  • CounterFact & ROME CounterFact: Used to evaluate held-out fact retrieval (500 facts split 70/30) and steering preservation (1,000 prompts per model).

Key Insights and Ideas

  • Less is much more for content: Compressing representations down to just the 20-dimensional $H^0$ kernel isolates factual meaning far better than full-dimensional erasure methods. In fact, the projection map $P$ barely matters—even random projections work well, proving the magic lies in selecting the low-disagreement kernel of paraphrase differences.
  • Style carries the causal weight: You might assume "surface form" coordinates are superficial. Yet the $H^1$ directions (where paraphrases vary most) hold massively concentrated causal influence over next-token predictions compared to other equally variable coordinates.
  • Layer commutativity predicts steerability: Why does random steering shatter Llama-2-7B's recall while Mistral-7B shrugs it off? The multi-layer harmonic mass reveals that in fragile models, layer-to-layer transformations don't commute with paraphrasing. Facts travel along fractured, phrasing-dependent pathways, making linear interventions treacherous.

Key Results

  • Fact Retrieval: Across 8 architectures, the tiny 20-dimensional sheaf $H^0$ beats full-dimensional LEACE (a linear concept-erasure baseline using up to 4,096 dims) by an average of +17.1 percentage points on hard CounterFact retrieval (e.g., jumping from 43.1% to 85.3% on GPT-2). Linking all paraphrases of a fact into a joint ring adds another +6.5 pp.
  • Causal Concentration: Zeroing out the most paraphrase-variable coordinates alters model outputs 5.6$\times$ to 26.5$\times$ more than ablating control coordinates matched for per-coordinate variability. Projecting out the $H^1$ eigenbasis collapses fact recall to 0–5%.
Output-change ratios across nine models when ablating $H^1$ coordinates versus variability-matched controls.
  • Fragility Screening: Harmonic mass varies by nearly three orders of magnitude across 6 tested architectures ($10^{-4}$ on Mistral-7B up to $0.079$ on Llama-2-7B) and accurately ranks their steering fragility (Spearman's $\rho = 0.90$, $p = 0.014$). On fragile Llama-2-7B, random steering preserves just 4.2% of facts, whereas contrastive sheaf steering preserves 31.0% (outperforming CAA at 13.7% and PIXEL at 21.1%).
Table 1: Multi-layer matching grid, b1 = N(L−1) from depth alone. Hodge harmonic mass of model-derived edge cochains varies by nearly three orders of magnitude. Every row shares the same graph (b1 = 30 at L = 2), so the variation comes from the model’s layer transitions. 30 MRPC pairs with joint-PCA per layer at shared k = 8. The last column is steering fragility: CounterFact fact preservation (%) under random steering (§5.4, Appendix A.3).

Limitations and Future Work

  • Tuning knobs remain: Which projection map $P$ works best for steering (PCA vs. CCA vs. contrastive) depends on the model architecture and partially on the text domain. Steering also requires choosing the right perturbation magnitude ($\alpha \in [0.10, 0.15]$ works best on robust models, while $\alpha \approx 0.30$ suits fragile ones).
  • Small sample of architectures: While $\rho = 0.90$ is striking, the fragility diagnostic was evaluated across 6 architectures; turning it into a battle-tested predictor requires scaling up to many more models.
  • Negative topological transfers: Not every fancy topological idea panned out—attempts to use node-space $H^1$ operationalizations didn't help steering, and cycle holonomy on relation hypergraphs couldn't beat a shuffled baseline.
  • Future directions: Because the math only requires pairs of inputs that "mean the same thing," the authors note it naturally extends beyond paraphrases to cross-lingual translation pairs, logical equivalences, or even multi-modal setups (gluing text and image encoders together via per-node maps of different widths).

Summary updated

BibTeX
@inproceedings{grant2026gluing,
  author = {Bryce Grant and Peng Wang},
  title = {{Gluing Local Contexts into Global Meaning: A Sheaf-Theoretic Decomposition of Transformer Representations}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=P5J2YE6sLF},
}
Figure