Recursive Language Models
An inference library for Recursive Language Models, a task-agnostic paradigm that lets a language model programmatically examine, decompose and recursively call itself over near-infinite-length contexts.
Recursive Language Models replace a plain llm.completion(prompt, model) call with rlm.completion(prompt, model), offloading the input context as a variable inside a REPL environment that the model can inspect and call itself over. The repository provides both an inference engine and a training environment for standard API-based and local LLMs.
The approach argues for a CodeAct-style harness in which sub-language-model calls are functions in code and prompts are objects in code, moving away from JSON tool-calling for sub-agents and generic tool calls. The default client runs its REPL through Python exec calls on the host process, sharing the host's virtual environment and dependencies with some limits on available global modules; a verifiers training environment based on Prime Intellect's prime-rl is also included.
It installs with pip install rlms, requires Python 3.11 or later, is written in Python, and is licensed under MIT.