Dependency Transformer Grammars: Integrating Dependency Structures into Transformer Language Models

Yida Zhao, Chao Lou, Kewei Tu

Introduction

Standard Transformer language models have achieved remarkable success in natural language processing. However, they remain fundamentally "flat," processing sequences of tokens without an inherent understanding of the hierarchical, nested nature of human language. This lack of syntactic inductive bias often leads to poor generalization on complex grammatical structures, such as long-distance dependencies or "garden-path" sentences.

While previous attempts to address this have integrated constituency trees, this paper introduces Dependency Transformer Grammars (DTGs). DTGs argue that dependency structures—defining head-to-dependent relationships between individual words—are a more natural fit for the "point-to-point" nature of the self-attention mechanism. DTGs integrate these structures directly into the Transformer's autoregressive decoding process.

Methodology

DTGs treat language modeling as a joint task: generating a sentence and its corresponding dependency tree simultaneously. This is achieved through several key innovations:

Transition-based Simulation

Instead of predicting only the next word, the model predicts a sequence of transitions based on the "arc-standard" parsing system. These include GEN (to generate a new word), LEFTARC (LA), and RIGHTARC (RA) to establish dependency links.

Dependency tree and transition sequence for the sentence "There is a difference".

Dual Attention Mechanisms

To manage the parser state, DTGs employ two specialized attention masks:

  1. STACK Attention: This allows a position to attend to all currently "active" tokens on the parser's stack to determine the next transition.
  2. COMPOSE Attention: When a dependency arc is formed, this mask allows a "head" word to "absorb" information from its "dependent." Once absorbed, the dependent is masked out for future steps, effectively "popping" it from the stack and reducing noise for future predictions.

Stack-Depth Encoding

Rather than standard linear sequence positions, DTGs utilize the depth of a token within the parser's stack. This relative positional encoding helps the model grasp hierarchical distance regardless of how many words appear between a head and its dependent in the linear string.

Evaluation and Results

The model was trained on the BLLIP-LG dataset using "silver" dependency labels generated by a pre-trained Biaffine-roberta parser. Evaluation focused on both predictive power (perplexity) and linguistic accuracy.

Syntactic Generalization

Using the Syntactic Generalization (SG) Test Suites, which target specific phenomena like center embedding and agreement, DTGs demonstrated a significant advantage over standard models. DTGs achieved a score of 83.9, compared to 76.6 for the Transformer-XL (TXL) baseline.

Comparison of syntactic generalization scores between DTGs (Ours) and Transformer-XL (TXL) across various linguistic phenomena.

Perplexity and Parse Reranking

Crucially, this gain in syntactic understanding does not come at the cost of predictive performance. DTGs achieved a perplexity of 14.9 on BLLIP-LG, nearly identical to the TXL baseline (14.8) and far superior to previous constituency-based models. Furthermore, when used for parse reranking on the Penn Treebank, DTGs achieved a 97.0 UAS (Unlabeled Attachment Score), matching the performance of the specialized parser used to generate its training data.

Conclusion

Dependency Transformer Grammars demonstrate that baking syntactic inductive bias into the Transformer architecture significantly improves a model's ability to handle complex linguistic structures. By using dependency relations to guide attention, DTGs achieve superior generalization while maintaining competitive perplexity. Future work will explore the integration of more complex representations, such as Universal Dependencies, and the adaptation of these masks for modern, high-speed architectures.

Summary updated

BibTeX
@inproceedings{zhao2024dependency,
  author = {Yida Zhao and Chao Lou and Kewei Tu},
  title = {{Dependency Transformer Grammars: Integrating Dependency Structures into Transformer Language Models}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.acl-long.84},
}
Figure