LSTM (Long Short-Term Memory) is an RNN (recurrent neural network) with a "memory cell" that can hold information for a long time and "gates" that control writing to and reading from that memory. Hochreiter and Schmidhuber proposed it in 1997 and showed that it can learn relationships between inputs and outputs more than 1000 steps apart, which earlier RNNs could not learn.
An RNN reads a sequence (a sentence, speech, a time series, and so on) one element at a time by feeding its own output from the previous time step back in as input at the next step. However, when a simple RNN such as the Elman network is trained with backpropagation, the error signal shrinks exponentially as it travels back in time (vanishing gradient) or grows too large (exploding gradient). As a result, problems where an input dozens of steps earlier determines the answer could hardly be learned.
LSTM solved this problem with two ideas.
- Memory cell: a linear unit connected to itself with a weight of 1, which creates a path along which the error can travel back in time without changing in size. The paper calls this the "constant error carousel (CEC)".
- Gates: they multiply by values between 0 and 1 and decide, based on the input, "when to write" to the memory cell and "when to read" from it.
What is generally called "LSTM" today is this design with a forget gate added (Gers et al., 1999–2000). The forget gate erases memories that are no longer needed. PyTorch's nn.LSTM also uses this form.
LSTM was the standard model for a long time in speech recognition, handwriting recognition, machine translation (Sequence to Sequence), and other tasks, and from 2017 onward it was replaced by the Transformer in many fields.

