skip to content

Search

← The Language Machines

Part I — Words Become Vectors (1948–2016)

RNNs, LSTMs, and seq2seq

Gating equations, the bottleneck vector, and machine translation as generation.

1997–2015 14 min read 8 papers

It is September 2014. Word vectors can capture that Paris relates to France the way Rome relates to Italy, yet no neural network can reliably read an English sentence and write out its French translation. Within one year, two ideas separated by seventeen years — a memory cell designed in 1997 and an encoder–decoder framing published in 2014 — combine to make “sequence in, sequence out” the default shape of neural language processing.

Where We Were

The language models of chapter 1 predicted the next word from a fixed, short window of preceding words: n-gram counts, and later Bengio’s 2003 neural probabilistic language model, both truncated history at a hard boundary. The embeddings of chapter 2 — word2vec (January 2013) and its relatives — gave each word a fixed vector regardless of context, and gave sentences no representation at all. Language, however, is a sequence of arbitrary length in which the words at position 40 can depend on the words at position 2. A model whose input size is fixed cannot, even in principle, represent that.

Recurrent neural networks were the obvious candidate architecture, and they were not new. Elman (1990) had described a “simple recurrent network” in which the hidden layer’s activations are fed back as input at the next time step, so the network maintains a state that summarizes everything it has read so far (Elman, 1990). Trained on letter and word sequences, Elman networks discovered word boundaries and rough syntactic categories — structure in time, as the title put it.

The problem was training them. Learning long-range dependencies requires propagating error signals backward through many time steps, and Bengio, Simard & Frasconi (1994) proved that this fails in a characteristic way: the gradient signal either decays exponentially toward zero or blows up exponentially as it travels back through time (Bengio et al., 1994). A network could learn dependencies spanning five or ten steps, but not fifty. Nearly two decades later, Pascanu, Mikolov & Bengio (2012) revisited the same pathology with modern tooling, gave it a geometric interpretation, and proposed the fix that became standard practice — clipping the gradient norm to handle explosions, plus a soft constraint to fight vanishing (Pascanu et al., 2012).

There were signs the approach could pay off despite the difficulty. Mikolov et al. (2010) trained recurrent language models for speech recognition and reported that a mixture of several RNN LMs cut perplexity by around 50% versus a state-of-the-art backoff n-gram model (Mikolov et al., 2010) — evidence that a learned, unbounded history beat counted, truncated history when you could get the training to work. What was missing was an architecture that made long-range credit assignment reliable, and a task framing that turned “language model” into “language transformer of input to output.”

A memory cell and a training fix, seventeen years apart The idea of hidden-state feedback is 1990; the gated cell that made it trainable over long spans is 1997; the task framing that made it useful is 2014. Grey monospace text is the paper's own result for that step. 1990 Elman networks hidden state feedback at every time step discovers word boundaries 1994 Vanishing gradients proved to decay or explode exponentially over time Bengio, Simard, Frasconi 1997 LSTM gated cell state, additive updates carry gradients Hochreiter and Schmidhuber 2000 Forget gate added lets the cell reset its own memory the LSTM used ever since 2010 RNN language model learned history beats counted history ~50% perplexity cut vs n-grams 2012 Gradient clipping standard fix for the exploding side Pascanu, Mikolov, Bengio RNN encoder-decoder, seq2seq June and September 2014 the memory idea the training problem the fix and the task framing The LSTM waited fifteen years for compute and data to catch up before it became ubiquitous.
The LSTM waited fifteen years for compute and data to catch up before it became ubiquitous; the idea was not late, the hardware was. PNG ↓

The Breakthrough

The breakthrough happened in two acts, seventeen years apart.

