Interpreting token compositionality in LLMs: A robustness analysis

Nura Aljaafari, Danilo S. Carvalho, André FreitasarXiv 2024 · DOI

Introduction

In linguistics, the principle of compositionality suggests that the meaning of a complex expression is derived from its constituent parts and the rules used to combine them. Researchers have long hypothesized that Large Language Models (LLMs) mirror this process, building meaning hierarchically across layers—moving from characters to tokens, then to phrases, and finally to abstract semantic concepts.

However, LLMs often exhibit extreme sensitivity to minor perturbations. This study investigates the internal mechanisms of compositionality by asking: Where does this integration occur? Is it localized in specific layers, and how robust are these internal representations if we force the model to process higher-level linguistic units (constituents) instead of individual tokens?

Methodology: Constituent-Aware Pooling (CAP)

To probe these questions, the authors introduced Constituent-Aware Pooling (CAP). This intervention modifies the model's internal state at a specific layer $m$ by grouping token activations that belong to the same linguistic unit, such as a multi-token word or a syntactic phrase.

The CAP framework intervenes within the residual block of a Transformer layer, aggregating token activations into constituent-level representations using Max, Mean, or Sum protocols.

As shown in the figure above, CAP replaces fine-grained token activations with "pooled" versions before allowing the model to complete its inference. Three primary aggregation protocols were tested:

  • Max: Selects the most prominent feature from each segment.
  • Mean: Computes the average signal of the constituent.
  • Sum: Accumulates the total information across the segment.

By measuring the model's performance after this intervention, the researchers could determine how much the model relies on individual token identities versus higher-level constituents at different depths.

Experimental Setup

The study evaluated several decoder-only models, including GPT-2, Gemma, Llama 3, and Qwen, across three tasks derived from WordNet:

  1. Inverse Definition Modelling (IDM): Predicting a word from its definition.
  2. Synonym Prediction (SP): Identifying words with equivalent meanings.
  3. Hypernym Prediction (HP): Categorizing words into broader classes (e.g., "canine" for "dog").

Key Results and Analysis

The Fragility of Early Layers

Applying CAP in the first 25% of a model's layers resulted in catastrophic performance drops. For instance, Gemma-2B's accuracy plummeted by nearly 98% on the IDM task when word-level pooling was applied at the very first layer. This suggests that early layers are not just performing simple preprocessing; they are establishing delicate, high-dimensional token-level dependencies that are easily destroyed by aggregation.

Accuracy trends across layers show that performance is highly sensitive to pooling in early layers, with a gradual, non-linear recovery as the intervention moves toward the output.

The "Delayed Aggregation" Strategy

Contrary to the hierarchical "ladder" model, the results suggest a strategy of delayed aggregation. Transformers appear to have an information-theoretic incentive to postpone semantic integration. By keeping token-level information distinct for as long as possible, the model maximizes the information gain required for its primary objective: next-token prediction. This results in a "U-shaped" or non-linear recovery curve, where performance only stabilizes in the final layers of the network.

Fragility of Scale

One of the most surprising findings is that larger models are more fragile. While a smaller model like GPT-2 (124M) might handle CAP relatively well, larger models like Llama 3 (8B) often experience more significant performance degradation. This implies that as models scale, they rely on increasingly fine-grained token features, making their internal logic more fragmented and less robust to structural changes.

Discussion and Insights

  • No "Semantic Layer": The data debunks the notion of a specific "semantic layer" where tokens suddenly become words. Instead, information processing is distributed and fragmented. Smushing tokens into words too early breaks the specific dependency paths the model requires.
  • The Superiority of Summation: The "Sum" protocol consistently outperformed "Mean" or "Max." This indicates that LLMs require the cumulative, additive signal of all constituent tokens to maintain their internal logic, rather than just a representative average.
  • Fine-tuning Limitations: While fine-tuning on specific tasks improved robustness in the later layers (75%-100%), it did little to alleviate the fragility of the early layers. The architectural bias toward token-level processing appears deeply embedded.

Conclusion

This research highlights a fundamental tension in LLM architecture: the very mechanisms that allow for high-performance next-token prediction also make the models' internal representations surprisingly brittle and non-hierarchical. If the goal is to create models that reason in a more "human-like," compositional manner, we may need to move beyond standard Transformer designs toward architectures that explicitly encourage hierarchical integration.

Summary updated

BibTeX
@misc{aljaafari2024interpreting,
  author = {Nura Aljaafari and Danilo S. Carvalho and André Freitas},
  title = {{Interpreting token compositionality in LLMs: A robustness analysis}},
  year = {2024},
  eprint = {2410.12924},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.12924},
}
Figure