LLM Concept Lab

Recurrent neural networks: memory that fades

Carries a hidden state from word to word, so the output depends on the whole history and on word order.

The idea in plain words

A game of telephone with notes. Each word, you update your one-line summary of everything so far and pass it on. The summary can carry meaning forward, but when it is copied and shrunk again and again, early words fade away.

Step by step

  1. Keep a hidden state h. At each word: new h = a squashed mix of the old h and the new word.
  2. The same weights are reused at every step, so the model handles any length and is sensitive to word order.
  3. Learning sends the error signal backwards through every step, shrinking it each time (vanishing gradient). That is why plain RNNs forget the far past, and why LSTMs and GRUs add gates.

Play it on paper first

Whisper a sentence along a line of five people, each told to repeat it a bit more quietly and shorter. Compare the first and last versions: that gap is the vanishing memory.

Other labs