NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Understanding Hidden Memories of Recurrent Neural Networks

Yao Ming, Shaozu Cao, Ruixiang Zhang, Zhen Li, Yuanzhe Chen, Yangqiu Song, Huamin Qu

Abstract

Recurrent Neural Networks (RNNs) and their variants, such as LSTMs and GRUs, have become the standard for sequence-based tasks. However, their internal "memories"—represented as high-dimensional hidden state vectors—remain largely opaque. This paper presents RNNVis, a visual analytics system that facilitates the exploration and interpretation of RNN hidden states. By utilizing a novel "expected response" method and bipartite co-clustering, the tool maps abstract neural activations to human-interpretable linguistic concepts. Our evaluation across diverse datasets shows that RNNVis can uncover implicit grammatical learning and explain the superior performance of gated architectures like LSTMs.

Introduction

Despite their success in translation, sentiment analysis, and language modeling, RNNs are frequently criticized as "black boxes." The primary challenge in interpreting these models lies in the distributed nature of their representations: a single semantic concept may be spread across hundreds of hidden units, while a single unit may respond to a variety of seemingly unrelated inputs.

To address this, we must solve three key problems: interpreting individual hidden unit functions, scaling visualizations to handle thousands of units, and capturing the dynamic evolution of states as the model processes sequences word-by-word.

Methodology

The core of RNNVis is the expected response technique. To bridge the gap between mathematical vectors and natural language, we calculate the sensitivity of a hidden unit to a specific word by measuring the average change in its activation ($\Delta h$) when that word is processed across a large corpus.

Visual Analytics System

The system architecture integrates several components to manage complexity:

  • Bipartite Co-Clustering: Using spectral co-clustering, the system groups hidden units and words simultaneously. This results in "memory chips" (clusters of units) and corresponding "word clouds" that represent the semantic or syntactic concepts those units track.
  • Glyph-based Visualization: A custom bar-chart glyph represents each word in a sequence, illustrating how information is updated or preserved within each hidden state cluster at every time step.
  • Comparative Layouts: The interface supports side-by-side comparisons of different model architectures (e.g., vanilla RNN vs. LSTM) or different layers within a single model.
The RNNVis main interface, featuring model selection (A), sequence flow (B), memory clusters (C), word clouds (D), and detailed unit statistics (E).

Datasets

We evaluated the tool using three benchmarks: the Penn Tree Bank (PTB) for language modeling, the Yelp Data Challenge for sentiment analysis, and a corpus of Shakespeare’s works to examine the model's ability to relate archaic and modern English.

Analysis and Key Insights

Our exploration with RNNVis yielded several significant findings regarding the internal behavior of recurrent models:

  1. Implicit Grammar Learning: RNNs naturally cluster words by Part-of-Speech (POS) tags, such as modal verbs or prepositions, even without explicit supervision.
  2. The "Lazy" LSTM: Comparison between vanilla RNNs and LSTMs revealed that LSTMs are significantly more "sparse" in their updates. While vanilla RNN states fluctuate wildly, LSTMs preserve information more stably over time, providing empirical evidence for their superior long-term memory.
  3. Hierarchical Representations: In multi-layer models, lower layers often maintain "fuzzier," more abstract representations, while higher layers become increasingly specialized toward the final task, such as predicting the next token.
  4. Contextual Sensitivity: Using the tool, we observed how a GRU's "negative" hidden units respond more strongly to words like "though" when they follow positive sentiment, indicating the model's ability to detect logical contradictions.

Conclusion

RNNVis successfully transforms abstract neural activations into interpretable visual patterns. While the current implementation is limited to discrete inputs and carries some computational overhead for very large models, it provides a crucial step toward demystifying recurrent architectures. Future work will focus on extending these techniques to continuous data types and more complex structures like Attention Mechanisms and Memory Networks.

Summary updated

BibTeX
@inproceedings{ming2017understanding,
  author = {Yao Ming and Shaozu Cao and Ruixiang Zhang and Zhen Li and Yuanzhe Chen and Yangqiu Song and Huamin Qu},
  title = {{Understanding Hidden Memories of Recurrent Neural Networks}},
  booktitle = {VAST},
  year = {2017},
  doi = {10.1109/vast.2017.8585721},
}
Figure