{"slug": "what-happens-when-you-loop-the-middle-of-an-ai-model", "title": "What Happens When You Loop the Middle of an AI Model?", "summary": "Looping a pretrained Ouro model's middle layers during inference raised matched-pair accuracy from 29.0% to 44.3% on ProofWriter examples, according to an experiment run by the Operator0x author on a 10 GB RTX 3080 with the 2.668-billion-parameter checkpoint held frozen. In separate from-scratch tests, a compact 12-layer Transformer that repeated its eight middle layers up to 100 times beat its one-pass score at four passes but still trailed a standard model on longer problems and was slower, with 100 passes matching the four-pass score at 22 times the runtime. The author argues internal recurrent depth lets a model refine hidden states in continuous vector space instead of paying for extra computation through external chain-of-thought tokens.", "body_md": "AI architecture / Dynamic depth\n\n# What Happens When You Loop the Middle of an AI Model?\n\nEvery standard Transformer makes an absurd assumption: that every token in a sentence is equally difficult to generate.\n\nWhether a 70-billion-parameter model is emitting a trivial comma or resolving a deeply nested logical contradiction, it allocates the exact same amount of compute to the decision. The token vectors enter the embedding matrix, travel through `N` sequential layers, hit the unembedding projection, and exit.\n\nWhat if a model could stop and \"think longer\" on a hard decision without doubling its parameter count?\n\nOver the past year, the industry’s answer has been test-time compute via external scratchpads: generate chains of thought, write out reasoning tokens, and pay for extra computation in sequence length. But there is another axis that has received far less attention: **internal recurrent depth**. What happens if, instead of generating more words, we simply let the model loop its own hidden states through its middle layers before committing to an output?\n\nThe residual stream is fundamentally an iterative refinement canvas. External scratchpads force a model to project internal representations all the way down into discrete language tokens – a lossy, bottlenecked projection – just to read them back in on the next step. Looping the middle lets the model stay inside its continuous vector space, polishing its internal hypotheses at the edge of chaos before committing to a word. (For more on how token representations relate to execution, see [Words Are Just Shadows](https://operator0x.com/field-notes/model-execution-graph/) and [At the Edge of Chaos](https://operator0x.com/field-notes/edge-of-chaos/)).\n\nI decided to test this empirically on consumer hardware. The results were far weirder – and more revealing – than I anticipated.\n\n## The Small Transformer Did Better Without Loops\n\nI started where most people start: training tiny Transformer baselines from scratch. I built a compact 12-layer model and a variant that repeated the same eight middle layers up to 100 times.\n\nOn a pointer-following task, the training loss fell. Four passes helped the loop over its one-pass score, but the regular model still did better on longer problems and was faster. A hundred passes got the same longer-problem score as four and took 22 times as long.\n\nStandard validation metrics are notoriously forgiving because language models can cheat. They memorize surface-level linguistic statistics and guess common patterns. To expose what was actually happening inside the representations, I needed a counterfactual stress test: **The Matched-Pair Office Badge Test**.\n\nConsider this illustrative pair of prompts:\n\n**Prompt A:** *\"Alice holds a security badge issued for Building 4. The badge scanner reads: Status: VALID. Does Alice get access to Building 4? Answer yes or no.\"*\n\n**Prompt B:** *\"Alice holds a security badge issued for Building 4. The badge scanner reads: Status: EXPIRED. Does Alice get access to Building 4? Answer yes or no.\"*\n\nIn an isolated accuracy test, a model that simply defaults to outputting `\"yes\"` 100% of the time gets a 50% score. It looks like it understands half the world.\n\nIn a **matched-pair test**, a model receives a point **only if it gets both sides of the minimal pair right**. If it outputs `\"yes\"` for Prompt A, it *must* output `\"no\"` for Prompt B. If it fails either side, it gets a 0.\n\nFor the larger-model test, I took a pretrained Ouro checkpoint and ran it on matched pairs from [ProofWriter](https://aclanthology.org/2021.findings-acl.317/). I kept its weights frozen and changed how its layers repeated during inference.\n\n## Looping the Middle Layers Raised Pair Accuracy From 29.0% to 44.3%\n\nOuro is an open-weight model designed for recurrent execution. I ran the 2.668-billion-parameter checkpoint on my 10 GB RTX 3080.\n\nI constructed an experiment that matched the number of layer visits.\n\n1. **Native Ouro:** Running all 48 layers twice.\n2. **Middle-Layer Loop:** Running the first 18 layers once, the middle 12 layers five times, and the last 18 layers once. On each repeat, I mixed the candidate update with the carried state and part of the entry state.\n\nBoth variants had **96 layer visits** and almost identical median times for a single forced-choice answer without a KV cache, 215 ms for native Ouro and 218 ms for the middle loop. Then I ran them through the 176 matched-pair counterfactual suite.\n\nThe result stopped me in my tracks:\n\n- **Native Ouro (Full Recurrence):** 51 / 176 pairs correct (29.0%)\n- **Middle-Layer Loop:****78 / 176 pairs correct (44.3%)**\n\nWith the exact same frozen weights and the same number of layer visits, the middle-loop variant got 27 more pairs right, a **53% relative improvement** on this matched-pair test.\n\n```\nMatched-Pair Accuracy (/176, higher is better)\nNative Full Recurrence (all 48 layers, 2 passes)\n[██████████                    ] 51 (29.0%)\n\nMiddle-Layer Loop (12 middle layers, 5 passes)\n[███████████████               ] 78 (44.3%)\n0%            25%            50%\n```\n\n### Did Looping Squeeze More Reasoning Out of the Same Weights?\n\nOn this test, it looks like it. The same weights handled more cases where getting the answer right meant paying attention to which facts had changed.\n\nExact accuracy counts which answer ranks first. Log loss also cares how much probability the model gives the correct answer. Native Ouro had lower average log loss over the three answer choices, while the middle loop got both answers right on more pairs.\n\nHowever, recurrence is a double-edged sword. When I pushed the middle loop beyond its optimal operating window, matched-pair accuracy fell:\n\n| Configuration | Total Layer Visits | Cross-Entropy Loss (lower is better) | Matched Pairs Correct (higher is better) | Pair Accuracy (higher is better) | \n|---|---|---|---|---|\n| Middle Loop (9 passes) | 144 | 0.849 | 79 / 176 | 44.9% | \n| **Middle Loop (5 passes)** | **96** | **0.886** | **78 / 176** | **44.3%** | \n| Middle Loop (4 passes) | 84 | 0.923 | 75 / 176 | 42.6% | \n| Middle Loop (13 passes) | 192 | 0.838 | 73 / 176 | 41.5% | \n| Native Full Recurrence (2 passes) | 96 | **0.825** | 51 / 176 | 29.0% | \n| Middle Loop (2 passes) | 60 | 1.105 | 17 / 176 | 9.7% | \n| **Single Pass (No Loop)**(regular Transformer-style baseline using the same Ouro weights) | 48 | 1.213 | 3 / 176 | 1.7% | \n\nFrom nine to thirteen passes, exact accuracy fell from 79 to 73 fully correct pairs even as mean log loss improved. The test measured that divergence. What changed in the representations remains open.\n\n## How Deep Should a Model Go?\n\nIf extra passes help on some decisions, the obvious next step is to make the depth dynamic and train a learned exit gate that decides when to stop looping.\n\nI trained an early-exit routing head on the answer probabilities and the current pass number. The goal was to predict whether another pass would improve the correct answer's log loss.\n\nIt fell well short of the fixed loop.\n\nThe learned exit gate averaged **1.08 passes** and got **8 of 176 pairs** right. It usually stopped before the pass counts that helped in the fixed-depth sweep.\n\nThis points to a fundamental frontier in model architecture: **teaching a model to recognize its own uncertainty before it produces a token.**\n\n```\n                       ┌──────────────────────────────────────────────┐\n                       │           Dynamic Recurrent MoE              │\n                       └──────────────────────────────────────────────┘\n                                              │\n                      ┌───────────────────────┴───────────────────────┐\n                      ▼                                               ▼\n         [Pass 1: Broad Routing]                             [Pass 2: Refinement]\n      Hidden state probes syntax &                       Hidden state routes through\n         factual association                                 specialized logic &\n   (Token routed to: Expert A & C)                          constraint-checking blocks\n                                                         (Token routed to: Expert B & F)\n```\n\nThe puzzle becomes even more compelling when combined with **Mixtures of Experts (MoE)**. In a mixture-of-experts layer, a router can send a token to a subset of the available experts. If you introduce recurrent middle depth, you give the network two orthogonal degrees of freedom:\n\n1. **Temporal depth:** How many passes does this specific token need?\n2. **Dynamic specialization:** Which experts should process the state on Pass 1 versus Pass 3?\n\nA model could use Pass 1 to parse syntax and entity relations through broad-coverage feed-forward networks, and then use Pass 2 and 3 to route through specialized symbolic or logical constraint experts – all while maintaining the option to emit external scratchpad tokens when a problem exceeds the bounds of internal vector memory. (For an analysis of the trade-offs between parameter storage and compute routing, see [How Small Can We Slice an AI Model?](https://operator0x.com/field-notes/weights-still-need-a-home/)).\n\n## How Much Can We Fit into the Same Weights?\n\nLet’s look at the raw hardware economics – and what happens when you push loop efficiency to its logical extreme.\n\n### Getting More Passes From the Same Weights\n\nThe matched variants used about **5 GiB** for weights plus forward allocations on the RTX 3080. The middle loop stored one copy of its weights and reused it across passes.\n\nEach extra pass runs the same 12 middle layers again. That adds a quarter of a full 48-layer pass, with no extra weights to store. Five trips through the middle give the model twice as many layer visits as a single trip through the whole model. Nine trips give it three times as many.\n\nThe gains tapered off. Five middle passes got 78 pairs right. Four more passes got just one more pair right, and at thirteen passes the score fell to 73.\n\n### Could the Weights Take Up One Hundredth of the Memory?\n\nMy bet is that for some tasks, we can get the same quality with about one hundredth of the weight memory of a dense 16-bit model.\n\nHere’s one way to get to 100× on paper. Going from 16 bits to 4 bits gives a 4× reduction in raw storage per weight. That leaves a much harder target: storing 25× fewer weights. A model could learn a useful step once, apply it repeatedly inside its hidden state, and spend those extra passes where they help. If a task mostly needs the same operation applied several times, more of the work could come from extra passes through a small set of weights. The test is whether that smaller model can keep its accuracy and answer fast enough to use.\n\n### Automated Architecture Search and Recursive Self-Improvement\n\nRight now, human engineers are hand-crafting these loops like cavemen banging rocks together. We guess: *\"Let's loop layers 10 through 26 three times.\"* That is crude, rigid, and sub-optimal.\n\nGrant Sanderson’s [Compression is Intelligence](https://www.youtube.com/watch?v=l6DKRf-fAAM) explores the connection between prediction and compression. How far we can push that idea for model weights is still an open question. The frontier labs are currently caught in an arms race of brute-force parameter expansion. But the real masterstroke will belong to whoever figures out how to make tiny, hyper-dense models run recursive loops through their own hidden states.\n\nThe hardware is already sitting on our desks. We just need to stop treating inference as a one-way street.\n\nAs I write this, I’m hoping my AI provider lets me keep my API key. I have a few more loops to try.", "url": "https://wpnews.pro/news/what-happens-when-you-loop-the-middle-of-an-ai-model", "canonical_source": "https://operator0x.com/field-notes/looping-middle-layers/", "published_at": "2026-11-24 15:41:38+00:00", "updated_at": "2026-11-24 15:44:14.894687+00:00", "lang": "en", "topics": ["artificial-intelligence", "machine-learning", "large-language-models", "ai-research", "neural-networks"], "entities": ["Ouro", "ProofWriter", "RTX 3080", "Operator0x"], "also_reported_by": [], "takeaway": "Repeating a pretrained recurrent model's middle layers at inference, with weights frozen, lifted matched-pair accuracy from 29.0% to 44.3% on ProofWriter, while 100 loop passes matched four passes' longer-problem score at 22 times the runtime.", "recommendation": {"advice": "Score models on matched pairs where both sides of a minimal contrast must be correct, since a constant 'yes' answer scores 50% on isolated accuracy but 0% on pairs.", "playbook": "evals-testing", "playbook_url": "https://wpnews.pro/playbooks/evals-testing"}, "alternates": {"html": "https://wpnews.pro/news/what-happens-when-you-loop-the-middle-of-an-ai-model", "markdown": "https://wpnews.pro/news/what-happens-when-you-loop-the-middle-of-an-ai-model.md", "text": "https://wpnews.pro/news/what-happens-when-you-loop-the-middle-of-an-ai-model.txt", "jsonld": "https://wpnews.pro/news/what-happens-when-you-loop-the-middle-of-an-ai-model.jsonld"}}