Visual walkthrough — Long Short-Term Memory (LSTM) cells
This is the visual companion to Long Short-Term Memory (LSTM) cells. It exists because that note showed the cure for vanishing gradients; here we see the cure.
Step 0 — The problem we are escaping
Before we build anything, look at what goes wrong without an LSTM.
A plain recurrent network keeps one memory vector, the hidden state (a list of numbers describing "what I remember at step "). At each new step it is completely rewritten:
Reading it term by term: is a fixed grid of learned numbers applied to the old memory ; is a second grid applied to the current input ; is a learned offset that shifts the total; and (a function that gently bends every number into the range to ) squashes the result. The point to notice is the first term: the old memory is passed through the same grid every step. Multiplying by the same grid over and over is like multiplying a number by again and again: . The early memory fades geometrically.

Everything below is us earning that sentence.
Step 1 — The conveyor belt: the cell state
WHAT. We introduce a second memory vector called the cell state , a list of numbers (say 128 of them) that runs straight along the top of the cell. Read the subscript as "at time step ".
WHY. We want a channel where information can travel from step to step untouched unless we deliberately touch it. Think of a horizontal conveyor belt: a box placed on it at step 1 rides to step 100 without anyone lifting it off.
PICTURE. The red line is the belt. Notice it goes straight across — no grid , no sitting on the main road.

We will build the machinery that reads and writes the belt out of small, understandable parts. The first part is a valve.
Step 2 — A valve: the sigmoid gate
WHAT. A gate is a vector of numbers each between and . We get those numbers from the sigmoid function, written :
Here is any real number and . Let's read the formula: when is very negative, is huge, so the fraction is tiny → output near . When is very positive, is near , so the fraction is near . At we get exactly .
WHY sigmoid and not something else? We need a dial that lands smoothly anywhere in — meaning "block this", meaning "let it all through", and everything between meaning "let a fraction through". A hard on/off switch (step function) has no slope, so gradient descent could never nudge it. Sigmoid is the smooth switch.
PICTURE. The S-curve. The red dot at shows the midpoint; the flat tails are the "fully closed" and "fully open" ends.

The dial takes its instructions from the current situation. The "situation" is the previous worker's report glued to the new input .
Step 3 — The forget gate: how much of the old belt to keep
WHAT. First we glue two vectors together. means concatenation: stack the old hidden state (length ) on top of the input (length ) to get one longer list of length . Then:
Term by term: is a grid of learned weights (shape ) that turns the situation into a raw score; is a learned offset (length ) that shifts that score up or down; crushes it into a dial between and . The result has one dial per belt lane.
WHY. Some memories should be dropped when a new fact contradicts them (e.g. the sentence's subject switches from singular to plural). The forget gate decides, per lane, how much of the old belt survives.
PICTURE. The belt reaching a row of red valves; valves stay wide open (memory flows on), valves pinch shut (memory erased).

Element-wise, the belt after forgetting is , where means "multiply matching entries" ().
Step 4 — The input gate: what new thing to write, and how much
WHAT. Two pieces work together. First a candidate — a proposal of new content:
We use (range to ) here, not sigmoid, because content can be negative — memory should be able to say "the sentiment is negative" as a , not just "present/absent". Then a dial deciding how much of that proposal to actually write:
WHY two separate pieces? We split what (, signed content) from how much (, a dial). This lets the network form a strong candidate yet write only a whisper of it, or vice-versa.
PICTURE. Below the belt, (black arrow, a signed proposal) passes through the red valve before being allowed onto the belt.

The amount actually written is .
Step 5 — The additive update: the whole point
WHAT. Combine "what we kept" and "what we wrote":
WHY this is the hero equation. Look at how depends on : it is a plus, not a chain of matrix multiplies. Ask "if I nudge , how much does move?" — that sensitivity is:
Nothing else. During backpropagation the gradient travelling from step to step is simply multiplied by . If the network keeps , the gradient passes through unchanged — across 1 step or across 500. That is the gradient highway that plain RNNs lack (there the gradient is multiplied by every step and decays geometrically, exactly the fading from Step 0).
PICTURE. Two streams merging with a + node onto the belt, and the tiny red label on the arrow going backward in time — the only thing the gradient meets.

Step 6 — The output gate: what to reveal
WHAT. The belt may hold big numbers; the outside world wants a tidy, bounded report. So we squash and filter:
Term by term: is a learned grid (shape ); is a learned offset (length ) that shifts the raw score before the sigmoid, exactly like in the earlier gates; turns the result into the reveal-dial . Then compresses the belt into for stability, and chooses per lane which parts of that compressed memory to expose as .
WHY separate memory from output? The network might store a fact ("the subject is female") for many steps but only reveal it at the moment a pronoun is generated. The belt keeps it; the output gate decides when to speak it.
PICTURE. The belt tapped from above: box then a red valve producing the worker , which then loops down to become next step's report.

Step 7 — Edge and degenerate cases
Never leave the reader guessing what happens at the extremes. Each dial is in , so the corners are:
| Situation | Setting | What the belt does |
|---|---|---|
| Pure memory | — belt frozen, perfect recall (the counting task) | |
| Full reset | — old memory wiped, replaced by candidate (behaves like a plain RNN cell) | |
| Wipe to zero | — forget everything AND write nothing; the belt is blanked, a fresh start | |
| Ignore step | belt kept but nothing revealed: , silent memory | |
| First step | belt starts empty; |
Counting, seen on the belt. With and each time a "[" arrives, the update is literally
so the belt reads — an exact counter. A plain RNN cannot do this: caps its memory at , so it can never store the number .

The one-picture summary
Here is the entire cell: belt across the top, three red valves () reaching up to it, the + merge that makes memory additive, and leaving to loop back. Trace the red belt with your finger — it never passes through a weight grid, and that is the whole secret.

Recall Feynman retelling — say it like a story
Picture a conveyor belt carrying boxes of memory. At every tick of the clock three little valves lean over the belt. The forget valve decides how much of each old box to keep — it dims them, it never throws dice. The input valve lets a freshly written box (which can be positive or negative, because a fact can be "yes" or "no") drop onto the belt, and the two are simply added together — kept memory plus new memory. Because it's addition, a box placed at the start can ride all the way to the end untouched, which also means the learning signal (how the final error depends on this memory) riding backward only gets multiplied by the forget dial each step — a number the network keeps near when it wants to remember — so nothing fades away. Finally the output valve peeks at the belt (after gently squashing it with ) and hands a tidy summary to the outside. Freeze the forget valve open and stop writing, and the belt becomes a perfect counter. That belt, and the plus sign that feeds it, is the entire reason LSTMs remember.
Recall Quick self-test
Why is used for the candidate but for the gates? ::: Candidate content must be signed ( to ), so ; gates are fractions of "how much", so ( to ). What is and why does it matter? ::: It equals ; the gradient is only scaled by this per step, giving a highway instead of geometric decay. With , what is ? ::: — the belt is frozen, perfect memory. With , what is ? ::: — the belt is completely blanked, a fresh start mid-sequence. Why can't a vanilla RNN count to 4? ::: Its memory passes through each step, bounding it to , so it can't hold the value .
Where next: the GRU merges these gates into fewer valves; bidirectional RNNs run two belts in opposite directions; and the belt idea is eventually replaced by direct look-back in attention and Transformers.