RNNs and LSTMs
Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 14
6 cards in “14.3 RNNs for other NLP tasks” · whole deck
14.3 RNNs for other NLP tasks
- How is an RNN used for sequence labeling, e.g. part-of-speech tagging?Input word embeddings; at each step a softmax over the tagset gives tag probabilities; pick the most likely tag per step; train with cross-entropy.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 14, §14.3, p. 309
- How is an RNN used for sequence classification?Run the text through the RNN and pass the last hidden state \(h_n\), a compressed representation of the whole sequence, to a feedforward network with a softmax over classes. Only the final classification produces a loss.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 14, §14.3, p. 310
- What is end-to-end training?Using the loss from the downstream task to adjust weights all the way through the network (classifier and RNN).
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 14, §14.3, p. 311
- What alternative to the last hidden state can represent a sequence for classification?Pooling all hidden states, e.g. the element-wise mean \(\frac{1}{n}\sum_i h_i\) or element-wise max.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 14, §14.3, p. 311
- How does an RNN LM generate text autoregressively?Feed
<s>, sample a word from the softmax, feed that word’s embedding as the next input, sample again, until</s>or a length limit.- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 14, §14.3, pp. 311–312
- How is autoregressive generation adapted to tasks like translation or summarization?Prime the generator with a task-appropriate context instead of just
<s>: the source sentence for translation, the long text for summarization.- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 14, §14.3, p. 312
Source
- Daniel Jurafsky and James H. Martin. Speech and Language Processing. 3rd edition (draft). https://web.stanford.edu/~jurafsky/slp3/