Unsupervised and few-shot parsing from pretrained language models

Zhiyuan Zeng, Deyi Xiong

Introduction

Syntactic parsing—the process of identifying the hierarchical structure of sentences—is a fundamental task in natural language processing. Traditionally, developing accurate parsers has required "Treebanks," which are massive datasets of sentences manually annotated by linguistic experts. The creation of these resources is both expensive and time-consuming, limiting the development of parsers for low-resource languages.

Recent research has shifted toward unsupervised parsing, which attempts to learn structure without explicit labels. While promising, these models often lag behind supervised counterparts. This paper investigates a middle ground: leveraging the implicit syntactic knowledge already embedded within large pretrained language models (PLMs) like BERT. The authors introduce a framework to "mine" this knowledge with minimal to no additional supervision.

Methodology: The Inside-Outside Framework

The core of the proposed approach lies in the "Inside-Outside" association of words, derived from the self-attention weights of a transformer-based model.

Unsupervised Approaches (UPOA and UPIO)

The authors propose two primary unsupervised models:

  1. Unsupervised Out Association (UPOA): This model calculates a "syntactic distance" between words based on their attention to context outside a specific span. Large distances indicate a natural boundary or "break point" in the sentence structure.
  2. Unsupervised Inside-Outside (UPIO): This is an enhanced version that evaluates both "Inside Association" (how much words within a span attend to each other) and "Outside Association" (how much they attend to the rest of the sentence). A valid constituent, such as a noun phrase, is expected to exhibit high internal cohesion and low external dependency.

Few-Shot Extension (FPOA and FPIO)

To further improve accuracy, the authors developed a few-shot learning strategy. They discovered that the syntactic information within BERT is primarily localized in the linear projection matrices ($W_Q$ and $W_K$) used to generate Queries and Keys. By freezing the majority of the model and fine-tuning only these small matrices with a handful of annotated trees (as few as 20), the models—termed FPOA and FPIO—can be "steered" to produce highly accurate syntactic structures.

Experimental Setup

The models were evaluated on two major benchmarks:

  • Penn Treebank (PTB): The standard English benchmark for constituent parsing.
  • SPMRL: A multi-lingual dataset covering eight diverse languages, including Korean, German, Polish, Hungarian, Basque, French, Hebrew, and Swedish. This was used to test the cross-lingual generalization of the proposed methods.

Decoding was performed using two strategies: a fast Greedy Parsing algorithm for efficiency and a comprehensive Chart Parsing (CKY-style) algorithm for maximum accuracy.

Key Insights and Results

The Power of Projections

A significant finding of this research is that the entire PLM does not need to be retrained to improve syntactic extraction. Adjusting only the $W_Q$ and $W_K$ matrices is sufficient to align the model's attention with human-annotated syntax. Furthermore, the authors found that syntactic information is most concentrated in BERT’s middle-to-upper layers (specifically layers 7 through 9).

Performance Breakthroughs

  • Few-Shot Efficiency: The FPIO model achieved a breakthrough by outperforming previous few-shot methods (such as FSS) while using only 20 annotated trees, compared to the 50 required by prior work.
  • Unsupervised Competitiveness: On short sentences (length ≤ 10), UPIO achieved results comparable to state-of-the-art unsupervised models like C-PCFG.
  • Speed: The UPOA model, utilizing a top-down greedy algorithm, proved to be approximately four times faster than more complex unsupervised alternatives.
  • Constituent Accuracy: The models showed particular strength in identifying Prepositional Phrases (PP) and Adjective Phrases (ADJP), reaching state-of-the-art levels even in the fully unsupervised setting.

Discussion and Limitations

While the framework shows great promise, the authors noted that performance tends to degrade on very long or complex sentences. In these cases, attention weights can become diffused, making the "Inside Association" metric noisy. Additionally, while the study focused on BERT, the applicability of these methods to other architectures like RoBERTa or GPT remains an area for future exploration.

Conclusion

This research demonstrates that pretrained language models contain rich, accessible syntactic structures. By focusing on the Inside-Outside association and fine-tuning minimal projection parameters, it is possible to build efficient, high-performing parsers with little to no annotated data. This paves the way for more accessible NLP tools across a wider array of languages and domains.

Summary updated

BibTeX
@article{zeng2022unsupervised,
  author = {Zhiyuan Zeng and Deyi Xiong},
  title = {{Unsupervised and few-shot parsing from pretrained language models}},
  journal = {Artificial Intelligence},
  year = {2022},
  doi = {10.1016/j.artint.2022.103665},
}
Figure