What is a recurrent neural network (RNN)?
A recurrent neural network is a type of neural network that processes a sequence step by step, carrying information from earlier steps forward through a hidden state updated at each step.
It is also called an RNN. It differs from a Transformer in how it processes input: a Transformer looks at all tokens at once with self-attention and runs in parallel, while an RNN reads the sequence in order and summarises the past in one state vector. Long Short-Term Memory and Gated Recurrent Unit are gated members of this family.
- Topic
- Machine learning, models and training
- Also known as
- RNN
How a recurrent neural network (RNN) works
- At each time step the current input is combined with the previous hidden state to produce a new hidden state.
- The same weights are reused at every step, letting the network handle variable-length sequences.
- An output is produced at each step or at the end as needed; training uses backpropagation through time.
- Long sequences suffer vanishing or exploding gradients; gated cells were developed to ease this.
In more detail
Truncated backpropagation through time
In practice, training over very long sequences uses Truncated Backpropagation Through Time (TBPTT), which splits the sequence into fixed chunks for gradient updates. While this bounds memory usage, it limits how far back gradients can directly teach the network to retain dependencies.
Linear recurrent architectures: RWKV and xLSTM
While classical Elman RNNs and LSTMs were displaced in frontier LLMs, modern linear-time recurrent architectures such as RWKV, xLSTM and hybrids of Transformers and state space models revisit recurrence, allowing parallel matrix operations in training while keeping constant memory per token at inference.
Commonly confused terms
| Term | How it differs |
|---|---|
| Feed-forward neural network | A standard feedforward network processes each input independently with no memory of prior inputs, whereas an RNN carries a hidden state across time steps to model sequential order. |
| State space model | Modern SSMs (such as Mamba) also maintain a fixed-size state and run in linear time, but use linear continuous-time or structured state transitions that enable parallel scan training rather than non-linear step-by-step recurrence. |
| Recursive neural network | A Recursive Neural Network applies the same weights over hierarchical tree structures (such as parse trees), whereas a Recurrent Neural Network applies weights sequentially over linear time or token steps. |
Why a recurrent neural network (RNN) matters for on-premises AI
Transformers have replaced RNNs in large language models, but RNN-based models are still used for time series tasks such as sensor data, consumption and transaction sequences. Since memory does not grow with sequence length and the models are small, they run cheaply on edge devices and CPUs. The idea of carrying a fixed-size state has returned in long-context language models through state space models.
An energy company forecasts regional consumption readings with an RNN-based model and plans grid load on in-house servers; the readings are not sent to an external AI service.
Common questions
What is the difference between an RNN and an LSTM?
An LSTM is a type of RNN. A standard RNN tends to forget the past over long sequences; an LSTM carries information longer through gates and a separate cell state.
Are RNNs still used today?
Yes, especially for time series and signal processing where small, fast models suffice. In large language models Transformers have taken their place.
Related terms
- Long short-term memory (LSTM)
- Gated recurrent unit (GRU)
- AI Transformer
- Neural network
- AI time series forecasting
- Deep learning
- Backpropagation
- AI state space model
Sources
In the glossary: Glossary, R to Z