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

Nested LSTMs

Joel Ruben Antony Moniz, David Krueger

Abstract

Standard Long Short-Term Memory (LSTM) networks often struggle with long-term credit assignment in complex sequences. While stacking layers is a common solution, it fails to create a true temporal hierarchy as higher layers are still forced to process short-term noise. This paper introduces Nested LSTMs (NLSTM), an architecture that replaces the additive memory update with a nested LSTM cell. By allowing the model to selectively access and update inner memories, NLSTMs create a robust temporal hierarchy that outperforms standard stacked LSTMs on character-level language modeling and sequential classification tasks.

Introduction

Recurrent Neural Networks (RNNs) were designed to capture temporal dependencies, with LSTMs specifically addressing the vanishing gradient problem. However, learning dependencies over thousands of steps remains a significant challenge. The traditional approach of stacking LSTMs—placing one layer on top of another—increases computational depth but does not necessarily improve the model's ability to separate long-term state from short-term fluctuations. The authors argue that a more effective temporal hierarchy is needed to isolate long-term patterns from intermediate noise.

Comparison of (a) LSTM, (b) Stacked LSTM, and (c) Nested LSTM architectures.

As shown in the architectural comparison above, while stacked LSTMs (b) pass hidden states between layers, Nested LSTMs (c) integrate the hierarchy directly into the memory cell itself. This "nesting" allows the model to better manage information across different timescales by controlling access to internal memory states.

The Nested LSTM Architecture

The core innovation of the NLSTM is the replacement of the standard additive memory update. In a traditional LSTM, the cell state $c_t$ is updated via a simple linear combination of the previous state and new candidates. In an NLSTM, this addition is replaced by a stateful function implemented as an inner LSTM cell.

Specifically, the gated previous state and the gated new candidate are concatenated and serve as the input to this inner cell. The resulting state of the inner cell becomes the new outer memory cell value. This structure ensures that the inner memory is only modified when the outer gates (input and forget) permit access. Consequently, the inner cell can maintain information over much longer periods without being corrupted by irrelevant intermediate inputs, effectively increasing the "recurrent depth" of the model without the typical issues of gradient degradation.

Empirical Evaluation

The authors evaluated NLSTMs against single-layer and stacked LSTM baselines across several benchmarks: Penn Treebank (PTB) and Text8 for character-level language modeling, Chinese Poetry Generation for structural complexity, and MNIST Glimpses for sequential classification.

Key Results

NLSTMs consistently outperformed stacked LSTMs, even when the latter were given more parameters.

  • Penn Treebank: NLSTM reached 1.399 BPC (Bits Per Character), significantly better than the 1.434 BPC achieved by a 2-layer stacked LSTM.
  • Chinese Poetry: The improvement was dramatic, with NLSTM achieving a perplexity of 625.19 compared to 771.88 for the stacked baseline.
  • MNIST Glimpses: The NLSTM reduced validation error by 4.3% compared to the next best model.

Analysis of Temporal Hierarchy

A key insight of this work is the emergence of a natural temporal hierarchy. By nesting the memory update, the model forces a separation of concerns between different layers of the cell.

Activation heatmaps demonstrating timescale separation in Nested LSTMs.

Visualizations of cell activations (shown above) confirm that inner cells remain stable over many timesteps, capturing long-term features, while outer cells fluctuate rapidly in response to immediate inputs. This separation of timescales is more parameter-efficient and effective than the simple depth provided by stacking, as it allows the model to selectively ignore short-term "noise."

Conclusion

Nested LSTMs offer a more natural way to represent hierarchical data by nesting memory updates rather than just stacking computations. While they introduce some computational overhead per timestep, their superior performance and parameter efficiency make them a compelling alternative for tasks requiring long-term dependency modeling. Future work may explore deeper nesting levels and the integration of modern regularization techniques like Layer Normalization to further push the boundaries of recurrent architectures.

Summary updated

BibTeX
@inproceedings{moniz2017nested,
  author = {Joel Ruben Antony Moniz and David Krueger},
  title = {{Nested LSTMs}},
  booktitle = {ACML},
  year = {2017},
}
Figure