StructLens: A Structural Lens for Language Models via Maximum Spanning Trees
summary
The gist
The gist The STRUCTLENS framework constructs maximum spanning trees based on semantic representations in residual streams to analyze token relationships holistically, revealing middle-layer
In short
STRUCTLENS builds maximum spanning trees (MST) from token representations in residual streams to create a holistic structural view of language models. It reveals that middle layers show the strongest local-span organization, showing how token relationships evolve during training and how different layers interact structurally.
Key concepts
- Maximum Spanning Tree (MST)
- This is a tree structure built using token representations from different layers. The edges in this tree represent the similarity between tokens, with the goal of connecting all tokens in a way that maximizes their overall relationship structure within that specific layer's representation space.
- Contiguous Subtree Ratio
- This metric measures how densely connected subtrees are concentrated on contiguous sequences of tokens. A high ratio means that groups of related tokens tend to be adjacent to each other in the original token sequence, indicating strong local organization.
- Edge Edit Distance
- This is a metric used to measure the dissimilarity between two layers based on their structural trees. It counts the minimum number of edge changes needed to transform one layer's tree structure into another's, helping quantify how structurally similar or different two layers are.
Terminology used across episodes
This episode discusses
The paper
StructLens: A Structural Lens for Language Models via Maximum Spanning Trees · Read on arXiv
Haruki Sakajo, Frederikus Hudi, Yusuke Sakai, Hidetaka Kamigaito, Taro Watanabe
Nara Institute of Science and Technology
Language exhibits inherent structures, a property that explains both language acquisition and language change. Given this characteristic, we expect language models to manifest their own internal structures as well. While interpretability research has investigated how models compute representations mechanistically through attention patterns and Sparse AutoEncoders, the organization of the resulting representations is overlooked. To address this gap, we introduce StructLens, a framework to analyze representations through a holistic structural view. StructLens constructs maximum spanning trees based on the semantic representations in residual streams, inspired by tree representation in dependency parsing, and provides summaries of token relationships in representation space. We analyze how contiguous tokens are also nearby in representation space and find that middle layers show the strongest local-span organization. Moreover, analysis of pre-training checkpoints reveals that smaller local units become detectable earlier in pre-training, and larger units later. Our findings demonstrate that StructLens provides insights into how models organize token representations across layers and training. Our code is available at https://github.com/naist-nlp/structlens.
Transcript
Introduction to the show: ident: AI Radio. Generated commentary on the latest Artificial Intelligence papers.
Tom: We're looking at the paper: "StructLens: A Structural Lens for Language Models via Maximum Spanning Trees".
Jane: Here's the gist of the paper. The gist The STRUCTLENS framework constructs maximum spanning trees based on semantic representations in residual streams to analyze token relationships holistically, revealing middle-layer local-span organization in language models.
Tom: How it works STRUCTLENS introduces a framework to analyze representations through a holistic structural view by constructing maximum spanning trees (MSTs) based on the semantic representations in residual streams, inspired by tree representation in dependency parsing, and provides summaries of token relationships in representation space The approach analyzes residual streams at each layer’s output, computing L2 distance between token semantic representations to construct an MST at each layer.
Jane: The formal process begins by defining a pairwise similarity matrix W(l) ∈ R n×n where W(l)i,j = 1 / (1 + h(l)i - h(l)j, if i!= j 0 otherwise.
Tom: This matrix defines a complete graph G without self-loops, where each edge encodes a relation between two tokens.
Title and authors: Tom: So we're looking at this paper called StructLens: A Structural Lens for Language Models via Maximum Spanning Trees and it’s about getting a structural view of how language models organize their internal representations across different layers.
Jane: That sounds like it might be useful because right now we often look at the model's output or maybe just how attention patterns work, but this paper tries to look at the actual structure connecting the tokens themselves in those hidden states.
Tom: Exactly. The core idea is they construct maximum spanning trees based on semantic representations in residual streams, which is inspired by how you might see a dependency tree in parsing, but applied directly to the model's internal layers.
Lu: What it’s reaching for here is moving away from just looking at static grammatical structures that linguists assume are there and instead analyzing the dynamic structures that emerge bottom-up during pre-training, as they say on page two of StructLens: A Structural Lens for Language Models via Maximum Spanning Trees <ref:2603.03328#pg1,StructLens: A Structural Lens for Language Models via Maximum Spanning Trees>.
Meng: So if I'm thinking about deployment, what does this structural view actually give me? Does it help me figure out where the model is most vulnerable when we try to prune layers later?
Jane: Well, the paper suggests that by building these spanning trees at each layer—using a pairwise similarity matrix defined by L2 distance between token representations—they get a summary of token relationships in representation space.
Tom: Right, they define this similarity matrix W where the similarity between two tokens i and j at layer is one divided by one plus the L2 distance between their semantic representations, if they aren't the same token.
Jane: Then they build a forward constrained adjacency matrix A, which essentially takes that pairwise similarity and turns it into a directed structure by picking the most similar preceding token for each node, assuming a unique predecessor.
Lu: This process results in an order-constrained directed tree for each layer using Chu-Liu/Edmonds’ algorithm, which then summarizes the geometry of those token representations as an order-constrained tree.
Title and authors: Meng: Okay, so they build this tree structure for every single layer output? That sounds like a lot of computation if you're running this on a large model during inference or fine-tuning.
Tom: It is computationally intensive, but they do it to provide that holistic view beyond just token-level interpretations, which is what page three of StructLens: A Structural Lens for Language Models via Maximum Spanning Trees mentions <ref:2603.03328#pg1,StructLens: A Structural Lens for Language Models via Maximum Spanning Trees>.
Jane: And they go further by introducing local-span connectivity metrics to analyze these trees, like the contiguous subtree ratio and the contiguous token ratio.
Lu: The findings suggest that from lower to middle layers, specifically between zero percent and fifty percent of the layer percentage, both of these ratios become larger.
Tom: Which means that as you go up through those middle layers, those local structures—the contiguous token intervals—become more frequent and more widely distributed across the tokens.
Jane: That's interesting because it implies that the model starts developing these tight local organizations early on during pre-training, but they get denser and more dominant in later training steps.
Meng: Wait, so how does that relate to what we see in training dynamics? Earlier checkpoints show the contiguous token ratio increasing, which is good for initial learning. But later checkpoints show the contiguous subtree ratio increasing sharper, suggesting larger-span fragments dominate.
Lu: That points to something specific about the model's development path; it seems the model first develops short-range local connectivity, and then later training consolidates that connectivity into denser, larger-span tree fragments.
Tom: So earlier training builds the small connections, and later training takes those small connections and merges them into bigger ones. That’s a clear signal about how the organization evolves during pre-training checkpoints.
Jane: This structural insight is important because it shows *when* these local organizations become dominant, which is much more informative than just looking at final accuracy metrics.
Meng: What about inter-layer relationships? Is this framework useful for figuring out if two different layers are actually doing similar work or if they're collaborating in some structural way?
Tom: The paper introduces three structure-aware similarity metrics to measure that, including Cosine Similarity for StructLens, which compares the aggregated root representations of two layers.
Title and authors: Jane: They also have Tree Edit Distance and Edge Edit Distance, which measure dissimilarity between the actual ordered trees constructed for two different layers.
Lu: The analysis using these inter-layer similarity metrics shows that Edge-Edit exhibits diagonal clustering patterns, forming discrete groupings they call islands that remain consistent across model family and size.
Meng: So if we see these islands in the layer similarity space, it might give us some structural clues about how those layers cooperate or overlap internally.
Tom: And on the practical side, they also propose using these structural metrics like CosStruct-BI and TreeEdit-BI to signal layer influence for pruning, and they claim these outperform non-structural metrics for Llama3 point 1 8B Instruct.
Jane: But they also flag a limitation here; the paper says that while tree-aware metrics provide insights into layer pruning, they are inconsistently robust across different datasets and models, which limits their direct applicability to model optimization right now.
Lu: So, the big picture is that StructLens gives us a powerful tool for interpretability by revealing how token representations are organized across layers and during pre-training.
Tom: It’s definitely valuable for understanding the internal workings of these models because it moves beyond just static patterns and looks at the dynamic structure of their learned representations.
Jane: So, to wrap up, we've seen how they build maximum spanning trees from residual streams to map token relationships across layers, discovered that middle layers show strong local organization, and found ways to use structural metrics for pruning insights.
Lu: And they pointed out that the training dynamics reveal a progression from short-range local connectivity early on to denser, larger-span fragments later.
Meng: From an engineering standpoint, it gives us a way to quantify what’s happening internally without relying on just a single performance number across the board.
Lalam: I'm confident in this direction; the paper provides concrete mechanisms for analyzing these structural properties, and I see how this helps in understanding the stability of these internal structures.
Tom: So we’ve got a lot to unpack about StructLens, from its mechanics to its implications for training dynamics and layer analysis.
Jane: It sounds like a framework that really helps us see the hidden architecture beneath the surface of what an LLM is actually doing internally.
The paper's summary: Tom: So, StructLens is essentially trying to build a structural map of how an AI model organizes its internal representations layer by layer using these maximum spanning trees based on L2 distances between tokens at each output.
Jane: That's a really dense way of saying they're constructing these trees—these maximum spanning trees—based on the semantic representations in the residual streams, which basically gives them a holistic structural view of what’s happening inside the model.
Lu: Exactly. They’re inspired by how you might see a dependency tree from parsing, but applied directly to how tokens relate to each other within those hidden layers. It’s about getting that structural organization out loud instead of just looking at the final output accuracy.
Meng: From a deployment side, if this map is so detailed, it means we can actually start spotting where things get messy at scale, right? Where does the model start losing coherence?
Tom: Right. The paper goes into analyzing these trees with local-span connectivity metrics like the contiguous subtree ratio and the contiguous token ratio to quantify how much those connected tree fragments are stuck on actual, adjacent tokens in the representation space.
Jane: So what they found is that from lower to middle layers—say, between zero percent and fifty percent of the layer percentage—both of these ratios actually get bigger.
Lu: That means as you go up through those middle layers, that local structure becomes more frequent and more widely distributed across all the tokens in the model. It’s a key finding about where that organization is happening.
Tom: And then they look at training dynamics, and it shows how this changes during pre-training checkpoints, revealing that smaller local units become detectable earlier, but then later training consolidates those small connections into denser, larger-span tree fragments.
Jane: That implies the model starts building these short-range local connections first during early pre-training before it starts merging them into bigger structures later on. It’s a timeline for how the model learns its internal organization.
Meng: So what does that tell us about deployment? If we know *when* those larger, denser fragments form, maybe we can optimize for that specific stage of development instead of treating all layers the same way.
Tom: And they also look at inter-layer similarity using three metrics—Cosine Similarity for StructLens, Tree Edit Distance, and Edge Edit Distance—to measure how similar two different layers are to each other structurally.
Jane: The results on those similarity metrics show that Edge-Edit exhibits diagonal clustering patterns that form discrete groupings they call islands which stay consistent across different model families and sizes.
Lu: Those islands suggest there are specific structural relationships between layers that don't change much, regardless of the size or architecture of the AI. It points to some underlying, stable internal architecture in how these models connect.
Tom: And finally, they suggest using those structural metrics for layer pruning because they seem to outperform non-structural metrics when we look at models like Llama3 point one 8B Instruct.
Jane: The big picture here is that StructLens gives us a way to see the hidden architecture of these LLMs by mapping token relationships across layers, showing us *when* and *how* they build those organizational structures during training.
Lu: It’s a tool for interpretability, definitely expanding how we analyze these models internally. But they do flag that the structural metrics aren't perfectly robust across every single dataset or model size yet, so it’s not a perfect plug-and-play solution for pruning optimization right now.
Meng: So what I take away is that we have a new way to visualize the internal structure, which helps us understand *why* the model behaves the way it does during specific phases of training.
Jane: And this structural insight into middle layers showing strong local organization gives us a target—that’s where we might find the most interesting patterns to investigate next.
The paper's improvements: Tom: So, StructLens isn't just about building these trees; they also suggest using those structural metrics—like CosStruct-BI or TreeEdit-BI—to actually signal layer influence for pruning, and they claim those are better than non-structural metrics for models like Llama3 point one 8B Instruct.
Jane: That’s a practical implication, Tom; it means instead of just looking at raw performance numbers to decide which layers to cut out, you can look at the tree structure itself to get a hint about what layer is doing the most important work.
Lu: They're suggesting that these structural metrics might give us some clues about layer pruning, but they admit that those structural metrics aren't perfectly consistent across different datasets and models yet.
Meng: That inconsistency is a big deal for me; if the pruning signal changes depending on the data, it makes deploying this framework to production a bit risky right now.
Tom: Right, so while it’s promising for insight, they’re saying we can use these metrics to get initial ideas about layer importance, but we need more work to make those metrics reliable enough for real-world optimization.
Jane: And I think the authors are being honest there; they aren't claiming it solves layer pruning completely, but they are pointing toward a new direction where structure matters in model design.
Lu: They also touch on how these structural metrics can actually uncover non-adjacent layer collaboration by observing specific subtree patterns across layers that aren't directly next to each other.
Tom: So if you see those specific patterns linking two distant layers, it suggests those layers are cooperating during inference in a way we wouldn't see just looking at adjacent layer data.
Jane: That’s a really interesting thought; it implies that the organization isn't strictly top-down or bottom-up but can have these more complex structural dependencies across the whole stack.
Meng: If those non-adjacent collaborations are real, then we need to look at how we design our inference pipeline to account for that cross-layer communication instead of treating them as isolated components.
Lu: The overall idea is that this framework gives us a deeper understanding of the model's internal blueprint, showing us not just what the final output is, but how every layer contributes structurally to it.
Tom: So, it’s moving from just seeing the result to understanding the internal mechanics of how those results are being built up through these sequential layers.
Jane: And this deeper structural understanding is what we need as we try to build more reliable AI systems, because knowing *how* something works is often just as important as knowing *what* it does.
Conclusion: Tom: So StructLens is showing us how to build maximum spanning trees based on token semantic representations across residual streams to get a holistic view of those token relationships in language models.
Jane: Basically, they’re using these trees—maximum spanning trees—to map out how tokens are related inside the model layers, which is way more detailed than just looking at simple output scores.
Lu: The core idea is taking the L2 distance between token representations at every layer and using that to build a directed tree summary for each layer, which gives us that order-constrained structure we were talking about earlier.
Meng: From a practical standpoint, if we can get this structural map, it gives us something concrete to analyze when we’re trying to figure out why a model might be failing at scale during fine-tuning.
Lalam: I'm sure of the answer here; the paper shows that these tree summaries are a very reliable way to represent the geometry of those residual streams.
Tom: They also introduced metrics like contiguous subtree ratio and contiguous token ratio to check if those connected tree fragments are actually localized on adjacent tokens in the representation space.
Jane: And what they found is that the middle layers show strong local organization, meaning that as you go up through them, those tight local structures become more frequent and widely distributed across the tokens.
Lu: That means there’s a specific structural behavior happening in those middle layers during training that we can target for analysis.
Meng: It changes how I think about model optimization because it gives us a structural reason why certain layers might be behaving differently than others, even if their raw performance numbers look similar.
Tom: And they also looked at inter-layer similarity using three different metrics—Cosine Similarity for StructLens, Tree Edit Distance, and Edge Edit Distance—to see how structurally similar two different layers are to each other.
Jane: The results on those similarity metrics indicated that Edge-Edit showed diagonal clustering patterns forming these islands which stay consistent across different model sizes and families.
Lu: Those islands suggest there are stable structural relationships between layers that don't change much, which is a big piece of information about the AI's architecture.
Tom: So to wrap up, StructLens gives us a new way to see the internal organization by mapping token relationships through maximum spanning trees across residual streams.
Jane: It really helps us see the hidden structure behind what an LLM is actually doing internally, revealing how they organize their representations layer by layer.
Lu: It’s a valuable tool for interpretability that shows us *when* and *how* those local organizations emerge during training, which is super helpful for understanding the learning process itself.
Meng: I’m still cautious because they admit those structural metrics aren't perfectly robust across every single dataset yet, so we can use them as strong hints but not the final word for pruning decisions.
Lalam: I'm confident that this framework provides a concrete mechanism for analyzing these internal structures and is a very solid direction for future research in representation learning.
Tom: So, StructLens is definitely moving us toward understanding the inner workings of these models by focusing on their structural blueprint through those spanning trees.
Jane: It’s really opening up new avenues for us to ask deeper questions about how these large language models are actually thinking and organizing information internally.
More episodes
- 2512.02088-Comparing Baseline and Day-1 Diffusion MRI Using Multimodal Deep Embeddings for Stroke Outcome Prediction
- 2512.06746-Align, Don't Blend: Orthogonal Supervision Disentanglement As the Key to Generalizable AI-Generated Image Detection
- 2512.08945-Algorithmic Reflectivity in Large Language Models: Methodological Study of Linguistic Structure in Mentalization
- 2601.13235-RubRIX: Rubric-Driven Risk Mitigation in Caregiver-AI Interactions
- 2601.16823-Disentangling generalization and memorization in large language models using chess
- 2601.17454-Does Centralized Learning Help Embodied Agents Coordinate, and When Can a Tabular Study Tell?
- 2601.18702-From Fuzzy to Exact: The Halo Architecture for Infinite-Depth Reasoning via Rational Arithmetic
- 2602.02133-A Theoretical Analysis of Why Masked Diffusion Models Mitigate the Reversal Curse
- 2602.03608-Controlling Output Rankings in LLM-Based Search via Generative Engine Optimization
- 2602.05286-HealthMamba: An Uncertainty-aware Spatiotemporal Graph State Space Model for Effective and Reliable Healthcare Facility Visit Prediction