This repository contains the public experimental materials, data, analysis scripts, and figures for:
How Structured is Decoder Self-Attention? Spectral Landscapes, Oracle Approximation, and Structure-Constrained Probing
The project studies full self-attention matrices from pretrained decoder LLMs through three linked questions:
- What spectral and spatial structure appears in real layer-head attention matrices?
- Which structured approximation families best preserve those matrices?
- Can structure-constrained interventions reveal architecture-specific head sensitivity?
| Path | Contents |
|---|---|
prompts/ |
12 full instruction prompts across Travel, Business, and Technical domains |
scripts/ |
Extraction, approximation, probe, selection, plotting, and reviewer-response analysis scripts |
results/spectral/ |
Spectral and locality metrics for all extracted attention matrices |
results/approx/ |
Structured approximation benchmark CSVs |
results/probe/ |
Causal probe outputs and selected head targets |
results/summary/ |
Aggregated tables, statistics, reviewer-response robustness summaries |
figures/ |
Paper figures generated from the result CSVs |
artifact_manifest.json |
Public artifact hashes, environment notes, model revisions, and reproducibility constants |
Private manuscript, review, and planning materials are intentionally excluded from the public repository.
- Sparse top-k is the strongest oracle matrix-fidelity family. Retaining 20% of entries per row reduces mean relative Frobenius error to roughly 0.032-0.035 across the tested models.
- When sparse top-k is excluded, the low-rank-initialized projected family is the safest dense fallback, winning 81.5%-96.3% of layer-head-prompt cases.
- Rank and locality are separable. Qwen3 contains low-rank diffuse heads with very low effective rank but long mean attention distance.
- A banded-local intervention reveals robust high-complexity global-head sensitivity in Ministral and more outlier-driven but interpretable patterns in Gemma3 and Qwen3.
- A supplemental Qwen3 projected low-rank (PLR) probe provides an orthogonal check: selected Qwen3 local-band heads are much more sensitive to PLR-r4 replacement than to banded-local replacement, while low-rank diffuse heads show the opposite high-KL pattern under banding rather than PLR.
The released CSVs preserve the original experiment code labels:
| CSV/code label | Paper term | Meaning |
|---|---|---|
sparse_topk |
Sparse top-k oracle | Row-wise top-k retention baseline for matrix fidelity, not a runtime acceleration claim |
lowrank |
Projected low-rank / PLR | Truncated-SVD reconstruction followed by nonnegative projection and row renormalization |
banded |
Banded local mask | Local window mask followed by row renormalization |
monarch |
Simplified block-diagonal proxy | Legacy code label for a block-diagonal proxy; not full MonarchAttention or the full Monarch matrix design space |
The reviewer-requested orthogonal PLR probe is released under results/probe/ and results/summary/:
results/probe/probe_qwen3_8b_multi_plr_r4.csvresults/probe/probe_qwen3_8b_multi_plr_r2.csvresults/summary/qwen_plr_probe_summary.mdresults/summary/qwen_plr_r4_probe_comparison.csvresults/summary/qwen_plr_r4_probe_group_summary.csvresults/summary/qwen_lowrank_diffuse_plr_rank_sweep.csv
Install dependencies:
pip install -r requirements.txtRun model-dependent experiments, replacing <model_path> with a local Hugging Face checkpoint path:
python scripts/s1_extract_spectra.py <model_path> qwen3_8b
python scripts/s2_approximate.py <model_path> qwen3_8b
python scripts/s5_select_probe_targets.py 6
python scripts/s3_causal_probe.py <model_path> qwen3_8b TR01,TR08,BZ01,BZ09,TC01,TC10 results/probe/probe_targets.csv
python scripts/s3_causal_probe.py <model_path> qwen3_8b TR01,TR08,BZ01,BZ09,TC01,TC10 results/probe/probe_targets.csv --intervention plr --rank 4Run post-hoc summaries and figures from existing CSVs:
python scripts/s6_analyze_results.py
python scripts/s7_selection_and_stats.py
python scripts/s8_enhance_rq2_selection.py
python scripts/s9_paper_support.py
python scripts/s5_review_response_stats.py
python scripts/s10_selector_robustness.py
python scripts/s11_review_hardening_stats.py
python scripts/s4_figures.py- The sparse top-k results are an oracle fidelity baseline, not a claim of wall-clock speedup.
- The Monarch-related benchmark uses a simplified block-diagonal proxy, not the full Monarch matrix design space.
- The main cross-model probe uses a banded-local intervention and should be interpreted as structure sensitivity, not a complete semantic explanation of model reasoning.
- The supplemental PLR probe is currently limited to selected Qwen3 heads and should be read as targeted orthogonal evidence, not a full cross-model double dissociation.
- Local model checkpoints are not included.
The public artifact contains prompts, scripts, CSV results, figures, and reproducibility metadata. The manuscript draft and internal review notes are private and are not part of this repository.
No explicit license has been selected yet. Please add one before public reuse if needed.