Skip to slide
Chapter 5 · Recursive Language Models, Thinking Beyond the Memory Limit
36 / 53

CHAPTER 05 · Recursive Language Models, Thinking Beyond the Memory Limit · 2 / 6

The idea: treat the long prompt as an environment, not a thing to read

Here is the shift in thinking. Instead of forcing the entire giant input into the model's memory all at once, RLMs keep the input outside the model, as data the model can explore. The long prompt is placed into a REPL, a small live programming environment, as a variable the model can examine with code.

Now the model does not try to read everything. It writes code to peek at the input: check how long it is, search it for relevant parts, slice it into chunks. It pulls in only the pieces it actually needs, when it needs them, rather than drowning in the whole thing.

flowchart TD
    Big[Huge input kept outside the model,<br/>as a variable in a REPL] --> Root[Root model writes code to explore it]
    Root --> Peek[Peek at length, search,<br/>slice into relevant chunks]
    Peek --> Need{Chunk small enough<br/>to handle directly?}
    Need -->|Yes| Solve[Answer it directly]
    Need -->|No| Rec[Call itself on the chunk]
    Rec --> Root
    Solve --> Combine[Combine results<br/>into a final answer]
← → arrow keys work too