Fast and Accurate Neural CRF Constituency Parsing

Yu Zhang, Houquan Zhou, Zhenghua Li · DOI

Abstract

Estimating probability distribution is one of the core issues in the NLP field. However, in both deep learning (DL) and pre-DL eras, unlike the vast applications of linear-chain CRF in sequence labeling tasks, very few works have applied tree-structure CRF to constituency parsing, mainly due to the complexity and inefficiency of the inside-outside algorithm. This work presents a fast and accurate neural CRF constituency parser. The key idea is to batchify the inside algorithm for loss computation by direct large tensor operations on GPU, and meanwhile avoid the outside algorithm for gradient computation via efficient back-propagation. We also propose a simple two-stage bracketing-then-labeling parsing approach to improve efficiency further. To improve the parsing performance, inspired by recent progress in dependency parsing, we introduce a new scoring architecture based on boundary representation and biaffine attention, and a beneficial dropout strategy. Experiments on PTB, CTB5.1, and CTB7 show that our two-stage CRF parser achieves new state-of-the-art performance on both settings of w/o and w/ BERT, and can parse over 1,000 sentences per second.

Introduction

Constituency parsing—the task of breaking a sentence into its hierarchical syntactic components (like noun phrases and verb phrases)—is a cornerstone of NLP. While linear-chain CRFs are the gold standard for sequence labeling (like POS tagging), tree-structured CRFs have historically been avoided in deep learning due to computational bottlenecks. The inside-outside algorithm used to calculate probabilities in trees is notoriously difficult to parallelize on GPUs. Most previous neural parsers either settled for "lossy" greedy decoding or performed expensive tree calculations on the CPU. Furthermore, many modern parsers lack a proper probabilistic framework, making it harder to provide confidence scores (marginal probabilities) for specific subtrees.

Methodology

The authors propose three major innovations to bridge the gap between accuracy and efficiency:

1. Batchified Inside Algorithm

Instead of processing trees one by one, the model "packs" spans of the same width from different sentences into large tensors. This allows the GPU to process the recursive CKY-style logic in parallel across an entire batch, significantly reducing the overhead of sequential processing.

Batchified inside algorithm for GPU parallelization

2. Outside via Backpropagation

A key realization in this work is that the "outside" part of the algorithm (used to find the probability of specific subtrees) is mathematically equivalent to the gradients calculated during backpropagation. By using automatic differentiation, the researchers skip the manual implementation of the complex outside procedure entirely.

3. Two-Stage Parsing and Biaffine Scoring

Instead of finding structure and labels (NP, VP, etc.) simultaneously, the model first finds the best unlabeled "brackets" (the tree structure) and then labels those specific spans. This reduces computational complexity from $O(n^3 + n^2|L|)$ to $O(n^3 + n|L|)$. Borrowing from successful dependency parsers, they use a biaffine attention mechanism to score spans based on their left and right boundaries.

Architecture of the two-stage CRF parser showing bracketing and labeling stages

Experiments and Results

The model was evaluated on three standard benchmarks: the Penn Treebank (PTB) for English, and the Penn Chinese Treebank (CTB5.1 and CTB7). The parser was tested both with randomly initialized word embeddings and with BERT.

  • Speed: The parser is exceptionally fast, reaching 1,092 sentences per second on a single GPU. This is roughly 3x faster than previous high-performance parsers like Kitaev & Klein (2018).
  • Accuracy: On the PTB, the model achieved an F1 score of 95.69 (with BERT), setting a new state-of-the-art at the time. Improvements were even more pronounced on Chinese datasets, where the CRF loss consistently outperformed standard "max-margin" losses.
  • Dropout Strategy: Adopting a dropout strategy from dependency parsing (dropping entire word/character embeddings at once) led to a significant jump in F1 scores (up to 1.59 points).

Discussion and Limitations

The paper demonstrates that tree CRFs can be both practical and efficient. The two-stage approach (bracketing then labeling) is not only faster but also slightly more accurate, as it allows the model to specialize in structural versus categorical tasks.

However, some limitations remain. The model requires trees to be converted into Chomsky Normal Form (binary trees) to work with the CKY logic. Additionally, the two-stage approach assumes labeling is independent of bracketing, which might theoretically miss deeper dependencies between structure and labels. Finally, the speed gains are heavily reliant on batching, which is highly optimized for GPUs but may not offer the same benefits for single-sentence, low-latency inference.

Summary updated

Abstract

Estimating probability distribution is one of the core issues in the NLP field. However, in both deep learning (DL) and pre-DL eras, unlike the vast applications of linear-chain CRF in sequence labeling tasks, very few works have applied tree-structure CRF to constituency parsing, mainly due to the complexity and inefficiency of the inside-outside algorithm. This work presents a fast and accurate neural CRF constituency parser. The key idea is to batchify the inside algorithm for loss computation by direct large tensor operations on GPU, and meanwhile avoid the outside algorithm for gradient computation via efficient back-propagation. We also propose a simple two-stage bracketing-then-labeling parsing approach to improve efficiency further. To improve the parsing performance, inspired by recent progress in dependency parsing, we introduce a new scoring architecture based on boundary representation and biaffine attention, and a beneficial dropout strategy. Experiments on PTB, CTB5.1, and CTB7 show that our two-stage CRF parser achieves new state-of-the-art performance on both settings of w/o and w/ BERT, and can parse over 1,000 sentences per second. We release our code at https://github.com/yzhangcs/crfpar.
BibTeX
@inproceedings{zhang2020fast,
  author = {Yu Zhang and Houquan Zhou and Zhenghua Li},
  title = {{Fast and Accurate Neural CRF Constituency Parsing}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2020},
  url = {https://openreview.net/forum?id=H9oj4HZD3Ch},
}
Figure