[Paper Review] Reverse engineering recurrent networks for sentiment classification reveals line attractor dynamics
The paper analyzes trained RNNs for sentiment analysis, showing they converge to a low-dimensional line attractor with linearized dynamics that integrate evidence from words to drive sentiment predictions across architectures.
Recurrent neural networks (RNNs) are a widely used tool for modeling sequential data, yet they are often treated as inscrutable black boxes. Given a trained recurrent network, we would like to reverse engineer it--to obtain a quantitative, interpretable description of how it solves a particular task. Even for simple tasks, a detailed understanding of how recurrent networks work, or a prescription for how to develop such an understanding, remains elusive. In this work, we use tools from dynamical systems analysis to reverse engineer recurrent networks trained to perform sentiment classification, a foundational natural language processing task. Given a trained network, we find fixed points of the recurrent dynamics and linearize the nonlinear system around these fixed points. Despite their theoretical capacity to implement complex, high-dimensional computations, we find that trained networks converge to highly interpretable, low-dimensional representations. In particular, the topological structure of the fixed points and corresponding linearized dynamics reveal an approximate line attractor within the RNN, which we can use to quantitatively understand how the RNN solves the sentiment analysis task. Finally, we find this mechanism present across RNN architectures (including LSTMs, GRUs, and vanilla RNNs) trained on multiple datasets, suggesting that our findings are not unique to a particular architecture or dataset. Overall, these results demonstrate that surprisingly universal and human interpretable computations can arise across a range of recurrent networks.
Motivation & Objective
- Understand how trained RNNs solve document-level sentiment analysis using dynamical systems analysis.
- Identify the low-dimensional structure and fixed points in RNN dynamics.
- Assess whether line attractor dynamics generalize across architectures and datasets.
Proposed method
- Train four RNN architectures (LSTM, GRU, Update Gate RNN, vanilla RNN) on IMDB, Yelp, and SST datasets.
- Identify approximate fixed points by minimizing q = (1/N) ||h - F(h,0)||^2 and sampling from the network state distribution.
- Linearize dynamics around fixed points to obtain h_t ≈ h* + J_rec (h_{t-1}-h*) + J_inp x_t.
- Compute eigenvalues/eigenvectors of J_rec to analyze slow modes and memory time constants.
- Use the linearized model to predict the effect of inputs and compare with the full nonlinear dynamics.
Experimental results
Research questions
- RQ1Do trained RNNs exhibit low-dimensional dynamics during sentiment classification?
- RQ2Are the fixed points of trained RNN dynamics organized along a line attractor aligned with readout directions?
- RQ3Do slow integration modes exist across different RNN architectures and sentiment datasets?
- RQ4Can linearized dynamics near fixed points approximate the nonlinear RNN behavior sufficiently for interpretation?
Key findings
- RNNs explore a low-dimensional subspace where top principal components capture most variance after training.
- Fixed points form an approximately 1D manifold aligned with readout weights.
- RNNs exhibit marginally stable fixed points with slow modes that persist for hundreds to thousands of tokens.
- The top integration mode aligns with the fixed point manifold, enabling linearized inputs to push the state along the line attractor based on word valence.
- Positive and negative words produce opposite movements along the line attractor, while neutral words have smaller effects.
- The linearized dynamics approximate the nonlinear system with small single-step error, and the mechanism generalizes across LSTM, GRU, UGRNN, and vanilla RNNs across Yelp, IMDB, and SST.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.