Language modeling pre-2017
LSTMs were the SOTA for character-level and word-level language modeling before transformers.
Name things for the reader, not the writer.
Name things for the reader, not the writer.
Deep Learning Building Blocks
An RNN processes a sequence mathbf{x}_1, mathbf{x}_2, dots by carrying a hidden state mathbf{h}_t = tanh(W_{xh}mathbf{x}_t + W_{hh}mathbf{h}_{t-1} + mathbf{b}). Each step folds the new input into a running summary of everything seen so far. Output can be read off mathbf{h}_t at each step (sequence-t
RNNs roll a hidden state through a sequence.
An RNN processes a sequence by carrying a hidden state . Each step folds the new input into a running summary of everything seen so far. Output can be read off at each step (sequence-to-sequence) or only at the end (classification).
Vanilla RNNs suffer from vanishing and exploding gradients because backpropagation through time multiplies the same recurrent Jacobian repeatedly. LSTMs (Hochreiter & Schmidhuber 1997) fix this with a separate cell state that flows mostly linearly through time, gated by three sigmoids: input gate, forget gate, and output gate.
The LSTM update is: , , , , , . The forget gate decides what to keep; the input gate decides what to add.
Python (in browser)
Expected: Hidden state norm evolves with each step.
Python runs entirely in your browser via Pyodide (~6 MB on first Run, cached after).
GRUs (Cho et al. 2014) merge the cell and hidden state and use only two gates — update and reset — getting most of the LSTM benefit with fewer parameters. Both LSTM and GRU were the workhorses of sequence modeling before transformers overtook them around 2017.
LSTMs were the SOTA for character-level and word-level language modeling before transformers.
Stacked bidirectional GRUs were the workhorse acoustic model.
Encoder LSTM + decoder LSTM + attention won machine translation before transformers.
Put your understanding to the test. Score + streak + speed all count.
3 quick questions. Get 2 right to mark this lesson complete.