Recurrent Neural Networks
An RNN reuses parameters while carrying state through time:
The finite-dimensional state is a learned summary for the objective, not a lossless archive. That compression enables streaming and also loses long-range detail.
Sequence Objectives
| Form | Output | Example | Boundary |
|---|---|---|---|
| many-to-one | final or pooled state | sequence classification | can early evidence survive? |
| aligned many-to-many | every step | tagging, forecasting | masks and padding matter |
| autoregressive | next token/value | language, time series | train and generation inputs differ |
| encoder–decoder | conditional sequence | translation | one context can bottleneck history |
Autoregressive modeling factorizes
Teacher forcing supplies the true prefix in training; free generation consumes prior model errors. Low teacher-forced loss therefore does not guarantee stable rollout.
Why Backpropagation Through Time Fails
The path from time to contains a Jacobian product:
Repeated contraction causes vanishing gradients; expansion causes exploding gradients. Length, weight spectra, activation saturation, and encountered trajectories all matter.
Gradient clipping limits large updates but cannot restore vanished gradients. Truncated BPTT saves memory while truncating credit assignment. Initialization, normalization, and gates help without creating unlimited memory.
LSTM Gating
A common LSTM form is
The additive cell path improves information and gradient flow. Gates are learned soft controls, not automatically interpretable memory switches; implementations vary in biases, projections, peepholes, and gate order.
Worked Example: Streaming Smoothing
For scalar state
an observation steps old has weight . The update uses constant memory, but cannot retrieve one old value on demand. Learned recurrence is more flexible and retains the same compression trade-off; attention changes it by keeping and addressing multiple represented positions.
State and Data Boundaries
Causal RNNs support streaming; bidirectional RNNs use future context and cannot be deployed where the future is unavailable. Padding must be masked. State must reset between independent entities unless cross-boundary carry has explicit meaning. Randomly splitting overlapping windows can leak adjacent sequence content across train and test—an evaluation flaw, not architecture quality.
Modern State-Based Sequence Models
Classical RNNs are not the end of state-based modeling. Structured state-space models (SSMs) use structured state equations and parallel algorithms to combine long-sequence training with recurrent inference. S4 demonstrated structured SSMs; Mamba made parts of the update input-dependent and introduced a hardware-aware scan; xLSTM revisited recurrent memory and gates.
These are not one architecture. Mamba's sequence-scaling claim describes an algorithmic path, not guaranteed wall-clock superiority at every length, batch, or device. xLSTM does not establish that LSTMs universally beat Transformers. Paper benchmarks remain tied to data, scale, kernels, and budgets.
| Dimension | Classical RNN / some SSMs | Full self-attention |
|---|---|---|
| training path | RNN serial; structured SSMs may parallelize | positions parallel within a layer |
| inference state | fixed or controlled size | KV cache usually grows with context |
| history access | compressed state | direct access to represented positions |
| long-range cost | state dynamics and selection | scores usually quadratic in length |
| useful counterexample | streaming, low-memory sequence | flexible retrieval and parallel training |
As of 2026-08-11, S4, Mamba, and xLSTM are important competing designs, not a new permanent default.
Minimal Experiment
Overfit a short sequence; test that changing masked padding leaves output unchanged; deliberately mix state boundaries and ensure tests fail; report teacher-forced and free-running results; split by entity and time; compare against stateless, seasonal, or moving-average baselines; and record gradient norms, truncation length, hidden width, kernels, and failed seeds.
This note favors supervised discrete sequences. Continuous-time systems, all SSM variants, reinforcement learning, and online feedback require separate treatment.