Recurrent Transformer Layers: More Internal Computation Without More Parameters
Reusing a Transformer’s middle layers can increase its effective depth without adding another set of weights. This article explains how shared-weight recurrence changes hidden-state processing, how it differs from chain-of-thought generation, and why gating, cache management, and careful evaluation matter when balancing model capability against inference cost.
As large language models continue to scale, two straightforward paths to greater capability stand out: increasing parameters to expand the model’s representational capacity, or increasing inference-time computation so the model performs more internal transformations before producing an answer. The first resembles constructing a larger building; the second resembles having the same team review a plan again.
One class of architectural changes follows the second path. Rather than substantially increasing the parameter count or redesigning the entire base network, it selects a block of middle layers and passes the hidden states through that same block again.
For a base model with 78 layers, the execution path might look like this:
First 26 layers: execute onceMiddle 28 layers: execute twice using the same weightsFinal 24 layers: execute once
The number of layer executions in a forward pass therefore increases from:
26 + 28 + 24 = 78
to:
26 + 28 × 2 + 24 = 106
What increases is computation, not the number of parameters. The middle 28 layers do not acquire a second set of weights. Their second pass uses the same parameters, but receives states already transformed by the first pass, so it is not processing exactly the same information.
1. What Does Layer Recurrence Change?
A standard Transformer can be viewed as a layer-by-layer processing pipeline. Hidden states pass through attention, feed-forward networks, normalization, and residual connections, gradually forming more abstract semantic representations. Each layer typically executes once, so information integration, relationship analysis, and answer construction must take place within a fixed depth.
With recurrence in the middle layers, the process can be simplified as:
h_mid = Block(h_in, W_mid)h_out = Block(h_mid, W_mid)
Here, W_mid represents the shared middle-layer weights. Although the second execution uses the same parameters, its input has changed from h_in to h_mid. It therefore continues transforming an updated state rather than merely duplicating a result.
Functionally, the first pass might focus more on:
- Establishing local semantic relationships.
- Gathering relevant information from the context.
- Identifying the initial structure of the problem.
- Forming candidate intermediate representations.
The second pass might contribute to:
- Reorganizing relationships already established.
- Further resolving conflicts in the representation.
- Strengthening connections between distant information and the current task.
- Refining a coarse intermediate state into a representation better suited to subsequent output layers.
Describing the second pass as a “review” is only an explanatory analogy. It does not imply that the model contains an explicit human-like draft, consciousness, or subjective thought. The underlying operation remains another transformation of continuous vectors within a neural network.
2. Why Not Simply Add 28 More Layers?
If the goal is greater computational depth, the most direct approach is to add 28 layers with independent parameters. That comes with several costs.
First, the parameter count increases. Additional layers require attention matrices, feed-forward network matrices, normalization parameters, and corresponding training storage.
Second, training becomes more demanding. New layers must adapt alongside the existing network, introducing challenges involving initialization, optimization stability, and data requirements.
Third, inference memory and communication demands can rise. In large-scale deployments, parameters must not only be stored but may also need to be sharded and synchronized across devices.
Shared-weight recurrence offers a different compromise: existing parameters perform more computation. This increases effective network depth while keeping the parameter count largely unchanged.
The additional capacity is not free, however. A second pass still consumes compute, time, and energy.
| Approach | Parameter count | Computation per request | Representational depth | Main cost |
|---|---|---|---|---|
| Add independent layers | Increases | Increases | Increases | Parameters, training, and memory |
| Repeat middle layers | Largely unchanged | Increases | Increases | Inference latency and compute |
| Generate multiple complete samples | Unchanged | Increases substantially | Unchanged within each pass | Repeated generation and result selection |
| Extend explicit chain of thought | Unchanged | Grows with output length | Depends on generated steps | Output tokens and context overhead |
The distinguishing feature of recurrent layers is that they increase the depth of internal transformations rather than requiring the model to generate more visible text.
3. Recurrence Is Not Simply Replaying Earlier Attention
A common misconception is that the second pass repeats the first pass’s attention results unchanged. A more accurate explanation distinguishes three types of state.
Hidden States Change
The second pass through the middle layers usually receives the hidden states produced by the first pass. Because those states have changed, the queries, keys, and values computed during the second pass also change.
The second pass is therefore not a mechanical repetition over identical inputs.
Historical Key-Value Caches May Be Partially Reused
During autoregressive generation, previously processed tokens typically retain cached keys and values. This avoids recomputing the entire history whenever a new token is generated.
If a recurrent architecture reconstructs all historical caches for each pass, memory and computational costs can increase significantly. Implementations may therefore consider:
- Retaining existing indices or caches for more distant history.
- Keeping finer-grained intermediate results for the current local region.
- Recomputing only the portions affected by recurrence.
- Balancing accuracy, memory use, and latency.
Cache reuse does not mean that nothing needs updating. If the second pass changes a hidden representation, whether its associated keys and values must be updated—and over what range—depends on the architecture and cache strategy.
Sparse Attention Indices May Remain Useful
When a model uses local windows, block-based connections, or other sparse attention mechanisms, the connection pattern is often more stable than the underlying vectors. A second pass can reuse established sparse attention indices, reducing the overhead of searching again for relevant positions.
Reusing indices means that “which positions to attend to” can remain unchanged. It does not mean that “the content at those positions” requires no further computation.
Indices, keys and values, and attention weights are distinct objects and should not be conflated.
4. Why Gating Matters
Forcing the same block to execute repeatedly can modify representations too aggressively. A stronger second pass is not always better, and neither is a higher recurrence count.
A gate or step-size control can let the model learn how much to update the state on a given pass. One abstract formulation is:
u = Block(h)g = sigmoid(G(h))h_next = h + g * (u - h)
In this formulation:
uis the candidate state produced by the block.gis a gating coefficient between 0 and 1.h_nextis the updated state.
A larger gate value incorporates more of the new result. A smaller value preserves more of the original state. This can help limit overcorrection, numerical instability, or semantic drift during recurrence.
From an optimization perspective, gating can also help the model learn different computational requirements for different tasks. A simple factual query may need little additional refinement, while multistep mathematical reasoning, complex code analysis, or relationship analysis across long documents may benefit from a more substantial middle-layer update.
5. How It Differs from Chain of Thought
Conventional chain-of-thought generation adds reasoning steps by producing intermediate text. Each step can become part of the context for later steps, increasing token usage, cache requirements, and context-length consumption.
Middle-layer recurrence instead operates in hidden-state space:
Input tokens↓First pass through the middle layers↓Second pass through the middle layers↓Subsequent layers↓Output tokens
It does not require each internal step to be translated into natural language or exposed to the user. Internal computation can therefore increase even when the final output becomes shorter.
This also creates a limitation: an external observer cannot easily determine which internal steps occurred by examining the output alone. Shorter output indicates a change in the generation path, but does not establish that the model has an interpretable, stable, human-like drafting process.
6. Why Not Split the Model into Drafting and Final-Answer Specialists?
An apparently natural design would assign some modules to internal drafting and others to producing the final answer. Such a rigid division is not necessarily better than a shared structure.
First, reasoning and expression are not fully independent. Understanding a question, selecting evidence, and organizing an answer require repeated information exchange. A hard separation may lose information when passing intermediate representations between modules.
Second, tasks require different depths of processing. A fixed drafting module may waste computation on simple tasks while remaining insufficiently flexible for difficult ones.
Third, independent modules introduce more parameters, more complex training objectives, and higher deployment costs. Shared middle layers may be less intuitive than fully separate components, but they make it easier to reuse the capabilities of an existing base model.
A more flexible direction is to use gating, routing, or dynamic stopping mechanisms to determine whether additional computation is needed for a particular input, rather than dividing responsibilities completely.
7. Can Hidden States Carry Annotation Dimensions?
From an engineering perspective, auxiliary channels could be attached to hidden states to record stage markers, confidence, source cues, or recurrence counts. Such designs require care.
Hidden states are not manually completed tables. Adding a few “annotation” dimensions does not ensure that the model will use them as interpretable labels. Making those dimensions consistently encode specific information generally requires additional training constraints, such as auxiliary losses, state supervision, or consistency objectives.
Annotation dimensions can also create new problems:
- Greater coupling within representations, making the main task harder to optimize.
- Excessive dependence on explicit markers.
- Semantic drift across tasks.
- Additional storage and communication overhead.
- Signals that appear interpretable but are not actually stable.
Before adding an “annotation field,” it is more useful to define the problem being addressed. Improving recurrence stability, increasing interpretability, and recording the computational stage are different objectives and may require different structural choices.
8. How to Evaluate Whether Recurrence Works
A single benchmark or a reduction in output length is not enough to establish effectiveness. A more complete evaluation should cover several dimensions.
Capability
Measure performance on mathematics, coding, long-context tasks, information extraction, and multistep reasoning. Compare outcomes at the same parameter scale.
Computational Cost
Record actual floating-point operations per input, inference latency, memory consumption, cache size, and energy use. An unchanged parameter count does not imply unchanged deployment cost.
Stability
Test across different input lengths, difficulty levels, and batch sizes. Check whether additional recurrence leads to degradation, repeated overcorrection, or unstable outputs.
Training Efficiency
Compare the data, optimization steps, and convergence time required for continued training. Determine whether improvements come from the structure itself or from additional training resources.
Ablation Studies
At a minimum, compare:
No recurrenceOne fixed extra passGated recurrenceAdditional independent layersMultiple external samples
These comparisons help distinguish benefits from recurrence itself, benefits from increased computation generally, and benefits attributable to more training resources.
9. The Broader Lesson: Scaling Beyond Parameter Count
The central insight is not a particular allocation of layers. It is a broader way to think about scaling model capability.
Parameter count is often treated as the primary indicator of a model’s potential, but practical systems are also shaped by factors that can be summarized conceptually as:
Model parameter count×Effective network depth×Inference-time compute budget×State-memory and information-routing efficiency
Parameters influence how much knowledge a model can store and combine. Depth determines how many transformations information can undergo. The inference budget determines whether the model can devote more processing to difficult problems. Cache management and routing determine whether that processing can be delivered at an acceptable cost.
Running the middle layers again without adding parameters does not make computation free. It creates another trade-off between parameter scale and inference cost.
For future language-model systems, the key question may be less about building a larger network and more about deciding dynamically:
- Which information deserves repeated computation?
- Which states can be reused?
- When should processing continue?
- When should it stop?
Progress will increasingly depend on the coordination of architectural design, compute scheduling, and state management—not parameter growth alone.
