Recurrent Neural Network Grammars

Chris Dyer, Adhiguna Kuncoro, Miguel Ballesteros, Noah A. SmithNAACL 2016

Abstract

We introduce recurrent neural network grammars, probabilistic models of sentences with explicit phrase structure. We explain efficient inference procedures that allow application to both parsing and language modeling. Experiments show that they provide better parsing in English than any single previously published supervised generative model and better language modeling than state-of-the-art sequential RNNs in English and Chinese.

Introduction

Standard sequential Recurrent Neural Networks (RNNs), such as LSTMs, have been remarkably successful in language modeling. However, they treat language as a linear sequence of surface tokens. Linguists have long argued that natural language is inherently hierarchical, organized into nested structures—phrases within phrases. While sequential models can implicitly learn some of this structure, they lack the formal inductive bias to represent it directly. Previous attempts to bridge this gap often relied on "bottom-up" transition-based parsers, which struggle to incorporate global, top-down information necessary for effective sentence generation.

Recurrent Neural Network Grammars (RNNGs) address this by combining the flexibility of RNNs with a hierarchical inductive bias. They represent sentences as a series of top-down syntactic actions, providing a unified framework that can both parse and generate language.

The RNNG Framework

RNNGs operate via a top-down transition-based algorithm. The model maintains its state using three primary components: a Stack for partially completed syntactic constituents, an Output/Input Buffer for the sequence of words, and an Action History recording the transitions taken.

The RNNG architecture uses a Stack LSTM ($S_t$), a buffer ($T_t$), and action history ($a_{<t}$) to predict the next action $p(a_t)$.

To represent the stack state efficiently, the authors use Stack LSTMs. These allow for constant-time push and pop operations while maintaining a continuous vector representation of the stack's contents. This architecture ensures that the model can access the entire history of the parse or generation process in a computationally efficient manner.

Key Innovations

The core of the RNNG is its top-down transition system, which differs from traditional bottom-up shift-reduce parsers. It utilizes three primary actions:

  • NT(X): Opens a new nonterminal phrase of type X (e.g., NP, VP).
  • GEN(x) / SHIFT: In the generative model, GEN(x) produces a terminal word; in the discriminative parser, SHIFT moves a word from the input buffer to the stack.
  • REDUCE: Closes the current phrase, triggering a composition function.
A trace of the transition sequence for the sentence "The hungry cat meows .", showing the evolution of the stack and buffer during parsing.

A critical component is the Syntactic Composition Function. When a REDUCE action occurs, the model pops the children of the constituent and runs a bidirectional LSTM over them to create a single "summary" vector for the completed phrase. This vector is then pushed back onto the stack, effectively propagating structural information up the tree. The authors noted that the correct implementation of this function—ensuring information from all children is properly propagated—is vital for achieving state-of-the-art performance.

For inference, calculating the marginal probability of a sentence $p(x)$ is intractable as it requires summing over all possible trees. The authors solve this using Importance Sampling, where a discriminative parser serves as a proposal distribution to sample likely trees and estimate probabilities.

Experimental Results

The models were evaluated on the English Penn Treebank (PTB) and the Penn Chinese Treebank (CTB) Version 5.1.

  • Parsing: The generative RNNG achieved an F1 score of 93.3 on the English PTB, significantly outperforming previous neural models like Vinyals et al. (88.3). On the Chinese CTB, it achieved an F1 of 86.9, setting a new benchmark.
  • Language Modeling: The RNNG achieved a perplexity of 105.2 on the PTB and 148.5 on the CTB, substantially beating standard sequential LSTM baselines (113.4 and 207.3, respectively).

Discussion

The success of RNNGs highlights the importance of structure as an inductive bias. Explicitly modeling the recursive nature of language makes the model more statistically efficient, forcing it to learn patterns that a standard LSTM might only capture implicitly.

Interestingly, the generative model outperforms the discriminative model at parsing. This suggests that generative models are better at learning from limited data because they must model the entire data distribution. However, this comes with increased computational complexity; inference via importance sampling is significantly slower than standard sequential processing. Future work remains to explore training without gold-standard trees and developing more incremental, "human-like" marginalization algorithms.

Summary updated

BibTeX
@inproceedings{dyer2016recurrent,
  author = {Chris Dyer and Adhiguna Kuncoro and Miguel Ballesteros and Noah A. Smith},
  title = {{Recurrent Neural Network Grammars}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2016},
  url = {https://openreview.net/forum?id=SkElCMWu-S},
}
Figure