alexzhang13/rlm

General plug-and-play inference library for Recursive Language Models (RLMs), supporting various sandboxes.

What it solves

RLMs address the challenge of handling near-infinite length contexts in language models. Instead of passing a massive prompt to a single model call, this paradigm allows a model to programmatically decompose a task and recursively call itself to process information in smaller, manageable pieces.

How it works

RLMs replace the standard completion call with a system that treats the context as a variable within a REPL (Read-Eval-Print Loop) environment. The language model interacts with this environment by writing and executing code. Within this code, the model can launch sub-LM calls as functions, treating prompts and contexts as objects. This shifts the interaction from JSON-based tool calling to a CodeAct-style harness where the model manages its own execution flow and recursive sub-calls.

Who it’s for

This project is for AI researchers and developers building advanced inference engines or agents that need to process extremely long contexts or perform complex, multi-step reasoning that requires programmatic control.

Highlights

  • Flexible REPL Environments: Supports a variety of execution environments including local (exec/IPython), Docker, and cloud-based sandboxes (Modal, Prime Intellect, E2B, Daytona).
  • Recursive Inference Engine: Provides an extensible engine that enables models to call themselves recursively to solve tasks.
  • Integrated Training Harness: Includes a training environment based on prime-rl and verifiers to train models specifically for the RLM paradigm.
  • Trajectory Logging: Features a logger and a dedicated visualizer to inspect the full execution path of code, sub-LM, and root-LM calls.

Related

  • Project
  • Project
  • Project
  • Project
  • Project