alexzhang13 / rlm
Summary
Recursive Language Models (RLMs) offer a task-agnostic inference paradigm. They enable language models (LMs) to handle near-infinite contexts by programmatically examining, decomposing, and recursively calling themselves. This approach replaces the standard `llm.completion` with `rlm.completion`, offloading context to a REPL environment for code execution and sub-LM calls. Proposed in a 2025 blogpost and detailed in a December 2025 arXiv preprint (2512.24601), RLMs advocate for a CodeAct-style harness where LMs access a code environment. The `rlms` repository provides an extensible inference engine and training environment for API-based and local LLMs, requiring Python 3.11 or later. It supports various REPL environments, including `local`, `ipython`, `docker`, `modal`, `prime`, `daytona`, and `e2b`, with options for isolated cloud-based sandboxes. A `verifiers` training environment, based on Prime Intellect's `prime-rl`, is also included.
Key takeaway
For machine learning engineers building advanced language model applications, if you struggle with context window limitations or complex multi-step reasoning, explore Recursive Language Models. This paradigm allows LMs to programmatically decompose tasks and manage near-infinite contexts, moving beyond traditional JSON tool-calling. Consider integrating the `rlms` library to enable self-recursive LM capabilities. Leverage isolated REPL environments for secure execution.
Key insights
RLMs enable LMs to programmatically self-call and decompose tasks for near-infinite context handling.
Principles
- LMs should access a code environment.
- Sub-LM calls can be functions in code.
- Context and prompts can be code objects.
Method
RLMs replace standard `llm.completion` with `rlm.completion`, offloading context to a REPL environment where the LM executes code and launches sub-LM calls.
In practice
- Install `rlms` via `pip` for Python 3.11+.
- Use `RLM(backend="openai", ...)` for completions.
- Configure isolated REPLs like Modal or Prime Sandboxes.
Topics
- Recursive Language Models
- Long Context Handling
- CodeAct Harness
- REPL Environments
- LLM Inference
- Agentic AI
Code references
- alexzhang13/rlm-minimal
- alexzhang13/rlm
- PrimeIntellect-ai/verifiers
- PrimeIntellect-ai/prime-rl
- willccbb/verifiers
Best for: Research Scientist, AI Engineer, NLP Engineer, AI Scientist, Machine Learning Engineer, AI Architect
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by Github Trending: All languages.