Explain in 2-3 sentences why transformers replaced RNNs for sequence modeling.
Transformers process all tokens in parallel, give every token a one-hop path to every other token, and use GPUs efficiently. RNNs do none of these.
Imagine you are reading a 500-page book and have to summarize it. An RNN is like reading every page in order, never flipping back, while trying to keep the gist of every previous page in your head. By page 400 you have forgotten what happened on page 50. A transformer is like spreading every page out on a giant table and being allowed to look at any page when you need it. Whatever connection a sentence on page 400 has to a sentence on page 50, you can see it directly. The transformer also gets to read many pages at the same time on a parallel computer, while the RNN has to read them strictly one after the other. Faster training, longer memory, better results.
Detailed answer & concept explanation~4 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: parallelism + vanishing gradient + constant path length + GPU utilization + scaling laws + the modern SSM comeback (Mamba, RWKV) as nuance.
| Property | RNN / LSTM | Transformer |
|---|---|---|
| Sequence processing | Sequential, token by token | Parallel, all tokens at once |
| Path length between any two tokens | O(n) | O(1) per layer |
| GPU utilization | Low (sequential dependency) | High (one big matmul) |
| Compute per layer | O(n * d^2) | O(n^2 * d) + O(n * d^2) |
| Long-range dependencies | Vanishing gradient hurts | Direct attention path |
Real products, models, and research that use this idea.
- OpenAI's GPT-5.5 is a decoder-only transformer stack; no recurrent component, attention everywhere.
- Anthropic's Claude Opus 4.7 is a transformer model with extensions for long context and tool use; the base architecture is the same family.
- Mamba and Mamba-2 are 2024 state-space models that match transformer quality at sub-quadratic cost, used as the recurrent benchmark in 2026 long-context research.
- Google's earlier seq2seq Translate (pre-2017) was bidirectional LSTM; switching to transformer encoder-decoder in 2017-2018 delivered the BLEU improvements that launched the architecture.
What an interviewer would ask next. Try answering before peeking at the approach.
QIf transformers are O(n^2) in sequence length, why have they not been replaced by Mamba-style state-space models yet?
QWhat does 'positional encoding' contribute that recurrence used to provide for free?
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.
Saying transformers 'have more parameters' as the reason. The architectural choice (parallelism + direct paths) is what enabled the parameter scale, not the other way around.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.