项目简介
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
常见问题 (2)
故障排除为什么 `pip install rlms` 会安装 v0.0.1a1,并在 Python 3.10 上因 `ModuleNotFoundError: No module named 'rlm'` 报错而失败?
故障排除
为什么 `pip install rlms` 会安装 v0.0.1a1,并在 Python 3.10 上因 `ModuleNotFoundError: No module named 'rlm'` 报错而失败?rlms 0.1.0 要求 Python >= 3.11,而旧的 0.0.1a1 占位包没有 Python 版本约束。在 Python 3.10 上,pip 因此会回退到该不兼容的占位包并报告安装成功。请使用 Python 3.11 或更高版本进行安装:
python3.11 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip uninstall -y rlms
pip install rlms
pip show rlms # 必须显示 Version: 0.1.0
python -c "from rlm import RLM"
在 Python 3.10 上,pip install rlms==0.1.0 会失败并报错 No matching distribution found;不应使用 0.0.1a1,因为它仅包含一个版本字符串。软件包维护者可以通过撤回(yank)0.0.1a1 或发布兼容 Python 3.10 的版本来解决这一静默回退问题。
故障排除如何让 rlm_query_batched 并行运行独立的 RLM 子查询?
故障排除
如何让 rlm_query_batched 并行运行独立的 RLM 子查询?升级到包含 PR #136 的版本。在该版本中,rlm_query_batched 会使用有界的 ThreadPoolExecutor 自动并发运行 2 个或更多独立的子 RLM 调用,并按照原始提交顺序返回结果。这将 N 个 I/O 密集型子调用的实际耗时(wall time)从大约 N × T 降低到约 T,具体取决于配置的并发上限。除了使用多个提示词调用 rlm_query_batched 之外,无需更改任何代码。