Abstract
The Sentence-State LSTM (S-LSTM) is a powerful and highly efficient graph recurrent network that views words as nodes and performs layer-wise recurrent steps simultaneously. Despite its success, the S-LSTM suffers from two drawbacks: uniform computation steps for all words regardless of their complexity, and a lack of inherent sequential information. We propose a depth-adaptive mechanism for the S-LSTM that allows the model to learn how many computational steps to conduct for different words. Additionally, we integrate an extra RNN layer to inject sequential information. Results on 24 text classification datasets show significant improvements over conventional S-LSTM and Transformers, achieving a superior accuracy-speed trade-off.
Introduction
In natural language processing, not all words require the same level of cognitive effort to understand. A functional word like "the" is straightforward, whereas a content-heavy word like "awesome" may require multiple layers of contextual analysis to determine its sentiment or nuance. Traditional models like the Sentence-State LSTM (S-LSTM) process sentences by treating words as nodes in a graph, but they typically apply a fixed number of recurrent steps to every node. This approach is computationally inefficient for simple words and potentially insufficient for complex ones. Furthermore, by treating the sentence primarily as a graph, these models can overlook the vital sequential order of language.
Proposed Method
To address these limitations, we introduce the Depth-Adaptive Graph Recurrent Network. The architecture incorporates three primary innovations:
1. Sequential Module
Before graph processing begins, word embeddings are passed through a Bi-LSTM layer (Layer 0). This layer serves two purposes: it injects a sequential inductive bias into the model and provides the necessary features for the subsequent depth-adaptive decision-making process.
2. Depth-Adaptive Mechanism
For each word $x_i$, the model predicts a probability distribution over possible computational depths (up to a maximum $L$) using a feed-forward network. To ensure the model remains end-to-end differentiable while making discrete depth choices, we employ the Gumbel-Max trick. This allows the model to "sample" a specific depth during training.
3. Dynamic State Transition
During inference, once a word reaches its predicted depth $d_i$, it stops updating its state. The model simply copies the current representation to subsequent layers. This sparsity significantly reduces the total number of operations, driving substantial speed gains without sacrificing accuracy.
Experimental Results
We evaluated the model across 24 datasets, including the Amazon-16 benchmark and various classic benchmarks like IMDB, AG News, and Yelp.
Performance and Efficiency
The depth-adaptive model achieved state-of-the-art (SOTA) performance on 16 out of 24 datasets. Notably, on the Amazon-16 benchmark, it improved average accuracy by +0.7% over previous high-performance models. Regarding efficiency, tests on the IMDB dataset revealed that the depth-adaptive model could match the accuracy of a full 9-layer fixed-depth model while running 3x faster.
Visualization of "Pondering"
Analysis of the learned depths confirms that the model successfully learns to allocate more computational resources to ambiguous or content-rich words. As shown in the visualization below, words like "thriller," "twisted," and "particular" receive higher depth assignments than functional words or punctuation.
Conclusion
The Depth-Adaptive Graph Recurrent Network effectively addresses the rigid computation and lack of sequence in standard S-LSTMs. By allowing the model to "ponder" more difficult words and integrating sequential context, we achieve a more robust and efficient architecture for text classification. Future work will explore the application of this mechanism to generative tasks and its integration with large-scale pre-trained language models.
Summary updated