Recurrent Neural Networks

Recurrent neural networks process sequences through a carried hidden state. They are an older sequence-modeling family and a useful reference point for state-space models.

The basic recurrence is:

The hidden state is the compressed memory of the prefix up to time .

For sequence-to-sequence outputs, the recurrence is often paired with an output projection:

For sequence-level prediction, the model may use , a pooled sequence of hidden states, or an attention/readout layer over .

Key Ideas

  • RNNs update a hidden state one step at a time, so order is built into the computation.
  • The hidden state is a bottleneck that must carry useful past information forward.
  • Gated variants such as LSTM and GRU add learned mechanisms for retaining and forgetting information.
  • Bidirectional RNNs use past and future context for representation tasks, but not for strict causal generation.
  • RNNs are useful comparisons for state-space models because both scan sequences through state updates.

Sequence Contract

FieldQuestion
Directioncausal, bidirectional, or encoder-only?
State sizehow much memory can carry?
Outputtoken-level, sequence-level, pooled, or autoregressive?
Maskinghow are padding and variable lengths handled?
Truncationfull BPTT or truncated backpropagation through time?
Streamingcan inference process one token at a time?

For long sequences, the hidden state is both the memory and the bottleneck:

so information from must survive repeated updates to affect .

Complexity

For sequence length and hidden width , recurrent computation is usually:

for dense recurrent matrices, with sequential dependence over . This makes RNNs efficient for streaming but harder to parallelize across time than Transformers.

Transformer-Era Recurrent Models

Modern recurrent language models try to keep the streaming advantage while recovering Transformer-era training scale:

RWKV and RetNet are canonical paper notes here. They can be formulated in parallel-friendly modes for training and recurrent modes for inference:

RetNet makes this explicit with retention:

The practical tradeoff is:

BenefitRisk
constant-size recurrent state at inferencecompressed state may bottleneck retrieval-heavy tasks
no growing KV cacheless direct pairwise token access than attention
streaming-friendly generationtraining and implementation details are architecture-specific

Paper Reading Boundary

ClaimWhat To Check
long-context modelingtruncation length and gradient stability
streaming inferencelatency, state carry-over, reset policy
compact baselineparameter count and hidden size
protein sequence modelinghomolog split, sequence identity, length handling
time-series or trajectorysampling rate, missing data, and episode boundary

Practical Checks

  • Check whether the task needs causal, bidirectional, or streaming inference.
  • Watch sequence length, truncation, masking, and padding behavior.
  • Inspect how the final representation is chosen: last state, pooled states, attention over states, or token-level outputs.
  • Compare with Transformers when long-range interactions or parallel training are central.
  • Is hidden state reset per example, carried across chunks, or initialized from context?
  • Are sequence-level metrics separated from token-level metrics?