Efficient Beam Tree Recursion

Jishnu Ray Chowdhury, Cornelia Caragea

Introduction

Recursive Neural Networks (RvNNs) have long been recognized for their theoretical capacity to handle hierarchical structures, a domain where standard Transformers often struggle with "length generalization." While Transformers excel at sequence modeling, tasks requiring deep hierarchical logic—such as mathematical expressions or formal logic—benefit from the bottom-up processing inherent in tree-based models. However, the practical application of RvNNs has been historically hindered by significant computational and memory overhead.

The recent introduction of the Beam Tree RvNN (BT-RvNN) addressed some performance issues by employing beam search to identify optimal latent tree structures. Despite its accuracy, BT-RvNN faced a massive memory bottleneck: to determine the best merge candidates, the model executed a "heavy" recursive cell function on every possible adjacent pair in a sequence. This parallel computation scaled poorly, limiting the model's utility for long sequences or high-dimensional hidden states.

Efficient Beam Tree Recursion (EBT-RvNN)

This paper introduces Efficient Beam Tree Recursion (EBT-RvNN), a refined architecture designed to mitigate the memory constraints of its predecessor while maintaining—and in some cases exceeding—its reasoning capabilities. The authors propose two primary architectural optimizations and a strategy for token-level contextualization.

1. Scorer-Recursion Disentanglement

In the original BT-RvNN, the score for a potential node merge was calculated only after the recursive cell had already combined the nodes. This meant the model performed expensive computations for thousands of candidate pairs that were ultimately rejected. EBT-RvNN disentangles these processes by introducing a lightweight, 2-layer MLP "new scorer." This scorer evaluates adjacent nodes and predicts a merge score before the heavy recursive cell is invoked. Consequently, the expensive recursive function is only executed on the specific pairs selected by the beam search, drastically reducing redundant computation.

2. Hidden-State Slicing

The authors observed that the information required to decide a tree structure (parsing) is distinct from the information required to represent the resulting node (representation). They hypothesize that parsing is a "coarse" task that does not require the full, high-dimensional hidden state. By "slicing" the hidden state and using only a small sub-region (e.g., the first 64 dimensions) for the scorer, EBT-RvNN further reduces the computational footprint without sacrificing structural accuracy.

3. Token Contextualization

Traditionally, RvNNs function as sentence encoders, producing a single vector for an entire input. EBT-RvNN extends this by becoming a token contextualizer. By allowing terminal nodes (individual tokens) to attend to their "parent" nodes in the latent tree via a Gated Attention Unit (GAU), the model generates rich, tree-aware embeddings for every token. This modification allows EBT-RvNN to be stacked with other architectures, such as Transformers or Structured State Space models.

Experimental Evaluation

The efficiency and efficacy of EBT-RvNN were evaluated across several challenging benchmarks:

  • Hierarchical Reasoning: ListOps (e.g., [MAX 2 9 [MIN 4 7]]).
  • Logical and Natural Language Inference: Formal logic classification, SNLI, and MNLI.
  • Semantic Tasks: Paraphrase detection (QQP) and sentiment analysis (SST5, IMDB).

Results and Impact

EBT-RvNN demonstrates significant improvements in both efficiency and performance:

  • Memory Efficiency: In stress tests, EBT-RvNN reduced peak memory usage by 10–16 times. For sequences of 900-1000 tokens, memory consumption plummeted from 43GB in the original BT-RvNN to just 2.8GB.
  • State-of-the-Art Performance: On the ListOps benchmark, EBT-RvNN achieved a new state-of-the-art accuracy of 99.9% on near-IID data. Crucially, it outperformed Transformers and previous RvNN variants on tasks involving unseen sequence lengths and argument counts, demonstrating superior generalization.
  • Scalability: While previous RvNN models frequently encountered Out-of-Memory (OOM) errors on sequences exceeding 1500 tokens, EBT-RvNN successfully processed these lengths while maintaining high performance.

Conclusion

EBT-RvNN addresses the primary bottleneck of recursive neural networks, transforming them from memory-intensive niche models into efficient, scalable components for hierarchical reasoning. By disentangling scoring from recursion and utilizing hidden-state slicing, the model achieves massive memory savings and sets new performance benchmarks. While still more computationally demanding than vanilla Transformers due to the beam search overhead, EBT-RvNN provides a viable path for integrating tree-based inductive biases into large-scale language models, potentially enhancing their ability to perform complex logical reasoning.

Summary updated

BibTeX
@inproceedings{chowdhury2023efficient,
  author = {Jishnu Ray Chowdhury and Cornelia Caragea},
  title = {{Efficient Beam Tree Recursion}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=PR5znB6BZ2},
}
Figure