← Contents Volume III · Lecture 6

Volume III · Remembering — Recurrent Networks

6

Three Gates and a Cell State

Picture a conveyor belt running the length of a factory floor, carrying a single crate from one end to the other, untouched, unless someone deliberately reaches in to add something to it or take something out. That belt, and the three hands stationed along it, is the whole idea this lecture explains.

The mental model

Give the network a second, separate pathway for memory that updates mostly by addition rather than repeated multiplication, and let three learned gates control what goes in, what comes out, and what gets forgotten.

A second pathway, addition instead of multiplication

Hochreiter and Schmidhuber published the Long Short-Term Memory cell in 1997, and its central move is the one the previous lecture was building toward: alongside the hidden state ht, the LSTM keeps a second state, the cell state ct, and updates it in a way that does not repeatedly multiply the same matrix through a saturating nonlinearity. The paper itself calls this pathway a "constant error carousel" — a state that can carry a gradient across many timesteps largely unchanged.

Three gates decide what happens to that state at every timestep. Each is a small neural network of its own, a sigmoid applied to a linear combination of the previous hidden state and the current input, producing a vector of values between zero and one that acts as a soft, learned switch.

Forget gate — what to erase from the cell state ft = σ( Wf·[ht-1, xt] + bf )
Input gate and candidate — what to write in it = σ( Wi·[ht-1, xt] + bi )
t = tanh( Wc·[ht-1, xt] + bc )
Cell update — mostly addition, not repeated multiplication ct = ft ⊙ ct-1 + it ⊙ c̃t
Output gate — what to reveal as the hidden state ot = σ( Wo·[ht-1, xt] + bo )
ht = ot ⊙ tanh( ct )
THE CELL STATE, AS A CONVEYOR BELT ct-1 ct FORGET INPUT OUTPUT
Figure 6a The cell state runs the length of the diagram largely unbroken — the "constant error carousel." Each valve is a learned gate deciding, at that point, how much of the belt's contents to erase, add to, or reveal, rather than the whole line being repeatedly squashed through a shared nonlinearity.

Reading the gates as a decision

Read the four equations as one decision made at every timestep: the forget gate looks at the previous hidden state and the new input and decides, per dimension of the cell state, how much of the old value to keep; the input gate and its candidate decide what new information is worth writing in and how much of it to add; and the output gate decides how much of the (now updated) cell state to expose as the hidden state that the rest of the network, and the next timestep, actually sees. Nothing about the cell state itself is squashed through a matrix multiplication at every step — only the gates computing how much to add or erase are.

The GRU's simplification

Cho and colleagues introduced the Gated Recurrent Unit in 2014, as part of an encoder–decoder architecture for machine translation, and it keeps the LSTM's core idea — a gated, largely additive state update — in a cheaper form. The GRU merges the forget and input gates into a single update gate zt, and eliminates the separate cell state entirely: the hidden state ht now serves both roles at once. A second gate, the reset gate rt, controls how much of the past hidden state feeds into the candidate activation.

The GRU update ht = (1 − zt) ⊙ ht-1 + zt ⊙ h̃t
LSTM · THREE GATES GRU · TWO GATES forget input output separate cell state c_t update reset no separate cell state — h_t carries both roles FORGET + INPUT MERGE INTO UPDATE CELL STATE ELIMINATED
Figure 6b The GRU keeps the gated, additive idea but spends less on it: two gates instead of three, and no second state to maintain — the hidden state alone carries what the LSTM split across ht and ct.

One idea, two prices

Neither cell is a different theory of memory. Both protect a mostly-additive state behind learned gates; the LSTM spends an extra gate and an extra state to keep the two roles — "what to remember" and "what to expose" — fully separate, and the GRU spends less by folding them together.

Where this stood, before attention

For roughly two decades, some gated recurrent cell — an LSTM, or later a GRU — was the default component for anything sequential: language modelling, translation, speech recognition. The gate is what let a network finally carry information across dozens or hundreds of timesteps, and every one of those applications depended on exactly the mechanism this lecture derives.

That default eventually gave way to a different architecture, one that dispenses with recurrence altogether and lets every position attend to every other position directly. The sibling Modern LLMs track opens with exactly that mechanism. It is worth carrying this lecture's vocabulary into that one: attention is, in its own way, another answer to the same question — what should the network be allowed to remember, and how far back should it be allowed to reach.

Two gated cells, side by side
LSTMGRU
Gatesforget, input, output (3)update, reset (2)
Statehidden state ht + separate cell state cthidden state ht only
OriginHochreiter & Schmidhuber, 1997Cho et al., 2014

Read the primary source