Pair each transformer family with its canonical pretraining objective
Each architecture family has a canonical objective that fits its attention mask. Encoder-only uses MLM (bidirectional). Decoder-only uses next-token (causal). Text encoder-decoder uses span corruption.
Think of each transformer family like a different kind of student with a different study method. The encoder-only student (BERT) reads the whole sentence at once with some words hidden behind sticky notes, then guesses what is under each sticky note, this is masked language modeling. The decoder-only student (GPT, Llama) reads one word at a time and tries to predict the next word, never peeking ahead, this is next-token prediction. The text encoder-decoder student (T5) reads a sentence with whole phrases hidden, then has to write out the missing phrases one by one in a separate notebook, this is span corruption. The cross-modal student (Whisper) listens to an audio recording and writes down what was said in text form, this is supervised audio-to-text. Each method matches the architecture's attention pattern, which is why the pairings are not arbitrary.
Detailed answer & concept explanation~6 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
4 min: state each pairing, explain why the objective matches the attention mask in each case, mention that decoder-only's sample-efficiency advantage drives its dominance at scale.
Real products, models, and research that use this idea.
- BERT-base (2018): 12-layer encoder pretrained with MLM on Wikipedia + BookCorpus. The model that established MLM as the canonical encoder-only objective.
- Llama 3.1 (2024): 8B / 70B / 405B decoder-only models pretrained with causal next-token on 15T+ tokens. The current open-weight standard for decoder-only + next-token.
- T5 (2020): encoder-decoder pretrained with span corruption (15% mask rate, mean span length 3). Established the text-to-text paradigm that FLAN-T5 and UL2 built on.
- Whisper (2022): encoder-decoder pretrained with supervised seq2seq on 680k hours of (audio, transcript) pairs. Multitask via prompt tokens fed to the decoder.
- ELECTRA (2020): encoder-only with replaced-token detection (RTD) instead of MLM. More sample-efficient than MLM but never displaced it as the canonical encoder-only objective.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy does next-token prediction give more training signal per token than MLM?
QCould you train a decoder-only model with MLM?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Assuming any architecture can use any objective. The objective has to match the attention mask: causal masks force next-token prediction, bidirectional masks enable MLM, encoder-decoder masks enable span corruption.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
- Devlin et al., BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding (MLM)
- Radford et al., Language Models are Unsupervised Multitask Learners (GPT-2, next-token at scale)
- Raffel et al., Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer (T5, span corruption)
- Radford et al., Robust Speech Recognition via Large-Scale Weak Supervision (Whisper)
Same topic, related formats. Practice these next.