Masked Language Models
Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 9
7 cards in “9.2 Bidirectional transformer encoders” · whole deck
9.2 Bidirectional transformer encoders
- For what kinds of tasks is the left-to-right restriction of decoders a limitation?Tasks where processing a token benefits from future tokens, especially sequence labeling: named entity tagging, part-of-speech tagging, parsing.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 9, §9.2, p. 228
- What is the focus of a bidirectional encoder, compared with a causal model?Computing contextualized representations of the input tokens, using the entire input sequence, rather than generating the next token.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 9, §9.2, pp. 228–229
- Why are masked LMs called encoder-only?They produce an encoding for each input token but generally aren’t used to produce running text by decoding/sampling.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 9, §9.2, p. 229
- In what two ways do bidirectional encoders differ from causal transformers?Attention isn’t causal (a token can attend to following tokens), and training predicts tokens in the middle of the text rather than at the end.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 9, §9.2, p. 229
- How is bidirectional attention implemented?By simply removing the causal mask: \(\text{head} = \text{softmax}\big(\frac{QK^\top}{\sqrt{d_k}}\big)V\). Everything else in the transformer block stays the same.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 9, §9.2, p. 229
- What tokenization do BERT-style encoders use, and what complication does it cause?Subword tokens (BPE, WordPiece or SentencePiece Unigram LM). For tasks that need words, like parsing, subwords must sometimes be mapped back to words.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 9, §9.2, p. 230
- How large are masked language models compared to causal LLMs?Much smaller: typically orders of magnitude fewer parameters than large causal LLMs.
- Jurafsky & Martin, Speech and Language Processing, 3rd ed. draft, ch. 9, §9.2, p. 230
Source
- Daniel Jurafsky and James H. Martin. Speech and Language Processing. 3rd edition (draft). https://web.stanford.edu/~jurafsky/slp3/