Composition, Attention, or Both?

Ryo Yoshida, Yohei Oseki

Introduction

The rise of Large Language Models (LLMs) has reignited a fundamental debate in computational linguistics: do neural networks truly capture the hierarchical structure of human language, or are they merely sophisticated statistical engines operating on surface-level patterns? While Transformer-based models like GPT-4 exhibit remarkable capabilities, they typically treat language as a flat sequence of tokens. In contrast, traditional theories of generative grammar suggest that language is inherently recursive and hierarchical.

Researchers from the University of Tokyo have proposed a middle ground with Composition Attention Grammars (CAGs). This novel architecture integrates the recursive subtree composition found in Recurrent Neural Network Grammars (RNNGs) with the selective self-attention mechanism of Transformers. Their findings suggest that this hybrid approach provides a superior model for human-like syntactic generalization.

The CAG Architecture: Merging Composition and Attention

Historically, two paradigms have dominated syntactic modeling. RNNGs utilize explicit composition functions to build tree structures recursively, which is cognitively plausible but often limited in representational capacity. Transformers use self-attention to weigh the importance of various words, but they lack an explicit mechanism for hierarchical grouping.

CAGs bridge this gap using a stack-based system governed by three primary actions:

  1. GEN(x): Pushes a terminal word onto the stack.
  2. NT(X): Opens a new non-terminal phrase (e.g., a Noun Phrase).
  3. REDUCE: The "Composition" phase. When a phrase is closed, a bidirectional LSTM processes the components of that phrase, "squashing" them into a single vector representation of the resulting subtree.

The "Attention" component is applied after every action. Instead of relying on a fixed-length hidden state, the model employs a self-attention mechanism to look back at all vectors currently residing on the stack. This allows the model to dynamically weigh previous structural information to predict the next grammatical action.

Experimental Methodology

To isolate the impact of architecture from the benefits of scale, the researchers conducted a strictly controlled experiment. They compared CAGs against LSTMs, RNNGs, and standard Transformers, keeping the model size nearly identical at approximately 16.6 million parameters.

The models were trained on the BLLIP-LG dataset, which consists of roughly 1.8 million sentences (42 million tokens) of news-style text. Evaluation was conducted using SyntaxGym, a benchmark designed to test models on specific linguistic "circuits," including:

  • Agreement: Subject-verb agreement across intervening clauses (e.g., "The keys to the cabinet are...").
  • Center Embedding: Processing nested clauses (e.g., "The boy the dog bit ran away").
  • Long-Distance Dependencies: Tracking relationships between distant words in a sentence.

Key Findings and Insights

The results indicate that CAGs are highly effective at capturing syntactic nuances:

  • State-of-the-Art Performance: CAGs achieved an overall accuracy of 83.8% on SyntaxGym, significantly outperforming standard Transformers (48.1%) and the original RNNG architecture (81.1%).
  • Efficiency of Structure: Remarkably, the 16.6M parameter CAG model outperformed GPT-2, despite GPT-2 having seven times the parameters and being trained on 250 times more data. This suggests that explicit structural inductive biases are more efficient for syntactic learning than raw scale.
  • The "Syntactic Filter" Hypothesis: The study found that recursive composition acts as a filter, allowing syntactic features (like plurality) to percolate up into subtree representations while filtering out more complex semantic features. This explains why CAGs excel at grammar but can struggle with semantic-heavy tasks.
  • The Perplexity Paradox: A critical insight from the study is that lower perplexity (the standard metric for word prediction) does not necessarily correlate with better syntactic generalization. Models that were better at predicting the next word were sometimes worse at human-like linguistic processing, suggesting that current optimization targets may not align perfectly with linguistic competence.

Limitations and Future Directions

The primary challenge for CAGs is computational efficiency. Because the stack state changes dynamically based on the composition function, the model is difficult to parallelize or "batch" effectively. Training the CAG model required two weeks on eight NVIDIA V100 GPUs—a significantly higher cost than a standard Transformer of equivalent size.

Future research will likely focus on optimizing these recursive attention mechanisms. Potential avenues include the use of "linear attention" or sparse attention techniques to allow CAGs to scale to larger datasets and longer sequences without the prohibitive computational overhead.

Conclusion

Composition Attention Grammars demonstrate that the choice between recursive composition and self-attention is a false dichotomy. By combining both, CAGs achieve a level of syntactic sophistication that eludes much larger, sequence-based models. This work underscores the importance of structural inductive biases in the quest to build machines that process language with human-like depth.

Summary updated

BibTeX
@inproceedings{yoshida2022composition,
  author = {Ryo Yoshida and Yohei Oseki},
  title = {{Composition, Attention, or Both?}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2022},
  doi = {10.18653/v1/2022.findings-emnlp.428},
}
Figure