Which structural property of attention is the single biggest reason transformers scaled where RNNs did not?
The one hop gradient path between any two tokens. Parallelism is a consequence, even with infinite parallel RNN hardware, the gradient signal would still degrade across distance.
Think of writing a paragraph while glancing at notes spread across your desk. You can look at any note directly, no matter how far away on the desk it is: one quick glance and back to writing. That's attention. An RNN is like passing a whispered message down a line of people: by the time it reaches the end, half the words are gone. Same task, but the desk of notes setup keeps every detail one quick glance away.
Detailed answer & concept explanation~5 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.
Contrast O(d) RNN path with O(1) attention path, explain that the Jacobian product along the RNN chain causes vanishing/exploding gradients, and clarify that parallelism falls out of having no sequential dependency.
| Property | RNN/LSTM | Attention |
|---|---|---|
| Path length between tokens at distance d | O(d) | O(1) |
| Gradient stability at distance 1000+ | Degrades (vanishes/explodes) | Stable |
| Forward pass parallelism in sequence dim | Sequential | Parallel matmul |
| Compute cost per layer | O(n · d²) | O(n² · d) |
Real products, models, and research that use this idea.
- Bengio et al. 1994 'Learning long term dependencies with gradient descent is difficult' formally characterized the RNN vanishing gradient problem.
- GPT-3's 175B parameters and 2048-token context would have been intractable with LSTMs because of the gradient path, regardless of compute.
- Mamba / S4 explicitly engineer near identity state propagation to recover the long range modeling capability while keeping linear time inference.
- The 'Attention Is All You Need' paper's central claim was that the recurrence wasn't needed: the all to all attention path subsumed it.
What an interviewer would ask next. Try answering before peeking at the approach.
QIf the one hop path is so important, why do modern long context transformers still struggle past ~200K tokens?
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.
Picking the parallelism option (C). It's true but it's the consequence of the one hop property, not the underlying reason.
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.