Recurrent neural network (RNN)
A recurrent neural network is a neural network built for sequences, which reads its input one step at a time and carries a hidden state forward so earlier inputs can shape later outputs.
Text, speech and sensor readings are sequences, and the order matters. A plain feedforward network sees a fixed-size input all at once. A recurrent neural network instead works through a sequence step by step and feeds what it computed at one step back into the next. Google's machine learning glossary describes it as a network that is deliberately run many times, with parts of each run feeding into the next. The thread that connects the steps is the hidden state, a vector updated at every step from the current input and the previous state, which acts as a running memory of what has come before.
Take the phrase the cat sat on the. The network reads the and updates its state, reads cat and updates it again, and so on. By the last word the state holds a compressed summary of the whole phrase, which the network can use to predict what comes next. The same weights are reused at every step, so one network can handle sequences of any length. Training uses backpropagation through time: the network is unrolled across its time steps and ordinary backpropagation is applied to the unrolled version.
Plain RNNs have a well-known weakness, the vanishing gradient problem. The error signal used for learning shrinks exponentially as it travels back across many steps, so the network struggles to learn links between events far apart. In 1997 Sepp Hochreiter and Jürgen Schmidhuber introduced the long short-term memory network, or LSTM, whose gates control what is stored and what is forgotten. The gated recurrent unit, introduced in 2014, is a lighter design with fewer parameters.
The idea is old. John Hopfield published his recurrent Hopfield network in 1982, Michael Jordan proposed the Jordan network in 1986 and Jeffrey Elman the Elman network in 1990. Through the 2010s recurrent networks, mostly LSTMs, drove handwriting recognition, speech recognition and machine translation; Google used bidirectional LSTMs in voice search, and encoder-decoder RNNs were the state of the art in machine translation from 2014 to 2017.
Then the transformer arrived. The June 2017 paper Attention Is All You Need dropped recurrence entirely in favour of attention, which looks at all positions at once, trains in parallel on GPUs and handles long-range links better. Transformers now dominate language work. The recurrent idea has not gone away, though: a recurrent model does the same amount of work for each new step however long the sequence, and state space models such as Mamba revisit that property for long inputs.
An RNN reads a sequence one step at a time and squeezes everything it has seen into a hidden state. A transformer uses self-attention to look at every position in the sequence at once, which lets it train in parallel and connect distant words more easily. Transformers replaced RNNs as the main architecture for language after 2017. When an RNN learns, error signals are passed backwards through each time step, and with plain RNNs they shrink exponentially as they go. Over long sequences the signal becomes too small to teach the network how early inputs affect later outputs. LSTMs were designed to stop those errors from vanishing. An LSTM is a type of RNN. It adds gates that decide what information to keep, update or discard at each step, which makes it far better at learning long-range dependencies than a plain RNN. Most practical recurrent networks of the 2010s were LSTMs or the related gated recurrent units. Yes, though far less for language than before 2017. Recurrent models remain useful where efficiency and step-by-step processing of streaming data matter, and newer architectures such as state space models borrow their constant cost per step to handle very long sequences.Common questions
What is the difference between an RNN and a transformer?
What is the vanishing gradient problem?
What is the difference between an RNN and an LSTM?
Are RNNs still used?
Search for "recurrent neural network", "backpropagation through time", "vanishing gradient problem" or "LSTM vs transformer" to understand how sequence models evolved. Reliable sources include university course notes, the original papers on arXiv and in journals, machine learning glossaries from Google and similar providers, and encyclopedia articles that cite primary work. Be wary of tutorials that present RNNs as current state of the art for language, since much of that material predates transformers.Finding more
Working out what this means for your business?
Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.