Fundamentals of Recurrent Neural Network (RNN) and Long Short-Term Memory (LSTM) Network
Alex Sherstinsky
Establishes a rigorous mathematical foundation for recurrent neural networks and LSTMs by deriving their formulations from differential equations, formally proving the unrolling method, and providing complete training equations alongside a generalized model variant.
The article addresses the challenge that recurrent neural networks and long short-term memory networks, despite their widespread use in sequential data tasks such as language modeling and speech recognition, are frequently presented without complete derivations or training formulas, leaving practitioners without a unified reference. It sets out to derive the canonical forms of these systems rigorously from first principles, justify key techniques such as unrolling, explain training difficulties, and construct an enhanced LSTM variant.
The work begins by modeling state evolution with nonlinear delay differential equations drawn from physics and biology, then discretizes them via the backward Euler method to obtain the canonical RNN equations. It proves that an infinite impulse response sequence can be approximated by a finite impulse response model when the target output can be partitioned into mutually independent segments, thereby justifying the standard unrolling procedure. Training via back-propagation through time is examined next, revealing that long-range dependencies produce vanishing or exploding gradients because the product of repeated Jacobian matrices decays or grows exponentially.
To overcome these limitations, the analysis systematically augments the RNN cell with multiplicative gates that separately regulate retention of the prior state, injection of new candidate updates, and exposure of the readout signal. The resulting Vanilla LSTM cell recirculates error gradients through a constant-error-carousel mode when the state-control gate saturates at unity, allowing parameter updates to reflect distant dependencies. The article further augments this architecture with non-causal convolutional context windows on the input, a recurrent projection layer for dimensionality reduction, and an explicit input-control gate, producing the most general LSTM formulation presented to date.
These constructions matter because they supply every forward- and backward-pass equation in consistent vector notation, enabling direct implementation and modular reuse in larger sequence models. The findings imply that practitioners can now incorporate long-range context and adaptive input filtering without resorting to ad-hoc modifications, potentially improving accuracy and training stability on tasks that require modeling extended dependencies.
Recommended next steps include coding the augmented model in a high-performance framework, benchmarking it against the vanilla LSTM, bidirectional LSTM, and transformer baselines on language-representation and customer-support datasets, and measuring the contribution of each extension. The principal limitations are that the unrolling proof assumes segment independence—an assumption that must be validated empirically for each dataset—and that the work remains theoretical; concrete performance gains require systematic experimentation before deployment decisions can be made with high confidence.
- Paper: Long Short-Term Memory, Sepp Hochreiter et al. (1997). It introduces the fundamental Long Short-Term Memory architecture and constant error carousel mechanism that the source formally derives and extends.
- Paper: On the difficulty of training recurrent neural networks, Razvan Pascanu et al. (2012). It provides the foundational mathematical and dynamical analysis of vanishing and exploding gradients in recurrent networks during backpropagation through time.
- Paper: A Critical Review of Recurrent Neural Networks for Sequence Learning, Zachary C. Lipton et al. (2015). It offers a comprehensive review of recurrent sequence learning paradigms, network formulations, and gated mechanisms referenced throughout the source's derivations.
- Paper: LSTM: A Search Space Odyssey, Klaus Greff et al. (2015). It systematically explores and compares vanilla LSTM components and their mathematical variants, motivating the search for a unified, canonical formulation.
- Paper: Empirical Evaluation of Gated Recurrent Neural Networks on Sequence Modeling, Junyoung Chung et al. (2014). It evaluates the empirical behavior and structural trade-offs between standard recurrent units, LSTMs, and gated variants on sequence modeling tasks.
- Paper: Understanding LSTM Networks, Christopher Olah (2015). It breaks down the step-by-step gating operations and internal state updates of standard LSTM cells that the source formalizes into rigorous mathematical equations.
- Paper: Learning representations by back-propagating errors, David E. Rumelhart et al. (1986). It establishes the foundational backpropagation algorithm necessary for understanding backpropagation through time in unrolled recurrent networks.
- Paper: Neural Ordinary Differential Equations, Ricky T. Q. Chen et al. (2018). It generalizes the continuous-time dynamical system and differential equation perspective used by the source to derive RNNs into fully continuous-depth neural ordinary differential equations.
- Paper: Efficiently Modeling Long Sequences with Structured State Spaces, Albert Gu et al. (2022). It extends continuous-time state-space representations to modern structured state space models for ultra-long sequence processing beyond traditional recurrent architectures.
- Paper: An Empirical Evaluation of Generic Convolutional and Recurrent Networks for Sequence Modeling, Shaojie Bai et al. (2018). It provides a direct empirical comparison between canonical recurrent networks like LSTMs and generic temporal convolutional alternatives for sequence modeling.
- Paper: Relational recurrent neural networks, Adam Santoro et al. (2018). It enhances recurrent memory cells with multi-head self-attention mechanisms to enable relational reasoning across sequential memory states.
- Paper: Transformer-XL: Attentive Language Models beyond a Fixed-Length Context, Zihang Dai et al. (2019). It incorporates segment-level recurrence into self-attention models to overcome fixed-length context barriers and capture longer-range dependencies.
- Paper: Memory Caching: RNNs with Growing Memory, Ali Behrouz et al.. It augments recurrent networks with segmented memory caching to overcome fixed-capacity state limits during long-context processing.
- Paper: Titans: Learning to Memorize at Test Time, Ali Behrouz et al. (2024). It develops advanced test-time memorization modules to overcome the fixed-state compression bottlenecks inherent in classic recurrent architectures.
