Looped transformers, explained simply

Can a model think longer without getting bigger? A looped transformer does it with one trick: it runs the same block again and again.

Who is Ann's great-grandfather?

We use one example for the whole lesson. The model knows three facts: Ann's dad is Ben. Ben's dad is Carl. Carl's dad is Dan. To answer, it must go from Ann to Ben, from Ben to Carl, and from Carl to Dan. That is three steps of thinking.

New to transformers? Start with How a transformer works. Colours: blue is the model and its weights, amber is where to look, green is the right answer, red is a cost or a wrong answer.

1A normal transformer is a stack

A normal transformer is a stack of blocks. Each block has its own weights: the numbers that the model learned in training. The data goes up through each block one time, so each block gives one step of thinking.

More blocks give more steps. But each new block brings its own weights, so the model also gets bigger. Move the slider and compare.

Normal

Looped

Figure 1. The bar under each model shows its weights. Both models do the same number of steps. The normal model needs a new block for each step. The looped model sends the output of its one block back into the same block.

2The trick: one block, many laps

A looped transformer keeps one block and sends its output back into its input. Each pass round the loop is a lap. Every lap uses the same weights, so six laps give six steps of thinking with the weights of one block.

Real looped models don't loop just one block. They loop a stack of blocks, a few times. Ouro, a looped model from ByteDance, runs its whole stack of 24 blocks 4 times. You can try these numbers in section 6.

3One hop per lap

Why do laps help? Many questions need a chain of steps. Each step uses the result of the step before it. In our example, each step is one hop from a person to their dad.

Ann's dad is Ben. Ben's dad is Carl. Carl's dad is Dan.

Choose a question and the number of laps. Then run them.
Figure 2. A simple picture of the idea. A real model doesn't store names in its vectors, and its laps are not always this tidy. But it shows why a question with more hops needs more laps.

Too few laps and the model stops halfway: it answers Carl. Too many laps and the extra laps find nothing new: they only cost time. So the best number of laps depends on the question.

4Thinking without words

Reasoning models often think in words: they write their steps before the answer. This is called chain of thought. Each word that the model writes is one more full pass through the model.

A looped model does its steps inside, as laps. Nobody sees them, and it writes only the answer. This is called latent reasoning: reasoning in the model's hidden numbers.

Chain of thought: the steps are words
words written: 0
Looped: the steps are laps inside
words written: 0
Figure 3. Both find Dan. Chain of thought shows its steps, so you can read them. The looped model hides its steps, but it doesn't need to write them. The two ideas can also work together.

5Stop when the answer is ready

Easy questions need few laps. Hard questions need more. So Ouro has a small exit gate. After each lap, the gate gives a probability that the answer is ready. The model adds these up, and it stops at the first lap where the total reaches a threshold: q.

Figure 4. Left bar: what the gate says after each lap. Right bar: the total so far, with q as the dashed line. The gate's numbers here are made up. The rule, stop at the first lap where the total reaches q, is the rule that Ouro uses.

A small q stops early. That is fast, but the model can stop before the answer is ready. A large q is careful, but slower. Set q to 0.5 and choose the hard question: the model stops after lap 2 and answers Carl.

6What the loop gives, and what it costs

A looped model has the depth of a big model and the weights of a small model. In tests, Ouro's looped models with 1.4 and 2.6 billion parameters (weights) did about as well as normal models with 4 and 8 billion on most benchmarks.

But the loop isn't free. Each lap is one more pass through the blocks, so a looped model takes as much time for each word as a normal model of the same depth. Try it:

Figure 5. Blue bars: the weights (the size of the model). Red bars: the steps for each word (the time). The looped model has the weights of the small normal model, and the time of the big one.

There is one more limit. Loops don't give a model more facts. The Ouro team measured how much a model can remember: about 2 bits of knowledge for each parameter, with or without loops. The loops help the model use its facts better, for example to join facts in a chain, as in our example.

7Where the idea comes from

Check yourself

    The whole picture

    1. One block, many laps. The output goes back into the same block, with the same weights.
    2. More laps, more steps. Each lap can do one more step of a chain, like one more hop from Ann to Dan.
    3. The exit gate stops the loop when the answer is ready, so easy questions use fewer laps.
    4. The gain: the depth of a big model with the weights of a small one.
    5. The cost: each lap takes time, and loops add no new facts.

    That's a looped transformer: more thinking, with the same weights.

    Next level

    Not published yet. It will cover: