StructLens: A Structural Lens for Language Models via Maximum Spanning Trees

Haruki Sakajo, Frederikus Hudi, Yusuke Sakai, Hidetaka Kamigaito, Taro Watanabe · Submission to ICLR 2026 · Rejected

TL;DR

StructLens is a new analytical framework that treats the internal layers of Large Language Models (LLMs) as structural networks rather than just stacks of vectors. by building Maximum Spanning Trees (MSTs) from residual streams, it reveals how models organize information holistically, leading to superior performance in practical tasks like layer pruning compared to traditional methods.

What Problem Does This Paper Address?

Despite the massive success of Large Language Models, our tools for "looking under the hood" are often surprisingly narrow. Most mechanistic interpretability research focuses on individual tokens or specific attention heads. When researchers want to compare two layers, they typically use cosine similarity—a metric that compares tokens at the exact same position across layers.

The authors argue that this approach misses the "forest for the trees." Language is inherently structural (think of grammar and syntax), yet our analysis tools often ignore the global, inter-token relationships formed within a single layer. By failing to capture this holistic structure, we struggle to understand how information is actually transformed as it moves through the model, which limits our ability to optimize these models through techniques like pruning.

Methods

The researchers introduce StructLens, which shifts the focus from position-wise comparisons to structural ones. Here is the breakdown of their approach:

  1. Graph Construction: For every layer, they treat each token as a node in a graph. The "weight" of the edge between two tokens is determined by the similarity (specifically, the exponential of the negative L2 distance) of their representations in the residual stream.
  2. Maximum Spanning Trees (MSTs): To find the most important structural backbone of a layer, they construct an MST. This is a tree that connects all tokens using the strongest possible relationships while remaining acyclic. Because LLMs are auto-regressive (reading left-to-right), they use a single-root, forward-moving MST.
  3. Structure-Aware Metrics: Instead of just comparing vectors, they compare these trees across layers using:
  4. Tree Edit Distance: How many operations (insert, delete, relabel) are needed to turn one layer's tree into another's.
  5. Edge Edit Distance: A simpler count of how many edges differ between two trees.
  6. Cos-Struct: A method of aggregating subtree representations before calculating cosine similarity.

Datasets

The study evaluates several prominent open-source models, including Llama 3.1 (8B and 70B) and Qwen 2.5 (7B and 72B). To test these models across different linguistic tasks, they used:

  • MMLU & CMMLU: Massive Multitask Language Understanding benchmarks (English and Chinese) for general knowledge and reasoning.
  • Multinews & VCSUM: English and Chinese summarization datasets to test how models handle long-form structural information.
  • Wikipedia: Used for calibrating layer importance during pruning experiments.

Key Insights and Ideas

  • The "Island" Pattern: When visualizing inter-layer similarity using Edge-Edit distance, the researchers discovered distinct diagonal blocks they call "islands." This suggests that models process information in stages, where groups of adjacent layers maintain a very similar internal structure before a major transformation occurs.
  • Sequential Construction: By mining frequent subtrees, they found that models tend to build structures from left to right. Interestingly, structures formed early in the model often become "obsolete" and are replaced by new structures in deeper layers as the model integrates more context.
  • Model-Specific Strategies: Llama and Qwen aren't just different in their weights; they have different "philosophies." In Llama 3.1 8B, subtrees of contiguous tokens are most frequent in the middle layers. In Qwen 2.5 7B, the proportion of these contiguous structures actually increases toward the final layers.
  • Structure vs. Confidence: There is a strong correlation between structural transformations (captured by StructLens) and the model's final output confidence. If you prune a layer that is in the middle of a major structural shift, the model's performance tanks.

Key Results

The most practical application of StructLens is in Layer Pruning. The authors compared their structure-aware metrics against the current state-of-the-art pruning method, ShortGPT (which uses standard cosine similarity).

  • Higher Accuracy: On the MMLU benchmark, pruning 28% of Llama 3.1 8B layers using StructLens metrics resulted in significantly higher accuracy (e.g., 56.9% for Cos-Struct vs. 41.4% for the standard Cos-Base).
  • Lower Perplexity: In almost all cases, structure-aware pruning maintained lower (better) perplexity than position-wise methods, proving that the MSTs are capturing the "essential" work the model is doing.
  • Statistical Significance: The improvements were not just marginal; they were statistically significant ($p < 0.05$) across multiple models and datasets.

Limitations and Future Work

The authors acknowledge a few hurdles:

  • Metric Sensitivity: The "best" structural metric (Edge-Edit vs. Cos-Struct) varies depending on the specific model architecture and the task at hand. There isn't a "one size fits all" metric yet.
  • Computational Cost: Building MSTs for every layer across many samples is more computationally expensive than simple vector comparisons, though the authors used an $O(n^2)$ algorithm to keep it manageable.
  • Static vs. Dynamic: While they capture dynamic structures formed during inference, the study focuses on the residual stream. Future work could integrate these structural insights with other components like Multi-Head Attention or Sparse Autoencoders (SAEs) to get an even clearer picture of the model's "mental map."

Summary updated

BibTeX
@inproceedings{sakajo2026structlens,
  author = {Haruki Sakajo and Frederikus Hudi and Yusuke Sakai and Hidetaka Kamigaito and Taro Watanabe},
  title = {{StructLens: A Structural Lens for Language Models via Maximum Spanning Trees}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=9HF1y6JGjp},
}
Figure