Exercises — Limitations of RNNs motivating transformers
This page tests everything from the parent note by making you do the reasoning. Each problem is graded from L1 (just recognise the idea) up to L5 (put everything together). Every solution is hidden inside a collapsible callout — try the problem first, then reveal.
Before we start, one reminder about the symbols we use everywhere below, so nothing appears un-earned:
The two decay quantities we lean on:
Level 1 — Recognition
L1-Q1
An RNN reads a sentence of tokens. How many hidden states must be computed one after another before is available, and what is this sequential cost in big-O notation?
Recall Solution
To compute we need , which needs , … down to . That is 6 hidden states computed in strict order. Because the number of ordered steps equals , the sequential cost is . Each individual step is work, but they cannot overlap.
Answer: 6 sequential steps, cost .
L1-Q2
State in one line why a transformer's per-position work does not force sequential computation the way an RNN's does. Name the mechanism.
Recall Solution
Because in self-attention every position looks at every other position directly and simultaneously; position 6 does not wait for positions 2–5 to finish. The mechanism is self-attention, giving sequential depth.
Level 2 — Application
L2-Q1
The per-step shrink factor is . By what fraction is the gradient multiplied after flowing back 20 steps? Is the far-back token's signal strengthened or weakened?
Recall Solution
Over 20 steps the gradient is multiplied by . The signal is weakened to about of its starting strength. See the decay curve below — 20 steps sits where the plum curve has already dropped well under a fifth.

L2-Q2
An RNN encoder squeezes tokens drawn from a vocabulary of size into one hidden vector. Using , how many bits of information does the input carry?
Recall Solution
, so Answer: about 11,973 bits of information must be packed into a single fixed-size vector.
L2-Q3
Same setup, hidden size . Using the note's capacity estimate , roughly how many bits can the vector hold, and does it fit the 11,973 bits from L2-Q2?
Recall Solution
The vector holds about 4,608 bits but must store 11,973 bits — it holds only of what is needed. It does not fit; the encoder is forced to forget most of the sequence. This is the compression bottleneck the encoder-decoder suffers.
Level 3 — Analysis
L3-Q1
A vanilla RNN and an LSTM are compared. For the vanilla RNN the per-step factor is ; the LSTM's cell-state highway keeps a forget-gate value each step so its effective factor is . Over a 300-token review, compute each surviving fraction and the ratio between them.
Recall Solution
Vanilla: . Taking logs, , so — effectively zero. LSTM: . , so , about 4.9% surviving. Ratio . The LSTM keeps a usable of the signal where the vanilla RNN keeps essentially nothing — a trillion-fold improvement in reach. See how the two curves separate:

L3-Q2
Find the number of steps at which a gradient with has decayed to exactly of its original strength. Solve .
Recall Solution
Take logs of both sides: So after roughly 90 steps the signal is down to . Any dependency longer than ~90 tokens is essentially unlearnable at this . This is why the BPTT gradient cannot connect "not" near the start to a word 295 positions later.
Level 4 — Synthesis
L4-Q1
You must process a batch of sequences, each of length , on a GPU with cores. (a) For the RNN, how many sequential timesteps are forced, and how many cores are busy at each timestep if one core handles one sequence? (b) For the transformer, how many positions can be computed at once, and are all cores used?
Recall Solution
(a) RNN. All 64 sequences march through time together, so the forced sequential depth is timesteps. At each timestep only the 64 sequences advance, so 64 cores busy, leaving cores idle each step. (b) Transformer. Every position of every sequence is independent in the forward pass: positions ready at once. That exceeds the 6000 cores, so all 6000 cores are saturated and the work is done in waves instead of 256 sequential steps. The RNN wastes hardware; the transformer's parallel structure fills it.
L4-Q2
Combine two limitations. For over , what surviving gradient fraction reaches the first token, and separately, what compression ratio applies if , ? State which limitation would bite first for learning long-range negation.
Recall Solution
Gradient reach: . , so — about two-millionths survives. Compression: available bits; required bits; ratio , i.e. 60% fits. For learning a long-range negation, the vanishing gradient bites first: even if the vector could store the info ( is generous), the training signal () is far too weak to teach the network which token mattered. Storage and learning are different failures; here learning fails harder.
Level 5 — Mastery
L5-Q1
Design argument. Suppose someone proposes "just raise to exactly so gradients never vanish." Explain quantitatively what breaks, using the fact that if the factor becomes with . Compute the gradient blow-up for over and name the failure.
Recall Solution
Setting removes vanishing but sits on a knife-edge: any drift above triggers exploding gradients. For , : The gradient is amplified ~17,000×, causing numerical overflow / NaN updates — the exploding gradient failure. So is unstable: below it you vanish, above it you explode, and saturation makes staying exactly at impossible across all inputs. This dilemma is why transformers abandon the recurrence rather than tune .
L5-Q2
Full synthesis. A researcher claims: "LSTMs with solve everything up to 300 tokens, so we never needed transformers." Refute this using: (i) the L3-Q1 surviving fraction, (ii) the L4 parallelism result, and (iii) the compression ratio for .
Recall Solution
(i) Reach. From L3-Q1, : only of the gradient survives even at the friendly . LSTMs stretch memory (~10 → ~100 steps) but never remove the multiplicative decay — for 1000+ tokens the becomes , again near-useless. (ii) Parallelism. Even a perfect LSTM keeps the recurrence , so its sequential depth stays ; it cannot fill a GPU. Transformers stay deep. (iii) Compression. bits available; required bits; ratio — only 29.5% fits, exactly the parent note's failure case. Verdict: the LSTM improves one axis (reach) partially, but leaves parallelism and compression broken. Self-attention plus positional encoding repairs all three: one-hop gradients, full parallelism, and re-reading every source token instead of one squeezed vector. The claim fails.
Recall Quick self-check (reveal after attempting all)
RNN forced sequential depth ::: Transformer sequential depth ::: , via self-attention Per-step gradient factor symbol ::: Why is not a fix ::: knife-edge — below it vanishes, above it explodes What actually removes the multiplicative chain ::: direct one-hop self-attention