4.1.1 · D5Transformer Architecture

Question bank — Limitations of RNNs motivating transformers

1,525 words7 min readBack to topic

This page is a self-test for the ideas in Limitations of RNNs motivating transformers. Each line is a trap that catches most learners. Read the left side, say your answer OUT LOUD, then reveal the right side. If your reason doesn't match the reasoning given, you found a gap — go back and re-read.

Every symbol below appears in the parent note; if any feels unfamiliar, here is the one-line reminder before we start:


True or false — justify

RNNs cannot be parallelized at all, ever.
False. The time axis cannot be parallelized (each needs ), but many sequences in a batch can run side by side. The bottleneck is depth-in-time, not total work.
The vanishing gradient problem is a bug that better code could fix.
False. It follows from repeatedly multiplying by numbers ( times a small ); the exponential decay is baked into the recursive structure itself.
LSTMs completely eliminate vanishing gradients.
False. They mitigate it via the additive cell-state highway, but the forget gate still multiplies the gradient each step, so decay returns for very long sequences (~1000+ tokens).
If , gradients vanish faster.
False. When the per-step factor (largest stretch of times the typical shrink) exceeds 1, gradients explode (blow up) instead of vanishing — the opposite failure, but still caused by the same repeated multiplication.
A transformer does less total computation than an RNN.
False. Self-attention makes each position do work (it looks at all others), so total work can be more; the win is that this work happens in parallel, not in sequence.
The compression bottleneck only matters for very long inputs.
False. It bites whenever the input's information (in bits) exceeds what one fixed vector can hold; even moderate sentences lose fine detail because bits is a hard ceiling.
Making the hidden state bigger ( larger) fully solves the compression bottleneck.
False. It raises the ceiling but capacity grows only like , while required bits grow like ; long enough inputs still overflow, and big costs memory and slows training.
In BPTT the gradient to word 1 passes through one matrix multiply.
False. It passes through the whole chain — that's multiplications, exactly what causes the decay. Self-attention is what gives a single-hop path.

Spot the error

" can be computed as soon as we have ."
Error: needs , which needs . You need every earlier hidden state first, not just the current input token.
"Because , gradients always shrink by exactly the same factor each step."
Error: the factor varies with and combines with ; we use an average only as an estimate. The decay is approximate, not a fixed constant.
"The cell-state update has no gradient decay."
Error: , and is between 0 and 1, so gradients still shrink whenever the network chooses to forget — which it usually must.
"A sequence of tokens from vocabulary needs bits to store."
Error: each token needs bits (which of words), so the sequence needs bits, far less than .
"For a batch of 32 sequences each 512 tokens long, the RNN takes 512/32 ≈ 16 sequential timesteps."
Error: here 512 is the sequence length (tokens per sentence) and 32 is the batch size. Batching parallelizes over sequences, not time, so it still takes the full 512 timesteps; the 32 sequences just march through those steps together.
"Transformers are faster because self-attention is cheaper per position."
Error: per position it's actually more expensive ( vs ). The speed comes from doing all positions at once, so wall-clock time drops even though work rises.

Why questions

Why can't we "skip ahead" to compute a late hidden state directly?
Because each is a non-linear function of ; there's no closed-form shortcut that jumps past the intermediate states, so they must be built one at a time.
Why do modern GPUs sit mostly idle when running an RNN?
A GPU has thousands of cores, but the time-recurrence lets only one timestep run at a time, so the remaining cores have nothing to do until that step finishes.
Why does the "not ... terrible" example fail for a vanilla RNN?
The gradient linking the far-apart words must travel ~295 recursive steps; multiplied by a factor <1 each step it becomes ~, far too weak to teach the model that early "not" flips the meaning.
Why does self-attention avoid this exponential decay?
Position 1000 attends to position 1 through a single weighted connection, so the gradient between them passes through one hop, not 999 multiplications — no exponential shrinking. See Self-Attention Mechanism.
Why is the encoder's final vector called a "bottleneck"?
All of the input's information has to be squeezed through one fixed-size vector ; like a narrow pipe, it limits how much can pass, forcing detail to be dropped. See Encoder-Decoder Architecture.
Why does making close to 1 keep long-term memory but risk instability?
With the cell state barely forgets, so gradients survive — but old information never fades, so the cell can accumulate and blow up (exploding activations). See LSTMs and GRUs.
Why does the vanishing gradient problem count as a training failure, not a prediction failure?
The forward pass still runs fine; it's the backward learning signal that dies, so the model can never learn long-range rules even though it could in principle use them.

Edge cases

What happens to gradients when the per-step factor equals exactly 1?
They neither vanish nor explode — the ideal knife-edge — but it's practically impossible to stay there for many steps, so real training drifts to vanishing or exploding. See Vanishing and Exploding Gradients.
What if the sequence length ?
There is no recurrence to unroll, so parallelization, vanishing gradients, and the recurrence bottleneck all disappear; the RNN degenerates to a single feed-forward step.
What if two sequences in a batch have very different lengths?
The whole batch still marches for as many timesteps as the longest sequence (shorter ones are padded), so the slow-per-timestep problem is set by the longest input, not the average.
Does a bidirectional RNN remove the sequential bottleneck?
No. It adds a second pass reading right-to-left, but each direction is still a strict left-to-right (or right-to-left) chain — it doubles the passes, it doesn't parallelize time. See Backpropagation Through Time.
If we shorten inputs enough (say ), do RNN limitations vanish?
Largely yes for gradients — 10 steps of a factor like 0.95 loses only ~40% signal — but you also lose the ability to model any genuinely long-range structure, so it's a workaround, not a fix. See Computational Complexity of Sequence Models.
What about attention added on top of an RNN (pre-transformer models)?
It relieves the compression bottleneck (the decoder can look back at all ), but the encoder still processes tokens sequentially, so the parallelization problem remains — which is why transformers dropped recurrence entirely. See Positional Encoding.
Recall Quick self-check

Name the three distinct RNN limitations. ::: (1) Sequential processing — can't parallelize over time; (2) vanishing/exploding gradients over long chains; (3) fixed-size compression bottleneck in the encoder vector. Which single transformer idea attacks all three at once? ::: Self-attention: it computes all positions in parallel, gives one-hop gradient paths, and lets the decoder read every input position directly.