# Long Short-Term Memory (LSTM)

{% hint style="success" %}
We recommend reading the [RNN article](/wiki/recurrent-neural-network-rnn.md) before diving in to LSTMs.
{% endhint %}

Long Short Term Memory networks (LSTMs) are a special kind of recurrent neural network ([RNN](/wiki/recurrent-neural-network-rnn.md)) capable of learning long-term dependencies in sequence data.  LSTMs were created to overcome the inability to retain information for long periods of time, which is an inherent limitation in RNNs.

The following image illustrates the structure of a vanilla RNN:

![](/files/-LwEhQdx0Va-2e4jfI7q)

LSTMs have four activation functions which are used to save pertinent information to be used in later stages of training. &#x20;

![Source: Christopher Olah](/files/-LwEhdQALBJdxHUv2J3J)

The horizontal line running across the cells illustrates the **cell state**, a channel for information to flow across the entire chain.  The cell state can be updated if the information is deemed pertinent (regulated by gates in each cell).  With this novel refinement to RNNs, LSTMs were explicitly designed to capture, retain, and re-use key information over long sequences. &#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://machine-learning.paperspace.com/wiki/long-short-term-memory-lstm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
