OpenSource-Hub

rlm

alexzhang13/rlm

递归语言模型(RLM)的即插即用推理库,支持多种沙箱环境。

项目简介

RLM 以递归编程方式替代标准 LLM 调用,能处理近乎无穷的上下文。该库提供可扩展的推理引擎和训练环境,支持 API 及本地 LLM,并集成了 Docker、Modal 等多种沙箱环境以实现隔离执行。

README 预览

\n---\n\n\nRecursive Language Models (RLMs)\n\n\n\n  Full Paper •\n  Blogpost •\n  Documentation •\n  RLM Minimal\n\n\n\n  \n    \n  \n  \n    \n  \n\n\n\n  \n    \n  \n\n\n## Overview\nRecursive Language Models (RLMs) are a task-agnostic inference paradigm for language models (LMs) to handle near-infinite length contexts by enabling the LM to *programmatically* examine, decompose, and recursively call itself over its input. RLMs replace the canonical `llm.completion(prompt, model)` call with a `rlm.completion(prompt, model)` call, acting as a "language model". RLMs offload the context as a variable in a REPL environment that the LM can interact with and launch sub-LM calls inside of.\n\nRLMs are a bet on future "language model" design choices. We argue for a [CodeAct](https://arxiv.org/abs/2402.01030)-style harness (i.e. all language models should have access to a code environment) with sub-(R)LM calls as functions in code, and context / prompts as objects in code. RLMs explicitly defer code execution with sub-calls as functions to the language model itself, which is incredibly flexible and lends itself well to scale if trained correctly. We want to move away from the JSON tool-calling standard for both sub-agents and generic tool calls. The naming comes from the fact that such a system is itself a "language model" (a probabilistic mapping from text to text) that builds around and relies on recursive sub-LLM calls.\n\nThis repository provides both an extensible inference engine and training environment for using RLMs around standard API-based and local LLMs. The initial experiments and idea were proposed in a [blogpost](https://alexzhang13.github.io/blog/2025/rlm/) in 2025, with expanded results in an [arXiv preprint](https://arxiv.org/abs/2512.24601).\n\nWe now also include a [verifiers](https://github.com/PrimeIntellect-ai/verifiers) training environment based on Prime Intellect's [prime-rl](https://github.com/PrimeIntellect-ai/prime-rl) in the `training/` folder