Gluing Local Contexts into Global Meaning: A Sheaf-Theoretic Decomposition of Transformer Representations
Organizations: Case Western Reserve University
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 answers the question on a frozen model with no training. The kernel 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 ,pp, and constraining all paraphrases of a fact jointly adds a further ,pp. The spectral complement concentrates causal influence: ablating the most paraphrase-variable coordinates, a coordinate-wise proxy for it, changes model outputs to more than ablating coordinates of matched per-coordinate variability, across nine models from 124M to 13B parameters. Stacking layers into a grid creates 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 , exact one-sided permutation ). 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/
Figures & tables
| Architecture | Pres. (%) | ||||
|---|---|---|---|---|---|
| Mistral-7B | |||||
| Qwen-2.5-7B | |||||
| Llama-3-8B | |||||
| Phi-2 | |||||
| GPT-2 (124M) | – | ||||
| Llama-2-7B |
| Model | Full | (20D) | LEACE-full | LEACE-20D | PCA-20 | Rand-20 | |
|---|---|---|---|---|---|---|---|
| GPT-2 | 43.1 | 85.3 | 43.1 | 28.9 | 24.6 | 39.1 | +42.2 |
| Mistral-7B | 77.7 | 87.1 | 77.7 | 36.8 | 34.5 | 59.2 | +9.4 |
| OLMo-2-7B | 81.3 | 82.8 | 81.3 | 40.9 | 35.7 | 62.3 | +1.5 |
| Phi-2 | 69.1 | 87.1 | 69.1 | 38.8 | 37.2 | 55.1 | +18.0 |
| Qwen-2.5-7B | 49.4 | 64.1 | 49.4 | 36.8 | 37.5 | 43.7 | +14.7 |
| Gemma-2-9B | 54.4 | 77.9 | 54.4 | 32.3 | 27.5 | 43.5 | +23.5 |
| Model | Ratio | Layer | 95% CI | Cohen’s |
|---|---|---|---|---|
| GPT-2 (124M) a | 18.2 | L6 | [17.2, 19.3] | 2.34 |
| Phi-2 b | 14.48 | L8 | [14.0, 15.0] | 13.98 |
| Mistral-7B b | 19.71 | L8 | [19.1, 20.3] | 18.45 |
| Qwen-2.5-7B b | 5.76 | L7 | [5.38, 6.12] | 6.63 |
| OLMo-2-7B b | 9.17 | L16 | [8.85, 9.49] | 12.93 |
| Gemma-2-9B b | 9.24 | L21 | [8.94, 9.54] | 22.02 |
| Model | Method | Fact% | 95% CI | McNemar |
| Llama-2-7B | Contrastive sheaf ( dims) | 31.0 | [28.2, 33.9] | – |
| PIXEL [ 66 ] | 21.1 | [18.6, 23.9] | ||
| Full style (CAA) | 13.7 | [11.7, 15.9] | ||
| -removed (sheaf) | 13.7 | [11.6, 15.9] | ||
| dims (sheaf PCA) | 12.1 | [10.0, 14.1] | ||
| Random | 4.2 | [3.0, 5.4] |
Appendix figures & tables19 assets
Supplementary material from the paper’s appendix.
Appendix
| Topology | (algebraic) | frac. | Harmonic frac. | ||
|---|---|---|---|---|---|
| Matching (acyclic) | 180 | 0 | 0 | 0.000 | 0.000 |
| Clique (filled) | 60 | 0 | 240 | 0.600 | 0.000 |
| Relation hypergraph | 6 | 66 | 0 | 0.184 | 0.184 |
| Model | Full | (20D) | LEACE preserved | LEACE erased | PCA-20 | Random-20 |
|---|---|---|---|---|---|---|
| GPT-2 | 85.3% | 95.7 % | 85.0% | 2.0% | 22.7% | 53.7% |
| Phi-2 | 97.3% | 93.0% | 97.3% | 3.3% | 38.0% | 64.3% |
| Qwen-2.5-7B | 73.3% | 82.0 % | 75.0% | 1.0% | 30.3% | 50.0% |
| OLMo-2-7B | 100% | 97.0% | 100% | 2.3% | 36.7% | 77.3% |
| Mistral-7B | 100% | 80.7% | 100% | 2.0% | 50.0% | 71.3% |
| Gemma-2-9B | 99.3% | 83.7% | 99.3% | 1.3% | 26.7% | 68.3% |
| Architecture | coexact | coexact | coexact | |||
|---|---|---|---|---|---|---|
| Mistral-7B | ||||||
| Llama-3-8B | ||||||
| Qwen-2.5-7B | ||||||
| GPT-2 (124M) | ||||||
| Phi-2 | ||||||
| ( ) | ( ) | |||||
|---|---|---|---|---|---|---|
| Architecture | ||||||
| Mistral-7B | ||||||
| Llama-3-8B | ||||||
| Qwen-2.5-7B | ||||||
| GPT-2 (124M) | ||||||
| Phi-2 | ||||||
| Model | CF (in-domain) | MRPC | PAWS | QQP | PCA-20 | Random-20 |
|---|---|---|---|---|---|---|
| GPT-2 | 85.3 | 55.1 | 63.9 | 59.1 | 24.6 | 39.1 |
| Phi-2 | 87.1 | 57.3 | 61.6 | 57.6 | 37.2 | 55.1 |
| Mistral-7B | 87.1 | 57.8 | 65.9 | 61.2 | 34.5 | 59.2 |
| OLMo-2-7B | 82.8 | 64.1 | 60.5 | 57.6 | 35.7 | 62.3 |
| Qwen-2.5-7B | 64.1 | 47.0 | 53.3 | 56.7 | 37.5 | 43.7 |
| Gemma-2-9B | 77.9 | 48.3 | 47.9 | 51.0 | 27.5 | 43.5 |
| Model | pair ( ) | ring ( ) | clique ( ) | ||
|---|---|---|---|---|---|
| GPT-2 | 87.4 | 90.7 | 89.2 | ||
| Phi-2 | 83.1 | 89.6 | 90.5 | ||
| Mistral-7B | 86.7 | 89.8 | 91.4 | ||
| OLMo-2-7B | 84.4 | 91.4 | 91.4 | ||
| Qwen-2.5-7B | 62.3 | 71.8 | 70.7 | ||
| Gemma-2-9B | 75.2 | 84.0 | 84.7 |
| Model | PCA- | random- | identity- | PCA-20 (no kernel) | Random-20 |
|---|---|---|---|---|---|
| GPT-2 | 85.3 | 79.0 | 24.6 | 39.1 | |
| Phi-2 | 87.1 | 78.8 | 37.2 | 55.1 | |
| Mistral-7B | 87.1 | 83.3 | 34.5 | 59.2 | |
| OLMo-2-7B | 82.8 | 79.7 | 35.7 | 62.3 | |
| Qwen-2.5-7B | 64.1 | 62.3 | 37.5 | 43.7 | |
| Gemma-2-9B | 77.9 | 76.5 | 27.5 | 43.5 |
| Model | Sheaf | LDA | NCA | CCA | PLS | PCA-20 | W-PCA | Full |
|---|---|---|---|---|---|---|---|---|
| GPT-2 | 84.9 | 87.4 | 88.3 | 47.9 | 49.0 | 24.4 | 39.5 | 43.1 |
| Phi-2 | 87.6 | 84.9 | 83.3 | 58.9 | 64.1 | 37.9 | 42.7 | 69.1 |
| Mistral-7B | 86.9 | 90.1 | 88.3 | 60.7 | 63.7 | 34.3 | 45.1 | 77.4 |
| OLMo-2-7B | 82.6 | 88.5 | 86.9 | 62.8 | 67.5 | 36.6 | 37.2 | 81.3 |
| Qwen-2.5-7B | 64.8 | 72.5 | 72.9 | 50.8 | 56.0 | 36.6 | 38.1 | 50.3 |
| Gemma-2-9B | 77.4 | 76.1 | 76.3 | 51.2 | 50.1 | 27.3 | 37.2 | 54.4 |
| Model | Layers | /random, median | Range | Prompts | /random, median |
|---|---|---|---|---|---|
| GPT-2 (124M) | 6 | 13.7–53.5 | 99% | ||
| Phi-2 | 16 | 18.4–122 | 97% | ||
| Mistral-7B | 16 | 70.0–3075 | 100% | ||
| Qwen-2.5-7B | 14 | 78.7–293 | 99% | ||
| OLMo-2-7B | 16 | 112–1048 | 100% | ||
| Gemma-2-9B | 21 | 75.8–1211 | 100% |
| Model | Dormancy ratio ( /random) | Recall, no ablation | ablated | Random ablated |
|---|---|---|---|---|
| GPT-2 | 15.0% | 2.0% | 7.5% | |
| Mistral-7B | 46.7% | 0.0% | 47.0% | |
| Llama-2-7B | 47.3% | 4.7% | 48.7% |
| Subspace | FR EN | EN FR |
|---|---|---|
| kernel (20-dim) | 76 | 78 |
| complement | 6 | 3 |
| Full hidden state (4096-dim) | 82 | 59 |
| Observed | Shuffled | ||||||
|---|---|---|---|---|---|---|---|
| GPT-2 (124M) | |||||||
| Mistral-7B | |||||||
| Qwen-2.5-7B | |||||||
| Phi-2 |
| Embedding | Loss | Top-1 frac. | Effective rank | Feature var. | Pair MSE |
|---|---|---|---|---|---|
| GPT-2 (768D) | Naive MSE | ||||
| only | |||||
| Mistral-7B (4096D) | Naive MSE | ||||
| only | |||||
| GPT-2 ( ) | Mistral-7B ( ) | |||
|---|---|---|---|---|
| Method | Spearman | Pearson | Spearman | Pearson |
| Vanilla (no training) | ||||
| SimCSE (final-layer, InfoNCE) | ||||
| VICReg (final-layer, inv + var + cov) | ||||
| MLST nosheaf (final) | ||||
| MLST nosheaf (concat) | ||||
| Model | Full | ||||||
|---|---|---|---|---|---|---|---|
| GPT-2 | 63.7 | 74.3 | 85.3 | 91.2 | 87.8 | 35.9 | 43.1 |
| Phi-2 | 67.3 | 75.8 | 87.1 | 90.3 | 85.3 | 52.8 | 69.1 |
| Mistral-7B | 70.9 | 82.4 | 87.1 | 90.3 | 86.7 | 48.5 | 77.7 |
| Llama-2-7B | 62.8 | 74.0 | 80.4 | 85.3 | 85.1 | 35.2 | 68.2 |
| Mean (default) | Last token | First token | ||||
|---|---|---|---|---|---|---|
| Model | Full | Full | Full | |||
| GPT-2 | 43.1 | 85.3 | 25.5 | 74.3 | 41.8 | 42.7 |
| Phi-2 | 69.1 | 87.1 | 26.9 | 65.9 | 30.5 | 43.8 |
| Mistral-7B | 77.7 | 87.1 | 40.4 | 72.2 | 20.5 | 14.2 |
| Llama-2-7B | 68.2 | 80.4 | 21.4 | 47.0 | 19.6 | 23.0 |
Transformer Interpretability
Transformer interpretability studies how attention, feed-forward layers, and hidden representations support model predictions and behavior.
See all 338 papers