Act one: a cell that remembers. LSTM (Hochreiter & Schmidhuber, 1997) attacked the vanishing gradient at its source (Hochreiter & Schmidhuber, 1997). Instead of squashing the entire hidden state through a nonlinearity at every step, the long short-term memory unit maintains a separate cell state — a memory lane along which information can flow across time steps essentially unchanged, which the authors called the constant error carousel. Learned multiplicative gates decide, at each step, what enters this memory, what leaves it, and what is exposed to the rest of the network. Because the cell state is updated additively rather than by repeated matrix multiplication, error signals can travel backward across hundreds of steps without dying. Gers, Schmidhuber & Cummins (2000) completed the design with a forget gate that lets the cell learn to reset its own memory (Gers et al., 2000); the LSTM used in every system discussed below is this three-gate version.

Three gates decide what a cell remembers, forgets and reveals The cell state travels along the plum path by addition, not repeated matrix multiplication, which is why its gradient survives. Grey monospace text names the gate's role in one word. Input x_t current token Hidden h_t-1 previous output Forget gate what to erase Input gate what to write Output gate what to reveal Candidate memory proposed new content Cell c_t-1 the memory lane New cell c_t forgotten plus written additive, not multiplicative New hidden h_t gated view of c_t fed to the next step inputs and outputs the three gates and the candidate the protected memory lane
The cell state's path is dashed to mark it as additive, not repeated matrix multiplication, which is exactly the change that stops the gradient from vanishing. PNG ↓

Act two: two networks, one vector. For years the LSTM was applied where inputs and outputs aligned step-for-step — label each frame of audio, predict each next character. Translation does not align: an English sentence of 12 words may become a French sentence of 15, with word order scrambled. In June 2014, Cho et al. proposed the RNN Encoder–Decoder: one recurrent network reads the source sequence and compresses it into a single fixed-length vector; a second recurrent network conditions on that vector and emits the target sequence one symbol at a time (Cho et al., 2014). The same paper introduced a simplified gated unit — later named the gated recurrent unit, or GRU — that merged the LSTM’s gates into two. Cho’s system was still a component, not a replacement: the encoder–decoder scored phrase pairs as an extra feature inside a conventional statistical machine translation (SMT) pipeline.

Three months later, seq2seq (Sutskever, Vinyals & Le, September 2014) removed the pipeline entirely (Sutskever et al., 2014). A deep encoder — four LSTM layers of 1,000 cells each, with 1,000-dimensional word embeddings, 384M parameters in total — read the English sentence; a matching deep LSTM decoder generated the French translation token by token, trained end-to-end on the WMT’14 English-to-French corpus with a 160,000-word source vocabulary and an 80,000-word target vocabulary. On the WMT’14 test set the pure neural system scored 34.8 BLEU against 33.3 for a strong phrase-based SMT baseline — the first time an end-to-end neural model had beaten a mature SMT system on this benchmark — and reranking the SMT system’s 1,000-best lists with the LSTM pushed the score to 36.5.

One detail of the paper became folklore. The authors reversed the word order of every source sentence (but not the target), so that the first words of the input ended up adjacent to the first words of the output. This introduced many short-term dependencies between source and target and, in their words, made the optimization problem markedly easier. It is a telling artifact: even with LSTMs, the model strained to carry information across the full length of two concatenated sentences, and a data trick that shortened the worst-case dependency was worth real BLEU.

Every word of the source must pass through one vector The encoder reads left to right and compresses the whole sentence; the decoder conditions on that single vector and generates left to right. Grey monospace text is the actual word at that step, reversed on the source side. ENCODER sat cat the (reversed) Fixed vector v 8,000 numbers, whole sentence DECODER le chat end Reversing the source ("the cat sat" becomes "sat cat the") puts the first source words next to the first target words, shortening the worst-case dependency the LSTM has to carry.
Reversing the source sentence puts its first words next to the target's first words, shortening the worst-case dependency the single vector has to carry. PNG ↓

The Mathematics

The vanilla recurrence. An Elman-style RNN maintains a hidden state hth_t updated at every time step:

ht=tanh⁡(Whh ht−1+Wxh xt+bh)h_t = \tanh\left(W_{hh}\, h_{t-1} + W_{xh}\, x_t + b_h\right)
SymbolMeaning
hth_thidden state (the network’s memory) at step tt
xtx_tinput vector at step tt, e.g. a word embedding
WhhW_{hh}recurrent weight matrix, applied to the previous state
WxhW_{xh}input weight matrix, applied to the current input
bhb_hbias vector
tanh⁡\tanhelementwise squashing nonlinearity

