COMP5046 — Natural Language Processing

Lecture 5: Models — Encoder–Decoder

Static & contextual embeddings · seq2seq RNN · MT metrics · BPE · bottleneck → attention.

How to use: pair each bullet cluster with Recall · use Quiz Hub for spaced retrieval.

Vectors

Static embeddings: word2vec, GloVe, FastText

RecallCBOW vs skip-gram direction; what FastText adds vs word2vec.

Sense

Contextual representations

RecallWhy static embeddings fail on polysemy; what ELMo signals.

Seq2seq

Encoder–decoder

Source tokens
Encoder RNN
\(\mathbf{c}\) (context)
Decoder RNN
Target tokens
</s>

RecallTwo ways to end generation.

Train vs test

Training and inference

Training (teacher forcing)

gold1
gold2
gold3
↓   ↓   ↓
Decoder RNN

Input = ground truth tokens

Inference (autoregressive)

pred1
pred2
pred3
↓   ↓   ↓
Decoder RNN
↺ feeds predictions back as next input

Input = own previous predictions

Left: decoder receives gold tokens. Right: decoder feeds back its own predictions.

RecallWhat is fed to the decoder during training vs at inference?

Metrics

Evaluating translation

RecallchrF vs BLEU: what unit each uses; why BLEU has brevity penalty.

Subwords

Tokenisation and BPE

RecallBPE merge rule in one sentence.

Bridge

Encoder–decoder limits

RecallTwo limits of vanilla encoder–decoder that attention addresses.

Lab

Workshop 5 & materials

Quick practice

What is teacher forcing and why use it?
Feed the model's own previous prediction during training
Feed the gold previous token during training to stabilise gradients
Force the teacher model to generate harder examples
Use a separate teacher network for distillation
Why does BPE help with rare words?
Rare words decompose into known subword pieces shared with common words
BPE memorises all rare words in a lookup table
BPE uses character-level RNNs
BPE increases the vocabulary to include all words

Chapter quizzes

Retrieval practice for this lecture.

Open Quiz Hub Chapter flashcards