Constituency Parsing using LLMs

Xuefeng Bai, Jialong Wu, Yulong Chen, Zhongqing Wang, Yue Zhang · DOI · OpenReview

Abstract

Constituency parsing is a fundamental yet unsolved natural language processing task. In this paper, we explore the potential of recent large language models (LLMs) that have exhibited remarkable performance across various domains and tasks to tackle this task. We employ three linearization strategies to transform output trees into symbol sequences, such that LLMs can solve constituency parsing by generating linearized trees. We conduct experiments using a diverse range of LLMs, including ChatGPT, GPT-4, OPT, LLaMA, and Alpaca, comparing their performance against the state-of-the-art constituency parsers. Our experiments encompass zero-shot, few-shot, and full-training learning settings, and we evaluate the models on one in-domain and five out-of-domain test datasets. Our findings reveal insights into LLMs' performance, generalization abilities, and challenges in constituency parsing.

Introduction

Constituency parsing involves decomposing a sentence into its hierarchical sub-phrases, such as Noun Phrases (NP) and Verb Phrases (VP). While traditional state-of-the-art (SOTA) parsers are often graph-based and specifically engineered for tree structures, the rise of Large Language Models (LLMs) presents a new paradigm. LLMs are sequence-based models, requiring hierarchical trees to be "linearized" into strings. This transition introduces unique challenges, such as structural hallucinations and word mismatches, where the model may fail to close brackets or invent words not present in the input sentence.

Methodology: Linearization and Prompting

To bridge the gap between sequence generation and tree structures, we evaluate three primary linearization strategies:

  1. Bracket-based: Utilizing parentheses to denote depth and hierarchy (e.g., (S (NP Singapore) ...)).
  2. Transition-based: Representing the tree as a sequence of stack operations like SHIFT and REDUCE.
  3. Span-based: Describing the tree structure through natural language descriptions of phrase spans.
The task setup for LLM-based constituency parsing, illustrating the bracket-based linearization format used in few-shot prompting.

Beyond basic linearization, we propose two advanced strategies to mitigate common LLM errors:

  • Learning from Erroneous Samples (LES): Incorporating "negative" examples into the prompt to teach the model specifically what structural pitfalls to avoid.
  • Parsing with Multi-agent Collaboration (PMC): An iterative refinement loop where a Parser generates a tree, a Validation Checker verifies structural integrity, and a Faithfulness Checker ensures all input words are present. Feedback from these checkers allows the Parser to regenerate and correct the output.

Experimental Results

Our evaluation across the Penn Treebank (PTB) and the Multi-domain Constituent Treebank (MCTB) reveals that the choice of linearization strategy is critical. Bracket-based formatting consistently outperforms transition and span-based methods, likely because it mirrors the structure of code, which is prevalent in LLM pre-training data.

Comparison of F1-scores across different linearization strategies, decoding methods, and fine-tuning approaches.

Key Findings

  • Zero-shot Performance: GPT-4, combined with the PMC strategy, achieved a breakthrough F1 score of 76.87 in an unsupervised setting, significantly surpassing previous non-LLM baselines.
  • Supervised Fine-tuning: When fine-tuned on domain-specific data, models like Qwen2.5-72B reached an F1 of 96.04, nearly matching specialized graph-based SOTA models (96.40). Full-tuning was found to be more effective than parameter-efficient methods like LoRA.
  • Robustness and Generalization: The PMC strategy proved robust across diverse domains (dialogue, law, literature), effectively reducing the "hallucination tax" where models otherwise generate syntactically invalid trees.

Conclusion

LLMs demonstrate a profound latent understanding of syntax, capable of high-quality constituency parsing when guided by appropriate linearization and multi-agent verification. While computational overhead remains a concern for iterative methods like PMC, the ability of LLMs to generalize across domains and approach SOTA performance marks a significant milestone in structural NLP tasks. Future work will focus on improving the efficiency of these pipelines and refining the error taxonomy for even more precise parsing.

Summary updated

BibTeX
@article{bai2023constituency,
  author = {Xuefeng Bai and Jialong Wu and Yulong Chen and Zhongqing Wang and Yue Zhang},
  title = {{Constituency Parsing using LLMs}},
  journal = {IEEE Transactions on Audio Speech and Language Processing},
  year = {2023},
  doi = {10.1109/taslpro.2025.3600867},
}
Figure