HubLensLLMalexzhang13/rlm
44

// summary

Recursive Language Models (RLMs) provide a task-agnostic inference paradigm that enables language models to handle near-infinite contexts through programmatic decomposition and recursive self-calling. The framework replaces standard completion calls with an RLM-specific interface that offloads context into a REPL environment for interactive execution. This repository offers an extensible engine supporting various local and cloud-based sandbox environments to facilitate complex, multi-step language model reasoning.

// technical analysis

Recursive Language Models (RLMs) introduce a task-agnostic inference paradigm that enables language models to handle near-infinite contexts by programmatically decomposing tasks and recursively calling themselves. By treating the context as a variable within a REPL environment, the system allows models to interact with and launch sub-LM calls, effectively offloading complex reasoning processes. This architecture prioritizes extensibility and modularity, offering a trade-off between local execution speed and the security of isolated cloud-based sandboxes for code execution.

// key highlights

01
Enables near-infinite context handling by allowing models to recursively decompose and process input tasks.
02
Provides a flexible REPL-based inference engine that replaces standard LLM completion calls with a programmable interface.
03
Supports multiple execution environments including local, Docker, and cloud-based sandboxes like Modal and E2B for secure code execution.
04
Includes a built-in logging and visualization tool to inspect complex execution trajectories, sub-LM calls, and code generation.
05
Maintains compatibility with major model providers such as OpenAI and Anthropic, while supporting local models via vLLM.
06
Offers both non-isolated local execution for low-risk tasks and fully isolated sandboxing to mitigate security risks during code generation.

// use cases

01
Handling near-infinite length contexts via programmatic decomposition
02
Executing recursive sub-LM calls within isolated cloud-based sandboxes
03
Visualizing complex model reasoning trajectories through integrated logging and inspection tools

// getting started

To begin, install the package using 'pip install rlms'. You can then initialize the RLM client by specifying your preferred backend and environment, and execute tasks using the 'rlm.completion' method. For advanced use, you can configure an 'RLMLogger' to save execution trajectories to disk and inspect them using the provided Node.js-based visualizer.