RLM is an inference library for Recursive Language Models that enables language models to handle near-infinite length contexts by programmatically examining, decomposing, and recursively calling themselves over their input.
The library addresses the challenge of processing extremely long contexts by replacing the standard completion call with a recursive approach where language models operate within a REPL environment. Rather than passing all context at once, RLMs offload context as variables that the model can interact with and use to launch sub-model calls. This approach treats context and prompts as objects in code, with sub-calls functioning as code-based operations rather than JSON tool calls. The system is task-agnostic and designed around a CodeAct-style harness where language models have access to a code execution environment.
Developers considering adoption should understand that RLM represents an experimental inference paradigm grounded in research rather than a production-hardened framework. The tool suits projects exploring novel language model architectures and those dealing with exceptionally long context requirements where traditional approaches prove insufficient. The library supports both API-based and local language models with extensible sandbox environments. A minimal reference implementation is available separately for those wanting to understand the core concepts before adopting the full library.
The project maintains automated style and test workflows to ensure code quality. The repository includes a training environment based on established reinforcement learning infrastructure, allowing users to train custom RLMs that integrate directly with the inference engine. Documentation is provided alongside the academic paper and accompanying blog materials that explain the conceptual foundations and experimental results.