Assessing the Memory Ability of Recurrent Neural Networks

Cheng Zhang, Qiuchi Li, Lingyu Hua, Dawei Song

Abstract

This paper introduces a novel mathematical framework using a "Semantic Euclidean Space" to quantitatively measure the information retention of Recurrent Neural Networks (RNNs). By representing sequence semantics as convex hulls of word embeddings, the authors demonstrate that the memory capacity of LSTMs and GRUs effectively plateaus at a sequence length of approximately 15 words. This provides a principled approach for setting hyperparameters such as Backpropagation Through Time (BPTT) length.

Introduction

While architectures like Long Short-Term Memory (LSTM) and Gated Recurrent Units (GRU) are known for superior memory retention compared to Vanilla RNNs (VRNNs), their capacity is often treated as a "black box." Researchers typically rely on empirical guesswork to determine input sequence lengths or BPTT windows. This lack of theoretical grounding risks either information loss in excessively long sequences or underutilization of the network's potential in sequences that are too short. This study proposes a spatial, geometric approach to directly compare semantic information in hidden states against original input sequences.

Methodology: Semantic Euclidean Space

To quantify memory, the authors compare the "meaning" of an input sentence to the "meaning" captured by hidden layers. They define a Semantic Euclidean Space ($\mathbb{SR}^n$) that extends standard word embeddings to include "abstract semantic points," accounting for implicit meanings generated by word sequences.

The meaning of a sequence is mathematically defined as the convex hull of its constituent word vectors, with the sequence's "central idea" represented by the geometric centroid of this hull.

Figure 1: Geometric representation of sequence semantics as a convex hull in Semantic Euclidean Space.

To ensure direct spatial comparison, the authors utilize a tied Neural Network Language Model (NNLM) architecture, forcing input word vectors and hidden state vectors into the same mathematical space. Six evaluation indicators are established, including:

  • Semantic Coverage Recall/Precision: Measuring the extent and accuracy of original meaning coverage.
  • Central Idea Offsets: Measuring the drift of the hidden state's centroid from the input's centroid.

Experimental Results

The framework was evaluated using the Penn Treebank (PTB) and Wiki-2 datasets.

The Memory Plateau

A key finding is that the memory capacity of LSTMs and GRUs is not boundless. Semantic coverage metrics (Recall, Precision, and F-Measure) increase rapidly for sequences up to 15 words but flatten out thereafter. This "magic number 15" suggests a hard limit on the semantic information these units can absorb.

Figure 5: Performance metrics for PTB and Wiki-2 datasets showing the plateau in semantic coverage around a sequence length of 15.

Hyperparameter Validation

The authors empirically validated that setting the BPTT hyperparameter to 15 achieved optimal Perplexity (PPL) scores. Increasing BPTT to 35—a common default—did not yield performance improvements, confirming that the plateau in semantic memory directly correlates with training efficiency.

Architectural Comparisons

  • VRNNs: These units exhibited a Semantic Coverage Precision Ratio (SCPR) of less than 1%, indicating they lose specific input meaning by generating overly broad, imprecise semantic representations.
  • LSTM vs. GRU: Both architectures perform similarly. However, LSTMs are slightly more effective at preserving the "central idea" when using a single final hidden state, while GRUs are highly competitive when utilizing the full sequence of hidden states.

Discussion and Limitations

A primary limitation of the current approach is the reliance on t-SNE to project high-dimensional vectors into 2D space for area calculations. While t-SNE preserves local topology, the reduction from 50 dimensions to 2 may distort some geometric relationships.

Future research could apply these indicators to downstream tasks like machine translation or reading comprehension. Additionally, the "Central Idea Hit Ratio"—which remains low across current architectures—serves as a potential optimization target for designing next-generation recurrent units.

Summary updated

Abstract

It is known that Recurrent Neural Networks (RNNs) can remember, in their hidden layers, part of the semantic information expressed by a sequence (e.g., a sentence) that is being processed. Different types of recurrent units have been designed to enable RNNs to remember information over longer time spans. However, the memory abilities of different recurrent units are still theoretically and empirically unclear, thus limiting the development of more effective and explainable RNNs. To tackle the problem, in this paper, we identify and analyze the internal and external factors that affect the memory ability of RNNs, and propose a Semantic Euclidean Space to represent the semantics expressed by a sequence. Based on the Semantic Euclidean Space, a series of evaluation indicators are defined to measure the memory abilities of different recurrent units and analyze their limitations (Code is available at https://github.com/chzhang/Assessing_the_Memory_Ability_of_RNNs). These evaluation indicators also provide a useful guidance to select suitable sequence lengths for different RNNs during training.
BibTeX
@inproceedings{zhang2020assessing,
  author = {Cheng Zhang and Qiuchi Li and Lingyu Hua and Dawei Song},
  title = {{Assessing the Memory Ability of Recurrent Neural Networks}},
  booktitle = {ECAI},
  year = {2020},
  url = {https://openreview.net/forum?id=j4VxHdtC2L},
}
Figure