Why gradients vanish. Training by backpropagation through time requires the derivative of a late state with respect to an early one, which is a product of one Jacobian per intervening step:

∂ht∂hk  =  ∏i=k+1t∂hi∂hi−1  =  ∏i=k+1tWhh⊤ diag ⁣(tanh⁡′(ai))\frac{\partial h_t}{\partial h_k} \;=\; \prod_{i=k+1}^{t} \frac{\partial h_i}{\partial h_{i-1}} \;=\; \prod_{i=k+1}^{t} W_{hh}^{\top}\, \mathrm{diag}\!\left(\tanh'(a_i)\right)
SymbolMeaning
∂ht/∂hk\partial h_t / \partial h_ksensitivity of the state at step tt to the state at step kk
∏i=k+1t\prod_{i=k+1}^{t}product of one factor per intervening time step
Whh⊤W_{hh}^{\top}transpose of the recurrent weight matrix
diag(tanh⁡′(ai))\mathrm{diag}(\tanh'(a_i))diagonal matrix of nonlinearity derivatives at step ii
aia_ipre-activation entering the tanh⁡\tanh at step ii

The LSTM cell. The LSTM (with the forget gate of Gers et al., 2000) replaces the single squashed state with a gated cell state ctc_t alongside the hidden state hth_t:

ft=σ(Wfxt+Ufht−1+bf)it=σ(Wixt+Uiht−1+bi)ot=σ(Woxt+Uoht−1+bo)c~t=tanh⁡(Wcxt+Ucht−1+bc)ct=ft⊙ct−1+it⊙c~tht=ot⊙tanh⁡(ct)\begin{aligned} f_t &= \sigma\left(W_f x_t + U_f h_{t-1} + b_f\right) \\ i_t &= \sigma\left(W_i x_t + U_i h_{t-1} + b_i\right) \\ o_t &= \sigma\left(W_o x_t + U_o h_{t-1} + b_o\right) \\ \tilde{c}_t &= \tanh\left(W_c x_t + U_c h_{t-1} + b_c\right) \\ c_t &= f_t \odot c_{t-1} + i_t \odot \tilde{c}_t \\ h_t &= o_t \odot \tanh\left(c_t\right) \end{aligned}
SymbolMeaning
ft,it,otf_t, i_t, o_tforget, input, and output gates, each in the range 0 to 1
σ\sigmalogistic sigmoid, squashing to the range 0 to 1
c~t\tilde{c}_tcandidate memory content proposed at step tt
ctc_tcell state — the protected long-term memory lane
hth_thidden state — the gated, visible output of the cell
W∗,U∗,b∗W_\ast, U_\ast, b_\astlearned input weights, recurrent weights, and biases per gate
⊙\odotelementwise multiplication

Translation as conditional generation. seq2seq frames translation as modeling the probability of an output sequence given an input sequence. The encoder compresses the source x1,…,xTx_1, \ldots, x_T into a fixed-dimensional vector vv (its final hidden and cell states), and the decoder factorizes the output distribution one token at a time:

p(y1,…,yT′∣x1,…,xT)  =  ∏t=1T′p(yt∣v,  y1,…,yt−1)p\left(y_1, \ldots, y_{T'} \mid x_1, \ldots, x_T\right) \;=\; \prod_{t=1}^{T'} p\left(y_t \mid v,\; y_1, \ldots, y_{t-1}\right)
SymbolMeaning
x1,…,xTx_1, \ldots, x_Tsource sequence, length TT
y1,…,yT′y_1, \ldots, y_{T'}target sequence, length T′T', generated left to right
vvfixed-dimensional encoding of the entire source sentence
p(yt∣v,y1,…,yt−1)p(y_t \mid v, y_1, \ldots, y_{t-1})probability of the next token given the encoding and the tokens so far

What It Enabled

The most immediate effect was on machine translation itself. A discipline built over two decades — word alignment, phrase tables, log-linear feature weighting, separate language models — was matched by a single network trained end-to-end on sentence pairs.

Phrase-based SMT, circa 2014seq2seq NMT, September 2014
System shapePipeline of separately built componentsOne network, trained end-to-end
Linguistic knowledgeHand-engineered features, alignment modelsLearned from parallel text alone
Sentence representationNone — phrase-level statisticsOne fixed vector per sentence
Handling of word orderExplicit reordering modelsImplicit, learned by the decoder
WMT’14 En→Fr BLEU33.3 (baseline reported in the paper)34.8 direct; 36.5 reranking the SMT n-best lists
VocabularyEffectively openClosed: 160k source, 80k target; unknown words penalized

The second effect was a template. “Encode the input, decode the output” turned out to fit almost any pair of sequences: summarization, dialogue, speech transcription, code generation. The generation loop that seq2seq established — produce one token, feed it back, produce the next — is, unchanged, how every modern chat model emits its answers.

The third effect was a well-defined failure to attack. All information about the source must pass through the single vector vv — 8,000 numbers in the Sutskever et al. system (four layers of 1,000 hidden and 1,000 cell units) — and translation quality degrades as sentences grow beyond what that bottleneck can hold; the sentence-reversal trick was a symptom, not a cure. In the same month seq2seq appeared (September 2014), Bahdanau et al. proposed letting the decoder look back at all encoder states and learn where to look — soft alignment, soon called attention. That mechanism, which dissolved the bottleneck and set up everything after it, is the subject of chapter 4.

The architecture’s remaining limits defined the next two chapters of research. The closed vocabulary problem — seq2seq penalized for every out-of-vocabulary word — was answered by subword tokenization (chapter 8). The strictly sequential computation — step tt cannot begin until step t−1t-1 finishes, on both the time axis during training and across the eight GPUs of the original run — was answered by an architecture with no recurrence at all, the Transformer (chapter 5). Recurrence itself did not die so much as hibernate: state-space models revived the fixed-state, linear-time idea against attention’s quadratic cost a decade later (The Engine Room, chapter 18).

Recurrent unitGatesState carriedKey property
Elman RNN (1990)nonehth_tSimplest recurrence; gradients vanish beyond short spans
LSTM (1997; forget gate 2000)forget, input, outputhth_t and ctc_tAdditive cell-state path preserves gradients over long spans
GRU (2014)update, resethth_tLSTM-like gating with fewer parameters, no separate cell state

Key Papers

PaperAuthorsYearLinkWhy it matters
Finding Structure in TimeElman1990DOIThe simple recurrent network: hidden state as memory, structure discovered from sequence alone
Learning Long-Term Dependencies with Gradient Descent is DifficultBengio, Simard & Frasconi1994DOIProved gradients through time vanish or explode exponentially — the problem statement for a decade
Long Short-Term MemoryHochreiter & Schmidhuber1997DOIGated cell state with additive updates; made long-range credit assignment learnable
Learning to Forget: Continual Prediction with LSTMGers, Schmidhuber & Cummins2000DOIAdded the forget gate, completing the LSTM as used everywhere since
Recurrent Neural Network Based Language ModelMikolov et al.2010ISCAA mixture of RNN language models cut perplexity ~50% versus backoff n-grams — recurrence beats counting
On the difficulty of training Recurrent Neural NetworksPascanu, Mikolov & Bengio2012arXivModern analysis of vanishing/exploding gradients; gradient norm clipping becomes standard
Learning Phrase Representations using RNN Encoder-Decoder for Statistical Machine TranslationCho et al.2014arXivThe encoder–decoder framing and the GRU; still a component inside an SMT pipeline
Sequence to Sequence Learning with Neural NetworksSutskever, Vinyals & Le2014arXivEnd-to-end deep LSTM translation beats phrase-based SMT on WMT’14; the seq2seq template

PM Lens

Papers referenced