Long Short-Term Memory as a Dynamically Computed Element-wise Weighted Sum

Omer Levy, Kenton Lee, Nicholas FitzGerald, Luke Zettlemoyer

Abstract

Long Short-Term Memory (LSTM) networks have long been the standard for sequence modeling in Natural Language Processing (NLP). Traditionally, their success is attributed to the combination of non-linear recurrent transitions and gating mechanisms that mitigate vanishing gradients. This paper challenges this view, demonstrating that the non-linear recurrence is largely redundant. By reinterpreting the LSTM as a dynamically computed element-wise weighted sum of inputs, the authors show that the gating mechanism alone provides sufficient representational power for state-of-the-art performance on various NLP tasks.

Introduction

The prevailing narrative for LSTMs suggests they are Simple Recurrent Neural Networks (S-RNNs) enhanced with memory cells and gates. In this framework, the S-RNN component provides the non-linear representational capacity, while gates serve primarily as a training aid to facilitate long-range gradient flow. This research investigates whether the complex, non-linear recurrence is truly necessary or if the gates themselves are the primary drivers of the model's success.

The LSTM as a Weighted Sum

The authors mathematically demonstrate that an LSTM's memory cell $c_t$ can be viewed as an element-wise weighted sum of all previous inputs. In this formulation, the gates act as "soft element-wise binary filters." Unlike standard scalar attention, which applies a single weight to an entire word vector, the LSTM gating mechanism provides a unique weight for every dimension of the vector, allowing for highly granular contextualization.

Visualization of gate weights acting as a dynamic filter for a sentence from the study.

Methodology: Ablation Studies

To isolate the contributions of different components, the researchers compared the standard LSTM against four simplified variants:

  1. LSTM – GATES: A standard S-RNN without gating.
  2. LSTM – S-RNN: Replaces the recurrent "content layer" with a simple linear transformation of the current input ($W_{cx}x_t$), removing non-linear recurrent transitions.
  3. LSTM – S-RNN – OUT: Further removes the output gate.
  4. LSTM – S-RNN – HIDDEN: Computes gates only from the current input, eliminating all multiplicative recurrence.

Results

The ablation studies across Language Modeling (PTB), Question Answering (SQuAD), Dependency Parsing, and Machine Translation yielded striking results. Removing the gates (LSTM – GATES) led to a catastrophic performance drop; for instance, PTB perplexity rose from ~80 to over 140. Conversely, removing the non-linear recurrence (LSTM – S-RNN) had negligible impact, and in some cases, even improved performance. Even the most extreme simplification (LSTM – S-RNN – HIDDEN) maintained performance within a standard deviation of the full LSTM on tasks like Dependency Parsing (90.53 vs 90.60 UAS).

Visualizing Gating as Attention

The paper provides visualizations of the gate weights, revealing how the model "attends" to previous context. These heatmaps show that the gating mechanism effectively captures syntactic and semantic dependencies, behaving much like a vector-weighted attention mechanism.

Comparison of gate weights for Language Modeling vs. Dependency Parsing across various sentences, illustrating task-specific contextualization.

The visualizations highlight a specific inductive bias: because weights are products of forget gates (values in $[0, 1]$), the model naturally decays older information. This distinguishes LSTMs from standard self-attention, which lacks such an inherent temporal decay and can look back at any point with equal ease.

Conclusion

The findings suggest that the "secret sauce" of LSTMs is the gating mechanism, not the non-linear recurrence. This insight positions LSTMs as a specialized form of vector-weighted attention with a useful temporal inductive bias. Future work may leverage these findings to develop more efficient, parallelizable models that retain the strengths of the LSTM architecture while shedding unnecessary complexity.

Summary updated

BibTeX
@inproceedings{levy2018long,
  author = {Omer Levy and Kenton Lee and Nicholas FitzGerald and Luke Zettlemoyer},
  title = {{Long Short-Term Memory as a Dynamically Computed Element-wise Weighted Sum}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2018},
  doi = {10.18653/v1/p18-2116},
}
Figure