kefirski.me
EMNLPPaper 0320269 min read

You Do Not Fully Utilize Transformer's Representation Capacity

Each attention layer normally sees only the previous residual stream. Letting every head read all earlier layers' key-value buffers trains faster and undoes representation collapse.

The single stream is a bottleneck

A transformer never rereads its past layers. At layer \ell the attention block sees exactly one object, the residual stream X1\mathbf{X}_{\ell-1}, and every query, key, and value is a projection of it. Whatever layers 11 through 2\ell-2 computed survives only as far as it fits inside that single vector per position.

Forcing everything through one vector has a measurable failure mode: representation collapse, where distinct tokens become indistinguishable in deeper layers. Voita and colleagues showed top layers losing fine-grained token identity, and Barbero and colleagues proved a decoder can drive the final representations of different inputs arbitrarily close together. Long sequences make it worse, because subtle distinctions get squeezed out by finite state capacity and floating-point precision.

One stream versus layer-integrated memory

The architecture delta
Both stacks compute the same per-layer keys and values. The only change in LIMe is who gets to read them: a learned router lets each head attend over buffers from every earlier layer, not just the one below.

Our fix, Layer-Integrated Memory, or LIMe, removes the bottleneck without touching the transformer's shape. Every layer already computes per-head keys and values, and those tensors already sit in buffers during training and inference. We simply let every attention head read all of them.

A router over memory the model already has

At layer \ell, head hh no longer attends over the current layer's keys and values alone. A trainable router R()R×H×HR^{(\ell)}\in\mathbb{R}^{\ell\times H\times H} assigns a weight to every buffered head hh' at every earlier layer \ell', and attention runs over the resulting mixtures

K~,h==1h=1HR,h,h()B,h(K),V~,h==1h=1HR,h,h()B,h(V).\widetilde{\mathbf{K}}_{\ell,h}=\sum_{\ell'=1}^{\ell}\sum_{h'=1}^{H}R^{(\ell)}_{\ell',h',h}\,\mathcal{B}^{(K)}_{\ell',h'},\qquad\widetilde{\mathbf{V}}_{\ell,h}=\sum_{\ell'=1}^{\ell}\sum_{h'=1}^{H}R^{(\ell)}_{\ell',h',h}\,\mathcal{B}^{(V)}_{\ell',h'}.

Queries stay untouched, masking stays causal, and FlashAttention still applies. We initialize the current layer's slice of the router to the identity, so training starts from an exact standard transformer and learns where to deviate. Giving the router its own learning rate of 10210^{-2}, with no weight decay, speeds up circuit formation.

Because the buffers are already allocated, the overhead is nearly unmeasurable. With grouped-query attention, LIMe adds 0.00 percent parameters, 0.08 percent forward FLOPs, 1.16 percent step time, and 0.00 percent peak training memory. Hyper-Connections, the strongest alternative that widens the residual stream instead of rereading it, costs over 23 percent extra step time in the same setup.

Faster convergence at one billion parameters

We pretrained 1B-parameter LLaMA-style models from scratch on roughly 50B tokens of FineWeb Edu. Measured in training FLOPs, LIMe reaches the baseline's loss 15.3 percent sooner, 8.9 percent with grouped-query attention, and finishes with 1.15 percent lower perplexity, 0.91 percent under GQA. Same data, same optimizer, same budget; the only difference is that attention may reread earlier layers.

Three-shot accuracy at 1B parameters

accuracy, percent
LLaMAHyper-ConnectionsLIMe
Three-shot accuracy at 1B parameters Three-shot LM Evaluation Harness results for 1B GQA models. The rightmost group averages all eight reported tasks: MultiRC, WiC, QNLI, ARC-E, ARC-C, Key-Value Maps, Induction, and three-object Logical Deduction. LIMe leads on every one of the eight. MultiRC: LLaMA 43.2; Hyper-Connections 54.3; LIMe 56.2 KV Maps: LLaMA 45.9; Hyper-Connections 51.7; LIMe 55.6 Induction: LLaMA 54.2; Hyper-Connections 51.6; LIMe 55.4 Average of 8: LLaMA 48.2; Hyper-Connections 49.9; LIMe 51.7 020406080 43.2LLaMA: MultiRC, 43.254.3Hyper-Connections: MultiRC, 54.356.2LIMe: MultiRC, 56.2MultiRC45.9LLaMA: KV Maps, 45.951.7Hyper-Connections: KV Maps, 51.755.6LIMe: KV Maps, 55.6KV Maps54.2LLaMA: Induction, 54.251.6Hyper-Connections: Induction, 51.655.4LIMe: Induction, 55.4Induction48.2LLaMA: Average of 8, 48.249.9Hyper-Connections: Average of 8, 49.951.7LIMe: Average of 8, 51.7Average of 8 accuracy, percent
Three-shot LM Evaluation Harness results for 1B GQA models. The rightmost group averages all eight reported tasks: MultiRC, WiC, QNLI, ARC-E, ARC-C, Key-Value Maps, Induction, and three-object Logical Deduction. LIMe leads on every one of the eight.

