RNNs process sequences by maintaining a hidden state that is updated at each time step:
The same weights are shared across all time steps (parameter sharing through time).

Forward pass: process sequence left to right, updating at each step. Output can be taken at each step (sequence-to-sequence) or only at the end (sequence-to-one).
Backpropagation through time (BPTT): unroll the RNN into a deep network (one layer per time step) and apply Backpropagation. The gradient flows through all time steps.
Vanishing gradient problem: the gradient passes through at every time step. With , the step-to-step Jacobian is
Since the diagonal factor only ever shrinks, and repeated multiplication by drives gradients toward 0 (if ) or (if ). So the RNN forgets long-range dependencies; explosion is fixed by gradient clipping.
This is the fundamental limitation of vanilla RNNs — they struggle with sequences longer than ~20-50 steps.
Solutions:
- LSTM and GRU — gating mechanisms to control information flow
- Transformers — direct position-to-position connections, no sequential bottleneck
See also: LSTM and GRU, Self-Attention, Backpropagation