Notes

Cell State

Think of an LSTM cell as carrying a running notebook through a sequence. Its cell state is the notebook: a protected pathway for information that should survive across many steps, rather than being rewritten from scratch each time a new input arrives.

The long-term memory pathway

At time step t, the cell state, written ct, is updated by two learned gates. The forget gate chooses how much of the previous state ct−1 to retain, while the input gate chooses how much newly proposed content to write. In compact form:

c_t = f_t * c_(t-1) + i_t * g_t

Here, ft and it contain values between 0 and 1, and gt is candidate memory content. Element-by-element multiplication lets the LSTM preserve one piece of information while replacing another.

Cell state versus hidden state

The hidden state is the LSTM’s exposed, short-term working output: it is used to produce predictions and help compute the next update. The cell state is more private and persistent. An output gate decides which parts of the cell state become visible in the hidden state. This separation gives the model a place to store a long-running dependency without forcing every stored detail into every output.

Why it makes training work

A vanilla RNN repeatedly transforms its state, so gradients can shrink or explode as they are backpropagated through many time steps. The cell state has an additive update path, allowing gradients to travel backward with less distortion when the forget gate stays near 1. For example, an LSTM can retain an early condition until a later step needs it, then forget it once it is irrelevant. Poor gate biases or unstable optimization can still cause memory to be erased too eagerly or retained uselessly, but the cell state is the mechanism that makes controlled long-range memory practical.

Cell state is the LSTM’s persistent internal memory vector, carried across time steps and updated by forget, input, and output gates. It preserves selected long-range information while allowing irrelevant content to be discarded. This controlled memory path supports stable gradient flow through sequences, enabling LSTMs to learn dependencies that standard recurrent networks struggle to retain.

Imagine reading a long novel while carrying a small notebook. You do not write down every word. You keep the important facts: who the characters are, what promises were made, and clues that may matter much later. In an LSTM, a kind of AI designed for sequences, the cell state is that notebook.

It carries useful information forward as the AI moves through a sentence, song, or stream of data. This helps the network connect something happening now with something that happened much earlier. For example, it can remember the subject of a sentence while reading many words in between, making long-term context much easier to handle.