Abstract
Standard Recurrent Neural Networks (RNNs) process data linearly, often failing to capture the inherent hierarchical structures found in natural language or mathematical expressions. We present the Recurrent-Recursive (RRNet) model, which dynamically constructs hierarchical tree structures while reading a sequence. By employing "split" and "merge" operations to create adaptive skip-connections, RRNet captures long-term dependencies and compositional semantics more effectively than linear models. Crucially, RRNet operates "on-the-fly," discovering latent hierarchies without requiring pre-computed parse trees.
Introduction
Most sequential data is structured hierarchically. In a linear RNN, the distance between two tokens is defined by their string position, creating a "computational bottleneck" for long-term dependencies. While TreeLSTMs can exploit structural relationships, they typically require full sequence access or external parsers, making them unsuitable for online tasks like language modeling. RRNet addresses this by building its own hierarchy as it processes tokens, bridging the gap between online processing and structural awareness.
The Recurrent-Recursive Model
The core of RRNet consists of three specialized cells managed by a Policy Network that determines the operation at each timestep:
- Split (S): Initiates a new sub-tree. It generates a hidden state to continue computation and a state ($h_{down}$) pushed onto a stack for later retrieval.
- Recur (R): A standard LSTM operation that consumes an input token and updates the current hidden state.
- Merge (M): Closes a sub-tree by popping $h_{down}$ from the stack and merging it with the current representation via a Multi-Layer Perceptron (MLP) and an LSTM unit.
The Policy Network can be trained via supervision (using ground-truth trees) or unsupervised Reinforcement Learning (REINFORCE) to maximize downstream task performance. This mechanism creates dynamic skip-connections: a "merge" operation allows gradients to bypass entire sub-trees, facilitating learning across long sequences.
Experimental Results
We evaluated RRNet on three distinct tasks: Math Expression Evaluation (MEE), Propositional Logic, and Language Modeling (Penn Treebank).
Math Expression Evaluation (MEE)
On the MEE dataset, which requires parsing nested parentheses, supervised RRNet achieved 93.7% accuracy, significantly outperforming the standard LSTM (75.8%). Even without explicit labels, the unsupervised RRNet reached 86.0%, demonstrating its ability to discover useful hierarchical signals independently.
Propositional Logic and Generalization
In logic tasks, RRNet demonstrated superior generalization on longer sequences compared to LSTMs and Transformer-based Fast Attention Networks (FAN). While TreeLSTMs (which have global sequence access) performed best, RRNet was the most effective "online" model, maintaining higher accuracy as sequence length increased.
Language Modeling
On the Penn Treebank benchmark, RRNet achieved a test perplexity of 107.28, a notable improvement over the 113.4 baseline of a standard LSTM. Interestingly, the unsupervised model often learned "latent" hierarchies that diverged from human syntax but optimized task performance, suggesting the model finds structures specifically suited for the objective.
Conclusion
RRNet introduces a flexible framework for learning hierarchical representations on-the-fly. By integrating a stack-based transition system with recurrent units, it effectively manages long-term dependencies through adaptive skip-connections. Future work will focus on stabilizing Reinforcement Learning for the policy network and scaling the architecture to larger datasets.
Summary updated