Structural Guidance for Transformer Language Models

Peng Qian, Tahira Naseem, Roger Levy, Ramón Fernandez Astudillo

Sure, here is a blog-style summary of the paper "Structural Guidance for Transformer Language Models":

TL;DR

This paper explores how to make Transformer language models better at understanding and generalizing syntactic structures, mimicking human language acquisition. They propose two methods, "Generative Parsing" and "Structural Scaffold," which guide the models using explicit syntactic information during training, leading to improved generalization without requiring massive pre-training datasets.

What Problem Does This Paper Address?

Transformer language models, like GPT-2 and BERT, have achieved remarkable success in natural language processing. However, despite their impressive performance, they often lack the systematic and robust linguistic generalization that humans exhibit. This is partly because Transformers, unlike older recurrent neural networks (RNNs), don't have built-in inductive biases for sequential processing. While Transformers can implicitly learn syntactic information, this paper investigates whether explicitly providing structural guidance during training can lead to more human-like syntactic generalization, especially when data is limited. The core challenge is to imbue these powerful but structurally "naive" models with a better understanding of grammar.

Methods

The authors propose two main approaches to provide structural guidance:

  • Generative Parsing as Language Modeling (PLM): This method jointly models the generation of both the sentence (words) and its corresponding constituency parse tree. It treats the process of building a parse tree and generating words as a single sequence modeling task. The model learns to predict actions that incrementally build the tree and output words. This is inspired by prior work on RNNs but adapted for Transformers.
  • Structural Scaffold (ScLM): This approach uses a multi-task learning objective. It adds an auxiliary task during training where the model learns to predict syntactic information (specifically, n-grams of parsing actions) alongside the main language modeling task. This additional "scaffolding" loss helps regularize the model's representations. The authors explore two variants: predicting past n-grams (ScLM-past) and predicting future n-grams (ScLM-next).

A third method, PLM-mask, is also explored, which modifies the attention mechanism in the Transformer to focus on specific parts of the parse tree, inspired by "stack-Transformers."

Datasets

  • Training: The models are trained on subsets of the BLLIP dataset: BLLIP-MD (14 million tokens) and BLLIP-LG (46 million tokens). These are English newswire corpora that have been automatically parsed.
  • Evaluation:
    • SG Test Suites: A collection of hand-designed test suites for evaluating fine-grained syntactic generalization.
  • BLiMP Benchmark: A benchmark featuring minimal pairs of grammatical and ungrammatical sentences to test linguistic generalization. For computational efficiency, a down-sized version, BLiMP-10% (the first 10% of items from each test), is used.

Key Insights and Ideas

  • Explicit structure helps generalization: Providing explicit syntactic guidance during training significantly improves Transformer models' ability to generalize syntactic knowledge, especially with limited data.
  • Generative parsing is most effective: The "Generative Parsing as Language Modeling" (PLM) approach shows the most consistent benefits in improving syntactic generalization compared to the baseline Transformer language model.
  • Scaffolding offers some benefit: The "Structural Scaffold" approach provides some improvement over the baseline but is generally less effective than generative parsing.
  • Masking attention is less impactful: Dynamically masking attention heads based on syntactic structure (PLM-mask) did not yield consistent benefits over the standard PLM.
  • Perplexity vs. Generalization: Models can achieve similar word-level perplexity (a measure of how well they predict the next word) but exhibit dramatically different syntactic generalization performance, highlighting that perplexity alone is not a sufficient indicator of linguistic understanding.

Key Results

  • Models with structural guidance (PLM, ScLM) consistently outperform the vanilla Transformer language model (LM) trained on the same data.
  • On the SG Test Suites, PLM models achieve higher accuracy than LMs, with scores of 0.723 (BLLIP-LG) compared to 0.665 for LMs. PLM-mask also performs well, achieving 0.748.
  • On BLiMP-10%, PLM models also show improvements, reaching 0.751 compared to 0.708 for LMs.
  • The PLM method was able to close the gap between a small, randomly initialized Transformer and a pre-trained GPT-2 small model by about half on the SG Test Suites.
  • Structural guidance robustly improves learning for specific phenomena like subject-verb agreement and NPI licensing.

Limitations and Future Work

  • Scaffold limitations: The authors hypothesize that their scaffold approach might not fully exploit the compositional structure of local parses because it models each action n-gram as a distinct type. They suggest designing new scaffolds that can better leverage the combinatorial nature of syntax.
  • Scaling syntactic supervision: It remains an open question whether scaling syntactic supervision to larger datasets than BLLIP-LG would further close the gap with pre-trained models.
  • Future work: The authors suggest exploring alternative structural guidance strategies that combine the strengths of generative parsing and scaffolding. They also note that their work focuses on syntactic generalization and that future work could explore other linguistic phenomena.

Summary updated

BibTeX
@inproceedings{qian2021structural,
  author = {Peng Qian and Tahira Naseem and Roger Levy and Ramón Fernandez Astudillo},
  title = {{Structural Guidance for Transformer Language Models}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2021},
  url = {https://openreview.net/forum?id=1RvfRtbhugF},
}
Figure