Visual explainer
Long Short-Term Memory
LSTMs add a cell highway with three gates so old context survives the trip forward.
You run a vanilla RNN and each step multiplies the signal by 0.25 at most. After ten steps you keep a millionth of it. Early words vanish, so long sentences lose their start.
Straight Memory Highway
You lay a second track beside the hidden state. Left at 1.0, it arrives at 1.0 unless gates touch it. Gradients ride it backward untouched, so old context survives.
Three Gates Edit
Forget keeps 0.9 of the old 1.0, giving 0.9. Input takes 0.6 of candidate 0.8, adding 0.48. Your cell moves 1.0 to 1.38 with a paper trail you can check.
Read Out Loud
You squash 1.38 with tanh to 0.88. Output opens at 0.7, so hidden becomes 0.62. That is the only part the next step sees.
Old Words Steer
Give both nets a name from twenty steps ago. The plain net guesses blind while your gated net uses it. Same sentence, same scale, but the highway keeps the clue alive.
Bias The Forget
You start forget bias at 1.0 when passages run long, so cells default to keeping. Drop it toward 0 when streams reset often. Flip it when your net clings to stale clues.
Where It Breaks
Step 3 needs step 2 done, so one hundred tokens cost one hundred serial waits. You cannot widen this like attention. For long texts you switch architectures.
The Quick Version
- Plain nets keep a millionth after ten steps.
- A cell track carries 1.0 untouched.
- Gates move 1.0 to 1.38.
- Output gate reads out 0.62.
- Old names still steer new words.
- Bias forget to 1.0 for length.
- Serial steps stall your GPUs.