Why can BERT use bidirectional attention but decoder only LLMs like GPT cannot?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Training inference consistency. BERT's MLM objective is bidirectional at both train and inference.
Imagine two kinds of word puzzles. The first is a crossword: a few letters are blanked out and you can see every other letter on the grid, left, right, above, below, to fill in the missing ones. That's BERT: it learns by filling blanks while seeing the whole sentence at once. The second is reading a mystery one line at a time, with a piece of paper covering everything below the line you're on, and guessing the next word before sliding the paper down. That's GPT: it only ever sees what came before. Compare the two: BERT works because the test (a sentence with a few blanks) looks just like training. GPT works because the test (write the next word) also looks just like training. Mixing them, training crossword style but testing mystery style, would be like studying with the answer key open and then taking the real test in a quiet room.
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.
Walk through MLM vs next token prediction objectives, the inference modality of each, why mixing breaks generation, hybrid approaches (T5, prefix-LM, UL2), and the modern decoder only consensus.
| Model | Pretraining | Attention | Inference modality |
|---|---|---|---|
| BERT | Masked LM | Bidirectional | Encode full input once |
| GPT / Llama | Next token prediction | Causal | Autoregressive generation |
| T5 | Span corruption | Bi (enc) + Causal (dec) | Seq2seq generation |
| UL2 | Mixed denoisers | Bi + Prefix-LM + Causal | Both encode and generate |
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Treating it as a technical impossibility rather than a training inference consistency requirement. Bidirectional attention is mechanically fine; the issue is what's available at generation time.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.