Skip to content

B.6 Pass 4: Sequence Models

The models of Pass 3 look at a fixed window of context. Recurrent networks carry state across a whole sequence instead, and this pass builds them: an Elman RNN with backpropagation through time written by hand, the LSTM and GRU, a bidirectional encoder, and a recurrent language model trained with stateful truncated BPTT. The gap between the plain RNN and the gated cells is the vanishing-gradient argument made measurable.

Concepts from other sections (13)

This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.

The second half of the pass puts recurrent networks into encoder-decoders and translates dates. Without attention, a fixed-size encoder state is a bottleneck that long inputs overflow; with Bahdanau’s or Luong’s attention, every decoder step can look at every encoder position and the gap closes. That idea, attention, is what the transformer of Pass 5 is built from. Beam search and the sequence metrics that grade the translations complete the pass.

Learning objectives

  • Explain how bootstrap confidence intervals are computed for the metrics this pass reports.
  • Derive BPTT for a vanilla RNN and explain why gated cells train where it struggles.
  • Explain how stateful truncated BPTT trains on long text with bounded memory.
  • Explain why attention removes the encoder bottleneck, and how beam search and the sequence metrics work.

This pass needs Pass 3: its story corpus and NPLM are the baseline the recurrent model must beat.

  1. LLN, CLT, confidence intervals, bootstrap. Afterwards you can explain why a sample mean concentrates and how a bootstrap interval is computed.
  2. Probability problem set, part c: limit theorems and confidence intervals. Afterwards you can work every problem in the set and explain each answer.
  3. Vanilla RNN with manual BPTT and truncation. Afterwards you can derive backpropagation through time for a vanilla RNN and explain what truncation trades away.
  4. LSTM (torch gate order). Afterwards you can explain each LSTM gate in torch’s order and why the cell state eases vanishing gradients.
  5. GRU (torch gate order). Afterwards you can explain how the GRU merges the LSTM’s gates and how torch orders them.
  6. Bidirectional RNN with length-aware reversal. Afterwards you can explain how the bidirectional RNN reverses padded sequences by length.
  7. RNN language model with stateful TBPTT. Afterwards you can explain how stateful TBPTT carries hidden state across batches and where it is detached.
  8. Bahdanau additive attention. Afterwards you can derive Bahdanau’s additive attention scores and context vector.
  9. Luong attention and input feeding. Afterwards you can explain Luong’s score functions and why input feeding helps.
  10. Encoder-decoder with teacher forcing. Afterwards you can explain teacher forcing and how the encoder-decoder is trained and decoded.
  11. Beam search, generic over a step function. Afterwards you can explain how beam search over a generic step function ranks and prunes hypotheses.
  12. Sequence metrics: exact match, BLEU, chrF. Afterwards you can compute exact match, BLEU and chrF by hand on a small example.
  13. Mutation testing in depth: equivalent mutants, semantic mutants from pitfalls, reading survivors. Afterwards you can explain equivalent and semantic mutants and what a surviving mutant says about a test suite.
  14. What the System Does After Pass 4. Afterwards you can explain why the LSTM beats the RNN and the NPLM, and why attention closes the long-date gap that beam search alone cannot.

One optional section follows the pass for readers who want to see how recurrent language models were used for contextual embeddings before the transformer:

  1. ELMo: biLM, ScalarMix, linear probes. Afterwards you can explain ScalarMix and what a linear probe measures about a biLM’s layers.

The stages are also in this pass’s manifest, path.tsv. Pass 5 builds the transformer from the attention introduced here.

Generated from path.tsv.

StageReadDone when
1LLN, CLT, confidence intervals, bootstrap
13.5 LLN, CLT, confidence intervals, bootstrap
You can explain why a sample mean concentrates and how a bootstrap interval is computed (M07.4).
2Solve set: LLN/CLT, confidence intervals
13.11 Probability problem set, part c: limit theorems and confidence intervals
You can work every S-M07c problem and explain each answer.
3Vanilla RNN with manual BPTT and truncation
9.1 Vanilla RNN with manual BPTT and truncation
You can derive backpropagation through time for a vanilla RNN and explain what truncation trades away (L3.1).
4LSTM (torch gate order)
9.2 LSTM (torch gate order)
You can explain each LSTM gate in torch’s order and why the cell state eases vanishing gradients (L3.2).
5GRU (torch gate order)
9.3 GRU (torch gate order)
You can explain how the GRU merges the LSTM’s gates and how torch orders them (L3.3).
6Bidirectional RNN with length-aware reversal
9.4 Bidirectional RNN with length-aware reversal
You can explain how the bidirectional RNN reverses padded sequences by length (L3.4).
7RNN language model with stateful TBPTT
9.6 RNN language model with stateful TBPTT
You can explain how stateful TBPTT carries hidden state across batches and where it is detached (L3.6).
8Bahdanau additive attention
10.2 Bahdanau additive attention
You can derive Bahdanau’s additive attention scores and context vector (L4.2).
9Luong attention and input feeding
10.3 Luong attention and input feeding
You can explain Luong’s score functions and why input feeding helps (L4.3).
10Encoder-decoder with teacher forcing
10.1 Encoder-decoder with teacher forcing
You can explain teacher forcing and how the encoder-decoder is trained and decoded (L4.1).
11Beam search, generic over a step function
10.4 Beam search, generic over a step function
You can explain how beam search over a generic step function ranks and prunes hypotheses (L4.4).
12Sequence metrics: exact match, BLEU, chrF
10.5 Sequence metrics: exact match, BLEU, chrF
You can compute exact match, BLEU and chrF by hand on a small example (L4.5).
13Mutation testing in depth: equivalent mutants, semantic mutants from pitfalls, reading survivors
3.5 Mutation testing in depth: equivalent mutants, semantic mutants from pitfalls, reading survivors
You can explain equivalent and semantic mutants and what a surviving mutant says about a test suite (craft.07).
14What the system does after Pass 4
B.6.1 What the System Does After Pass 4
You can explain why the LSTM beats the RNN and the NPLM, and why attention closes the long-date gap that beam search alone cannot.
15ELMo: biLM, ScalarMix, linear probes
9.5 ELMo: biLM, ScalarMix, linear probes
You can explain ScalarMix and what a linear probe measures about a biLM’s layers (L3.5).