The gains concentrate where recalling earlier features matters most. Key-Value Maps climbs from 45.9 to 55.6 and MultiRC from 43.2 to 56.2, while saturated pattern-completion tasks barely move. Across all eight tasks the average rises from 48.2 for LLaMA and 49.9 for Hyper-Connections to 51.7 for LIMe.

Watching collapse recede

To observe collapse directly, we borrowed a probe from Voita and colleagues: 1,668 occurrences each of is, are, was, and were, drawn from FineWeb Edu, with a four-way linear classifier trained on each layer's representations under five-fold cross-validation. If deep layers keep these near-synonyms distinct, the probe succeeds; if representations collapse, it cannot.

The four-verbs probe

Linear separability
In LLaMA the four verbs' value vectors merge in deep layers and probe accuracy drops well below one. LIMe's deep-layer values separate with accuracy near 1.0, and their matrix-based Renyi entropy stays higher throughout.

The division of labor reverses exactly as designed. LIMe's value vectors stay separable with probe accuracy near 1.0, and their matrix entropy stays higher than LLaMA's layer after layer. The residual stream itself becomes less separable than the baseline's, which is the point: the stream no longer has to carry every lexical nuance forward, because the buffers already do.

Where representation quality decides the answer

Language-model perplexity averages over mostly easy predictions, so we also measured tasks that fail precisely when intermediate representations blur. ProsQA asks a model to search over a graph of fictional concepts and verify a claim, holding several candidate reasoning paths at once. Arithmetic expressions demand exact intermediate results, where confusing 12 with 13 anywhere poisons everything downstream.

Reasoning accuracy under collapse pressure

accuracy, percent
LLaMALIMe
Reasoning accuracy under collapse pressure Open-ended generation accuracy. On ProsQA the gap is 8.4 points. On six-operand arithmetic expressions, where every intermediate value must stay distinct, the baseline drops to 41.3 percent while LIMe holds 71.6. ProsQA: LLaMA 69.4; LIMe 77.8 Arithmetic, 6 operands: LLaMA 41.3; LIMe 71.6 022.54567.590 69.4LLaMA: ProsQA, 69.477.8LIMe: ProsQA, 77.8ProsQA150M, fine-tuned41.3LLaMA: Arithmetic, 6 operands, 41.371.6LIMe: Arithmetic, 6 operands, 71.6Arithmetic, 6 operands4-layer models accuracy, percent
Open-ended generation accuracy. On ProsQA the gap is 8.4 points. On six-operand arithmetic expressions, where every intermediate value must stay distinct, the baseline drops to 41.3 percent while LIMe holds 71.6.

The arithmetic result is the cleanest picture of the mechanism. With four operands both models cope; by six, LLaMA's accuracy falls to 41.3 percent while LIMe keeps 71.6, and the values of nearby numbers remain visibly separated in LIMe's layers. Early layers can hold a partial result and let later layers compose it, instead of overwriting it in the shared stream.

Depth tells the same story at scale. Training at 32, 64, and 128 layers, LIMe wins at every depth, and its loss falls faster as depth grows: a 64-layer LIMe beats a 128-layer LLaMA that spends roughly twice the FLOPs and parameters. The deeper the network, the more a single overwritten stream costs.

What the router chose to remember

The learned routing weights are interpretable on their own. Layers 2 through 4 lean heavily on the embedding buffer, consistent with early attention handling local and morphological structure. Middle layers borrow their immediate predecessors as auxiliary memory, widening the feature subspace heads can manipulate. And the final layers reach all the way back to the first buffers before predicting, revisiting raw token identity one last time.

Which layers is the router allowed to see?

Router variantValidation perplexityVersus full LIMe
LLaMA, no router16.4611+3.36%
Uniform average of buffers16.4611+3.36%
Learned, last 2 layers16.2810+2.22%
Learned, last 4 layers16.1675+1.51%
Learned, last 6 layers16.1351+1.31%
Learned, first 2 layers15.9746+0.30%
Learned, first 4 layers15.9586+0.20%
Learned, first 6 layers15.9906+0.40%
Full LIMe router15.9267reference
Constrained routers on the 150M model. Averaging buffers without learning helps not at all. Windows over the most recent layers recover part of the gain, windows over the earliest layers recover almost all of it, and unrestricted routing wins outright.

The ablation ranks the ingredients cleanly. A uniform average of buffers is exactly as bad as no router at all, so learning where to look is the substance, not the access itself. Restricting learned routing to recent layers gives up most of the gain, while restricting it to the earliest layers keeps nearly all of it. The model's favorite memory is its oldest.

The honest costs: a naive implementation grows router terms quadratically with depth, and sharded pipeline-parallel training would need to communicate buffers between stages. Both have workable mitigations, and the restricted-window results above suggest cheap approximations that keep most of the benefit. What we take away is simpler: the memory was already there, sitting in the buffers. We only had to let attention read it.

The transformer's memory was already sitting in its key-value buffers. LIMe lets attention read it, and the single-stream bottleneck turns out to be optional.