TreePiece: Faster Semantic Parsing via Tree Tokenization

Sid Wang, Akshat Shrivastava, Sasha Livshits

Abstract

Autoregressive (AR) encoder-decoder neural networks have proved successful in many NLP problems, including Semantic Parsing—a task that translates natural language to machine-readable parse trees. However, the sequential prediction process of AR models can be slow. To accelerate AR for semantic parsing, we introduce a new technique called TreePiece that tokenizes a parse tree into subtrees and generates one subtree per decoding step. On the TopV2 benchmark, TreePiece shows 4.6 times faster decoding speed than standard AR, and comparable speed but significantly higher accuracy compared to Non-Autoregressive (NAR) models.

Introduction

Semantic parsing is the critical process of converting natural language (e.g., "Remind me to send Susan an email") into machine-readable "parse trees" that a computer can execute. Currently, researchers face a difficult trade-off between two modeling styles:

  1. Autoregressive (AR) models: These predict the tree one node at a time. They are highly accurate because they consider previous context, but they are slow because the number of steps increases linearly with the size of the tree.
  2. Non-Autoregressive (NAR) models: These attempt to predict the entire tree in parallel. While incredibly fast, they often produce lower-quality results because they struggle to capture the complex structural dependencies inherent in a tree.

TreePiece aims to break this trade-off by making AR models faster without sacrificing the structural intelligence that makes them accurate.

Methodology

The core innovation of this work is TreePiece tokenization. Just as text models use Byte Pair Encoding (BPE) to turn characters into common subwords (like "ing" or "tion"), TreePiece turns a parse tree into a sequence of common subtrees.

Vocabulary Generation and Optimization

The authors developed an algorithm that scans a training corpus of trees and iteratively merges the most frequent adjacent nodes into larger units. To ensure the trees are partitioned optimally, they utilize an Expectation-Maximization (EM) algorithm. This helps the model decide the best way to "slice" a tree into TreePiece units during training, providing a mathematically sound foundation for the tokenization process.

Hybrid Architecture

The model employs a two-stage decoding process to maximize efficiency:

  • AR TreePiece Decoder: Predicts the "skeleton" of the tree (the intents and slots) using the new TreePiece units.
  • NAR Utterance Decoder: Once the structure is set, a non-autoregressive decoder fills in the specific text spans (like "Susan" or "tonight") in a single parallel step.

To allow subtrees to be "glued" back together correctly, the authors introduced a placeholder design that marks where one TreePiece unit expects another to attach. Because TreePiece units are extracted from real data, they inherently respect the "grammar" of the logical forms, making the model less likely to produce invalid structures compared to standard NAR models.

Experimental Results

The researchers evaluated their approach on TOPv2, a standard multi-domain benchmark for task-oriented semantic parsing containing complex, compositional queries across domains like reminders, weather, and messaging.

TreePiece effectively bridges the gap between AR and NAR models:

  • Speed: TreePiece decoding is 4.6x faster than standard AR models. Total inference time (including encoding) is 2.7x faster.
  • Accuracy: The model suffered only a 0.2% drop in Exact Match (EM) accuracy compared to the slow AR baseline.
  • Competitive Performance: It outperformed the NAR baseline by 0.8% in accuracy while maintaining nearly the same inference speed.
  • Efficiency: TreePiece requires significantly fewer "passes" through the decoder layers to generate the same logical form compared to traditional methods.

Limitations and Future Work

While TreePiece represents a significant step forward, some challenges remain. Finding every possible placeholder pattern is NP-hard, requiring the use of practical heuristics to manage Out-Of-Vocabulary (OOV) tree structures. Additionally, the authors opted for straightforward training to keep comparisons clean; adding modern techniques like label smoothing or beam search could likely push accuracy even higher.

Future work will focus on testing how well TreePiece scales to even more diverse or less structured tree formats found in general programming language tasks beyond task-oriented parsing.

Summary updated

Abstract

Autoregressive (AR) encoder-decoder neural networks have proved successful in many NLP problems, including Semantic Parsing -- a task that translates natural language to machine-readable parse trees. However, the sequential prediction process of AR models can be slow. To accelerate AR for semantic parsing, we introduce a new technique called TreePiece that tokenizes a parse tree into subtrees and generates one subtree per decoding step. On TopV2 benchmark, TreePiece shows 4.6 times faster decoding speed than standard AR, and comparable speed but significantly higher accuracy compared to Non-Autoregressive (NAR).
BibTeX
@inproceedings{wang2023treepiece,
  author = {Sid Wang and Akshat Shrivastava and Sasha Livshits},
  title = {{TreePiece: Faster Semantic Parsing via Tree Tokenization}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  url = {https://openreview.net/forum?id=JhC3lwWDhZ},
}
Figure