Compressed Sensing for Capability Localization in Large Language Models

Anna Bair, Yixuan Even Xu, Mingjie Sun, J Zico Kolter

TL;DR

This paper introduces a novel compressed sensing approach to efficiently identify small, specialized subsets of attention heads within large language models (LLMs) that are crucial for specific capabilities like math or coding. They demonstrate that ablating just a few of these "task-specific heads" can significantly degrade performance on that task, while leaving other capabilities largely unaffected, suggesting a modular organization within LLMs.

What Problem Does This Paper Address?

Large Language Models (LLMs) have become incredibly powerful, exhibiting a wide range of capabilities from mathematical reasoning to code generation. However, understanding how these models achieve these complex skills and where these capabilities are localized within their vast neural architectures remains a significant challenge. While previous work has localized factual knowledge to specific neurons or layers, it's unclear if complex behaviors are similarly localized. This paper aims to bridge this gap by identifying specific components (attention heads) responsible for distinct capabilities, moving beyond simple fact retrieval to higher-level skills.

Methods

The core of this paper is a compressed sensing-based method for identifying "task-specific heads." This approach leverages two key assumptions:

  1. Sparsity: For any given task, only a small subset of attention heads is critical.
  2. Additivity: The combined effect of ablating multiple heads is approximately the sum of their individual impacts.

Instead of exhaustively testing each head (which is computationally prohibitive for large models), they use a compressed sensing framework. This involves:

  • Constructing a measurement matrix ($\Phi$): This matrix defines various combinations of heads to "ablate" (set their output to zero). They explore two strategies: Bernoulli (random) sampling and Stratified Sampling (balanced to ensure each head is measured roughly equally).
  • Evaluating ablations: The LLM is evaluated on a target task for each combination defined by $\Phi$.
  • Solving a Lasso regression: This statistical technique, applied to the observed performance drops, recovers an estimate of each head's contribution to the task. Heads with the largest negative coefficients (indicating significant performance degradation when ablated) are identified as task-specific.

This method is significantly more efficient than naive greedy approaches, requiring far fewer model evaluations.

Datasets

The authors evaluate their method across several tasks and datasets:

  • Mathematical Reasoning: GSM8K, Arithmetic
  • Code Generation: MBPP, HumanEval
  • Linguistic Behaviors: Custom datasets for swearing and rhyming.
  • General Capability Benchmarks: HellaSwag, BoolQ, Arc Challenge, MMLU (used to assess specificity and generalization).

For the compressed sensing method's head identification phase, they use smaller subsets (e.g., 100 samples) of GSM8K and MBPP to speed up the process.

Key Insights and Ideas

  • Modular Organization: The most striking finding is that LLMs appear to organize complex capabilities in a modular fashion, with specific attention heads acting as dedicated components for tasks like math or coding.
  • Extreme Sparsity: A surprisingly small number of heads (as few as five) can be responsible for a significant portion of a model's performance on a specific task.
  • Task-Specific Heads are Necessary, Not Sufficient: Ablating these heads severely degrades performance, but retaining only these heads doesn't fully recover performance, indicating other network components are also involved.
  • Universal Heads: Beyond task-specific heads, they identify "universal heads" that are critical across multiple tasks, suggesting they handle core computations for general language understanding. Ablating these leads to more pathological failure modes (e.g., repetitive outputs).
  • Scale Dependence: Larger models seem to exhibit stronger localization, possibly due to increased capacity allowing for more specialized components.

Key Results

  • Ablating the top five identified task-specific heads can degrade performance by up to 60% on benchmarks like GSM8K.
  • This degradation is highly specific: performance on unrelated tasks (e.g., general language benchmarks) is largely preserved, with drops of less than 2%.
  • The compressed sensing method achieves comparable accuracy to greedy methods but with up to 50x fewer evaluations.
  • Task-specific heads identified for one dataset (e.g., GSM8K) also significantly impact performance on other datasets measuring the same capability (e.g., Arithmetic).
  • Universal heads, when ablated, cause more general performance degradation and lead to unusual failure modes, such as generating repetitive or nonsensical outputs.

Limitations and Future Work

  • Linearity Assumption: The compressed sensing method relies on an assumption of approximate linearity for head contributions. While empirically validated, it's acknowledged that LLMs are inherently non-linear.
  • Interactions: The current method doesn't explicitly model higher-order interactions between heads, which some other methods (like ProxySPEX) do, though this comes at a computational cost.
  • "Noise" Heads: The paper notes that sometimes more than five heads are identified, and there's a plateauing effect where ablating additional heads yields diminishing returns. They filter out some heads that appear to be "universal" or less task-specific.
  • Future Work: The authors suggest their method can be a crucial step for deeper mechanistic interpretability studies, model editing (e.g., targeted capability removal or modification), and AI safety research. They also point to investigating how these localized capabilities emerge and the role of universal heads in more detail.

Summary updated

BibTeX
@inproceedings{bair2026compressed,
  author = {Anna Bair and Yixuan Even Xu and Mingjie Sun and J Zico Kolter},
  title = {{Compressed Sensing for Capability Localization in Large Language Models}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=X4MFtxw1sB},
}
Figure