A sequence is data where order changes meaning. In “the server restarted,” the words arrive in a useful order. A temperature reading also forms a sequence because each value belongs to a moment in time. The problem is simple to state: how can a neural network use what came earlier when it processes what comes next?
A recurrent neural network, or RNN, answers this with a small internal memory. It reads one item at a time. After each item, it updates that memory and passes it to the next step.
The basic idea
A normal feedforward network receives an input and produces an output. It does not naturally remember the previous input. If it sees the word “cold,” it has no built-in record of the words before it.
An RNN adds a hidden state. This is a vector of numbers that carries information from earlier steps. At each step, the network receives two things:
- The current input
- The hidden state from the previous step
It combines them and creates a new hidden state. That new state moves forward with the sequence.
The process looks like this:
[ h_t = f(x_t, h_{t-1}) ]
Here, (x_t) is the current input. The term (h_{t-1}) is the earlier memory. The term (h_t) is the updated memory. The function (f) is a small neural network with learned weights.
The same weights are used at every step. This matters because the model can process sequences of different lengths without creating a new set of weights for every position.
An RNN also produces an output at each step, or after the final step. The output depends on the current hidden state. That makes RNNs useful for tasks such as language modeling, time-series prediction, and sequence classification.
A small example
Consider this short sentence:
“The package arrived because it was shipped.”
Suppose an RNN reads one word at a time. It starts with an empty hidden state. The first word updates that state. Each later word changes it again.
After reading “package,” the hidden state may hold information about the subject. After reading “arrived,” it may record an event. When the model reaches “shipped,” the earlier context can affect its interpretation.
The hidden state does not store a sentence in readable text. It stores a compressed numeric summary. That summary may contain signals about recent words, grammar, and the pattern seen so far.
This is why the word “recurrent” matters. The network feeds its previous state back into the next calculation. Memory becomes part of the input at every step.
A sequence model can also predict the next item. Given “The package,” it may assign a score to likely next words. After seeing “The package arrived,” the scores change because the context changed. The prediction uses the hidden state built from the earlier words.
The same pattern works with numbers. Imagine a stream of temperature readings. An RNN can read each reading in order and update its state. The state may represent a rising trend, a sudden drop, or a repeated cycle. The model then uses that information to produce a prediction.
How training works
An RNN learns from examples. During the forward pass, it moves through the sequence and calculates hidden states. It then compares its output with the expected answer.
That difference is called the loss. A training method uses the loss to adjust the model’s weights. Since the same weights appear at every time step, the update reflects errors from many parts of the sequence.
Training an RNN requires a method called backpropagation through time. The network is expanded across the sequence steps for this calculation. The error signal then travels backward through those steps.
This creates a known problem. If the sequence is long, the error signal must pass through many repeated operations. It can become very small, called a vanishing gradient. It can also grow too large, called an exploding gradient.
When the gradient vanishes, the model struggles to learn from distant events. The network may handle recent context well but lose useful information from much earlier in the sequence. This is a basic limit of simple RNNs, not a minor implementation detail.
Training methods can reduce some problems. Gradient clipping can limit very large updates. Careful initialization can help. Gated designs, such as long short-term memory networks and gated recurrent units, add mechanisms that control what information enters, leaves, or stays in memory.
These designs improve the handling of longer relationships. They do not give the model unlimited memory. Every sequence model still has limits set by its architecture, training data, and task.
What sequential memory means
The phrase “memory” can sound human. An RNN does not remember events in the way a person does. Its hidden state is a learned numeric representation.
The model decides which patterns matter during training. It may learn that a recent word helps predict the next word. It may learn that an earlier signal affects a later value. It may also fail to preserve information that matters.
This memory is sequential because it is updated in order. The model cannot process step five before step four has supplied its state. That dependency gives RNNs their strength with ordered data. It also limits how much work can happen at the same time.
A transformer handles sequence context in a different way. Its attention mechanism can compare items across a sequence more directly. This supports efficient parallel processing during training and can make long-range relationships easier to model.
That does not make RNNs useless. Their step-by-step structure can fit streaming data, where new inputs arrive over time. An RNN can update its state as each new item appears instead of waiting for the complete sequence.
The trade-off is clear. RNNs offer a compact sequential mechanism. They can process data one step after another and carry forward a learned state. Their weakness appears when useful information is far back in the sequence or when training needs heavy parallel work.
A practical mental model
Think of the hidden state as a running summary. At every step, the RNN asks:
- What is the current input?
- What did the earlier steps leave in memory?
- What should the updated memory contain?
- What output follows from that memory?
The summary changes after every input. It is not a fixed note attached to the whole sequence. It is an active state that the network updates again and again.
This view helps separate RNNs from ordinary dense networks. A dense network sees an input. An RNN sees an input plus a history summary. That extra state is the core design choice.
RNNs also differ from simply giving a model a large block of data. The order is built into the computation. The first item affects the second step, and the second affects the third. The model receives a path through time.
That path can carry useful context. It can also become a bottleneck. A long sequence must pass its information through repeated state updates. Some details may fade before they reach the final output.
An RNN therefore works best when the sequence structure matters and the needed context can survive the state updates. It becomes a poor fit when the task depends on many distant details or demands large-scale parallel processing.
After this lesson, the main mechanism should be clear. An RNN reads a sequence one item at a time, combines each input with a hidden state, and passes the updated state forward. That sequential memory lets a neural network model ordered data, but it also explains why long dependencies and training speed remain hard problems.
That is the kind of practical idea The Model Log is built around: one useful AI concept, one concrete example, and one honest look at what works and where the design starts to break.



