The year/Independent research

Paper 2512.24601

Recursive Language Models

Published
Dec 2025
Research lab
Independent
Citations
64
GitHub
5.4K stars

01 In brief

Summary

The paper introduces Recursive Language Models (RLMs), an inference-time framework that treats arbitrarily long prompts as part of an external environment, allowing an LLM to programmatically examine, decompose, and recursively call itself over prompt snippets.

RLMs use a REPL environment where the prompt is stored as a variable, and the model writes code to interact with it, including launching sub-LLM or sub-RLM calls.

This enables processing inputs beyond the model's context window and improves performance on long-context tasks.

Evaluations with GPT-5 and Qwen3-Coder-480B-A35B across four benchmarks (CodeQA, BrowseComp-Plus, OOLONG, OOLONG-Pairs) show RLMs outperform base models, compaction agents, and coding scaffolds (e.g., CodeAct, Claude Code) by double-digit percentages, with comparable or lower costs.

RLMs also scale to 10M+ tokens and handle information-dense tasks better.

A fine-tuned 8B model (RLM-Qwen3-8B) improves over its base by 28% median.

RLMs also enhance long reasoning on LongCoT-mini, and training exhibits length generalization.

Key design choices include offloading the prompt to the environment, symbolic recursion, and avoiding direct output generation.

02 From the paper

Abstract

We study allowing large language models (LLMs) to process arbitrarily long prompts through the lens of inference-time scaling. We propose Recursive Language Models (RLMs), a general inference paradigm that treats long prompts as part of an external environment and allows the LLM to programmatically examine, decompose, and recursively call itself over snippets of the prompt. We find that RLMs can successfully process inputs up to two orders of magnitude beyond model context windows and, even for shorter prompts, dramatically outperform the quality of vanilla frontier LLMs and common long-context and coding scaffolds (e.g., on GPT-5 by a median across the evaluated benchmarks of $26\%$ against compaction, $130\%$ against CodeAct with sub-calls, and $13\%$ against Claude Code) across four diverse long-context tasks while having comparable cost. At a small scale, we post-train the first model around the RLM. Our model, RLM-Qwen3-8B, outperforms the underlying Qwen3-8B model by $28.3\%$ on average and even approaches the quality of vanilla GPT-5 on three long-context tasks. Code is available at https://github.com/alexzhang13/rlm.