There is a fundamental tension in how we understand artificial intelligence and language processing. Human language is widely considered to be compositional: we build meaning bottom-up through hierarchical structures, often represented as trees. However, Transformers—the engines behind modern large language models—utilize "all-to-all" attention architectures that can route information between any two words arbitrarily.
This raises a critical question: Do Transformers learn to mimic human-like tree structures, or do they find unstructured "black box" shortcuts that utilize their full capacity? Previous attempts to answer this required comparing model outputs to "gold" syntax trees (which linguists often debate) or training expensive "probes" that might introduce their own biases.
To address this, researchers have developed Tree Projections, an unsupervised, parameter-free method to determine if a Transformer is processing language hierarchically.
Measuring Intrinsic Computation: The Tree Projection Method
The authors introduce a concept called Span Contextual Invariance (SCI) to measure intrinsic computation structure without needing labels or extra training.
In a perfectly tree-structured (compositional) model, the representation of a phrase like "red apples" should be determined only by its components. Its internal representation shouldn't change based on surrounding context, whether the sentence is "red apples are delicious" or "I ate red apples."
To test for SCI, the researchers employ T-Shaped Masking. They compare a Transformer's standard "contextual" representation of a span to a "context-free" version created by masking out all tokens outside that specific span.
Using a greedy top-down parsing algorithm, they find the specific binary tree that minimizes the difference between these two representations across the whole sentence. This process yields a tree-likeness score. Crucially, this score is functional, not topological—it evaluates how the resulting representations behave rather than looking at raw attention weights.
Emergent Hierarchy and Generalization
The study evaluated Transformers on three benchmarks designed to test compositional generalization: COGS (semantic interpretation), M-PCFGSET (nested list operations), and GeoQuery (natural language to database queries).
The results revealed several key insights about how Transformers learn:
- Emergent Hierarchy: Transformers aren't "born" with trees, but they "grow" them. In almost all cases studied, models became significantly more tree-like as training progressed. On COGS and M-PCFGSET, these unsupervised tree projections gradually aligned with ground-truth syntax.
- Structure Predicts Generalization: Standard "in-domain" accuracy is often a poor predictor of how a model will handle compositionally novel sentences. The authors found that their tree-likeness score was a much more reliable indicator of a model's ability to generalize out-of-domain (OOD).
- Supervision Matters: Interestingly, models trained purely with a self-supervised objective (like Masked Language Modeling) did not naturally become tree-like in the low-data regimes tested. The pressure to map language to a structured output (like a logical form) appears to drive the emergence of tree-like computation.
- Unsupervised Superiority: Because it is parameter-free, this method often recovered more accurate syntactic structures than a supervised probe, suggesting the "true" tree the model uses might differ from standard human linguistic annotations.
Limitations and Future Directions
While these findings provide a powerful new lens for interpretability, the study focused on relatively small Transformers (2-6 layers) trained on specific tasks. It remains to be seen if massive Large Language Models (LLMs) exhibit the same intrinsic tree-like behavior across general web text.
Furthermore, while the models become more tree-like, they don't always match human syntax perfectly. Future work could investigate whether these "model-native" trees provide better insights into AI interpretability than traditional linguistic frameworks, potentially bridging the gap between how humans and machines understand language.
Summary updated