AI Glossary

Recurrent neural network

A recurrent neural network (RNN) processes a sequence by updating a hidden state from the current input and the previous state. Reusing the same transition weights across steps lets it process sequences of different lengths.

Also known as: RNN

· Updated · Chain of Thought

An RNN could read “not very good” one word at a time. Each step combines the word’s input vector with the previous hidden state. A classifier reads the final state to predict sentiment. The transition at each position uses the same learned weights; the three steps are not three independently trained networks.

In a basic RNN, the state update applies a nonlinear function to weighted input and state values. Earlier words can influence later states, but the state is a learned summary rather than a verbatim transcript. LSTM variants add gates to control information retention.

Recurrence makes the state updates depend on preceding steps. Gradients through long chains can shrink or grow excessively, complicating training. Choose using the sequence length, memory needs and task results. Transformers instead connect positions through attention; neither architecture name establishes that all earlier information is used reliably.

One transition, repeated through timeAn initial state h0 enters three sequential RNN steps. Input vectors for not, very and good enter steps one, two and three. States h1 and h2 pass between steps; h3 feeds a sentiment head. Every step uses the same function f with the same weights. One transition, repeated through timeUnrolling a simple, single-layer RNN for “not very good” h₀x1: “not”h1 = f(h0, x1)x2: “very”h2 = f(h1, x2)x3: “good”h3 = f(h2, x3)Sentiment head ← h₃All three steps share the same learned weights.State updates depend on the preceding state.Earlier inputs influence later states; the hidden state can lose information.
An illustrative unidirectional RNN following PyTorch’s recurrence. The state is a learned summary, not a perfect record of the earlier words. Download the image

Sources

Go deeper