Pushdown Layers: Encoding Recursive Structure in Transformer Language Models

Shikhar Murty, Pratyusha Sharma, Jacob Andreas, Christopher D. Manning
10/29/2023
25 citations
cs.CL
transformer-attention

Official code: MurtyShikhar/Pushdown-Layers (29 stars, Python, last commit 2023-12-03).

Abstract

Recursion is a prominent feature of human language, and fundamentally challenging for self-attention due to the lack of an explicit recursive-state tracking mechanism. Consequently, Transformer language models poorly capture long-tail recursive structure and exhibit sample-inefficient syntactic generalization.

Show full abstract

This work introduces Pushdown Layers, a new self-attention layer that models recursive state via a stack tape that tracks estimated depths of every token in an incremental parse of the observed prefix. Transformer LMs with Pushdown Layers are syntactic language models that autoregressively and synchronously update this stack tape as they predict new tokens, in turn using the stack tape to softly modulate attention over tokens -- for instance, learning to "skip" over closed constituents. When trained on a corpus of strings annotated with silver constituency parses, Transformers equipped with Pushdown Layers achieve dramatically better and 3-5x more sample-efficient syntactic generalization, while maintaining similar perplexities. Pushdown Layers are a drop-in replacement for standard self-attention. We illustrate this by finetuning GPT2-medium with Pushdown Layers on an automatically parsed WikiText-103, leading to improvements on several GLUE text classification tasks.

View on arXivView PDF

Code Implementations(1)

Code for Pushdown Layers from our EMNLP 2023 paper

295PythonOct 21, 20232 years ago

Similar Papers

Cite this paper

@article{murty2023pushdown,
  title  = {Pushdown Layers: Encoding Recursive Structure in Transformer Language Models},
  author = {Shikhar Murty and Pratyusha Sharma and Jacob Andreas and Christopher D. Manning},
  year   = {2023},
  eprint = {2310.19089},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2310.19089v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2310.19089.svg)](https://codeofpaper.com/paper/2310.19089)

Discussion