[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-72179":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":23,"hasPages":25,"topics":26,"createdAt":10,"pushedAt":10,"updatedAt":27,"readmeContent":28,"aiSummary":29,"trendingCount":16,"starSnapshotCount":16,"syncStatus":30,"lastSyncTime":31,"discoverSource":32},72179,"rlm","alexzhang13\u002Frlm","alexzhang13","General plug-and-play inference library for Recursive Language Models (RLMs), supporting various sandboxes.","https:\u002F\u002Farxiv.org\u002Fabs\u002F2512.24601v1",null,"Python",4445,778,45,34,0,14,55,231,42,30.67,"MIT License",false,"main",true,[],"2026-06-12 02:02:59","\n---\n\n\u003Ch1 align=\"center\" style=\"font-size:2.8em\">\n\u003Cspan>Recursive Language Models (\u003Cspan style=\"color:orange\">RLM\u003C\u002Fspan>s)\u003C\u002Fspan>\n\u003C\u002Fh1>\n\n\u003Cp align=\"center\" style=\"font-size:1.3em\">\n  \u003Ca href=\"https:\u002F\u002Farxiv.org\u002Fabs\u002F2512.24601\">Full Paper\u003C\u002Fa> •\n  \u003Ca href=\"https:\u002F\u002Falexzhang13.github.io\u002Fblog\u002F2025\u002Frlm\u002F\">Blogpost\u003C\u002Fa> •\n  \u003Ca href=\"https:\u002F\u002Falexzhang13.github.io\u002Frlm\u002F\">Documentation\u003C\u002Fa> •\n  \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Falexzhang13\u002Frlm-minimal\">RLM Minimal\u003C\u002Fa>\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n  \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Falexzhang13\u002Frlm\u002Factions\u002Fworkflows\u002Fstyle.yml\">\n    \u003Cimg src=\"https:\u002F\u002Fgithub.com\u002Falexzhang13\u002Frlm\u002Factions\u002Fworkflows\u002Fstyle.yml\u002Fbadge.svg\" alt=\"Style\" \u002F>\n  \u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Falexzhang13\u002Frlm\u002Factions\u002Fworkflows\u002Ftest.yml\">\n    \u003Cimg src=\"https:\u002F\u002Fgithub.com\u002Falexzhang13\u002Frlm\u002Factions\u002Fworkflows\u002Ftest.yml\u002Fbadge.svg\" alt=\"Test\" \u002F>\n  \u003C\u002Fa>\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n  \u003Ca href=\"https:\u002F\u002Farxiv.org\u002Fabs\u002F2512.24601\">\n    \u003Cimg src=\"media\u002Fpaper_preview.png\" alt=\"Paper Preview\" width=\"300\"\u002F>\n  \u003C\u002Fa>\n\u003C\u002Fp>\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. 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\nThis repository provides an extensible inference engine for using RLMs around standard API-based and local LLMs. The initial experiments and idea were proposed in a [blogpost](https:\u002F\u002Falexzhang13.github.io\u002Fblog\u002F2025\u002Frlm\u002F) in 2025, with expanded results in an [arXiv preprint](https:\u002F\u002Farxiv.org\u002Fabs\u002F2512.24601).\n\n> [!NOTE]\n> This repository contains inference code for RLMs with support for various sandbox environments. Open-source contributions are welcome. This repository is maintained by the authors of the paper from the MIT OASYS lab.\n\n## Quick Setup\n> [!NOTE]\n> `rlms` requires **Python 3.11 or later**.\n\nYou can try out RLMs quickly by installing from PyPi:\n```bash\npip install rlms\n```\n\nThe default RLM client uses a REPL environment that runs on the host process through Python `exec` calls. It uses the same virtual environment as the host process (i.e. it will have access to the same dependencies), but with some limitations in its available global modules. As an example, we can call RLM completions using GPT-5-nano:\n```python\nfrom rlm import RLM\n\nrlm = RLM(\n    backend=\"openai\",\n    backend_kwargs={\"model_name\": \"gpt-5-nano\"},\n    verbose=True,  # For printing to console with rich, disabled by default.\n)\n\nprint(rlm.completion(\"Print me the first 100 powers of two, each on a newline.\").response)\n```\n\n\u003Cdetails>\n\u003Csummary>\u003Cb>Manual Setup\u003C\u002Fb>\u003C\u002Fsummary>\n\nSet up the dependencies with `uv` (or your virtual environment of choice):\n```bash\ncurl -LsSf https:\u002F\u002Fastral.sh\u002Fuv\u002Finstall.sh | sh\nuv init && uv venv --python 3.12  # change version as needed\nuv pip install -e .\n```\n\nThis project includes a `Makefile` to simplify common tasks.\n\n- `make install`: Install base dependencies.\n- `make check`: Run linter, formatter, and tests.\n\nTo run a quick test, the following will run an RLM query with the OpenAI client using your environment variable `OPENAI_API_KEY` (feel free to change this). This will generate console output as well as a log which you can use with the visualizer to explore the trajectories.\n```bash\nmake quickstart\n```\n\n\u003C\u002Fdetails>\n\n## REPL Environments\nWe support two types of REPL environments -- isolated, and non-isolated. Non-isolated environments (default) run code execution on the same machine as the RLM (e.g. through `exec`), which is pretty reasonable for some local low-risk tasks, like simple benchmarking, but can be problematic if the prompts or tool calls can interact with malicious users. Fully isolated environments use cloud-based sandboxes (e.g. Prime Sandboxes, [Modal Sandboxes](https:\u002F\u002Fmodal.com\u002Fdocs\u002Fguide\u002Fsandboxes)) to run code generated by the RLM, ensuring complete isolation from the host process. Environments can be added, but we natively support the following: `local` (default), `ipython`, `docker`, `modal`, `prime`, `daytona`, `e2b`.\n\n```python\nrlm = RLM(\n    environment=\"...\", # \"local\", \"ipython\", \"docker\", \"modal\", \"prime\", \"daytona\", \"e2b\"\n    environment_kwargs={...},\n)\n```\n\n### Local Environments\nThe default `local` environment `LocalREPL` runs in the same process as the RLM itself, with specified global and local namespaces for minimal security. Using this REPL is generally safe, but should not be used for production settings. It also shares the same virtual environment (e.g. Conda or uv) as the host process.\n\n#### IPython (*requires `pip install 'rlms[ipython]'`*)\n`IPythonREPL` runs cells inside a real IPython session — either in-process (default) or in a separate `ipykernel` subprocess. Subprocess mode adds hard `cell_timeout` enforcement and full namespace isolation from the RLM host. See the [IPythonREPL docs](https:\u002F\u002Falexzhang13.github.io\u002Frlm\u002Fenvironments\u002Fipython) for details.\n\n#### Docker \u003Cimg src=\"https:\u002F\u002Fgithub.com\u002Fdocker.png\" alt=\"Docker\" height=\"20\" style=\"vertical-align: middle;\"\u002F> (*requires [Docker installed](https:\u002F\u002Fdocs.docker.com\u002Fdesktop\u002Fsetup\u002Finstall\u002F)*)\nWe also support a Docker-based environment called `DockerREPL` that launches the REPL environment as a Docker image. By default, we use the `python:3.11-slim` image, but the user can specify custom images as well.\n\n### Isolated Environments\nWe support several different REPL environments that run on separate, cloud-based machines. Whenever a recursive sub-call is made in these instances, it is requested from the host process.\n\n#### Modal Sandboxes \u003Cimg src=\"https:\u002F\u002Fgithub.com\u002Fmodal-labs.png\" alt=\"Modal\" height=\"20\" style=\"vertical-align: middle;\"\u002F>\nTo use [Modal Sandboxes](https:\u002F\u002Fmodal.com\u002Fdocs\u002Fguide\u002Fsandboxes) as the REPL environment, you need to install and authenticate your Modal account.\n```bash\nuv add modal  # add modal library\nmodal setup   # authenticate account\n```\n\n#### Prime Intellect Sandboxes \u003Cimg src=\"https:\u002F\u002Fgithub.com\u002FPrimeIntellect-ai.png\" alt=\"Prime Intellect\" height=\"20\" style=\"vertical-align: middle;\"\u002F>\n> [!NOTE]\n> **Prime Intellect Sandboxes** are currently a beta feature. See the [documentation](https:\u002F\u002Fdocs.primeintellect.ai\u002Fsandboxes\u002Foverview) for more information. We noticed slow runtimes when using these sandboxes, which is currently an open issue.\n\n\nTo use [Prime Sandboxes](https:\u002F\u002Fdocs.primeintellect.ai\u002Fsandboxes\u002Fsdk), install the SDK and set your API key:\n```bash\nuv pip install -e \".[prime]\"\nexport PRIME_API_KEY=...\n```\n\n\n### Model Providers\nWe currently support most major clients (OpenAI, Anthropic), as well as the router platforms (OpenRouter, Portkey). For local models, we recommend using vLLM (which interfaces with the [OpenAI client](https:\u002F\u002Fgithub.com\u002Falexzhang13\u002Frlm\u002Fblob\u002Fmain\u002Frlm\u002Fclients\u002Fopenai.py)). To view or add support for more clients, start by looking at [`rlm\u002Fclients\u002F`](https:\u002F\u002Fgithub.com\u002Falexzhang13\u002Frlm\u002Ftree\u002Fmain\u002Frlm\u002Fclients).\n\n## Relevant Reading\n* **[Dec '25]** [Recursive Language Models arXiv](https:\u002F\u002Farxiv.org\u002Fabs\u002F2512.24601)\n* **[Oct '25]** [Recursive Language Models Blogpost](https:\u002F\u002Falexzhang13.github.io\u002Fblog\u002F2025\u002Frlm\u002F)\n\nIf you use this code or repository in your research, please cite:\n\n```bibtex\n@misc{zhang2026recursivelanguagemodels,\n      title={Recursive Language Models},\n      author={Alex L. Zhang and Tim Kraska and Omar Khattab},\n      year={2026},\n      eprint={2512.24601},\n      archivePrefix={arXiv},\n      primaryClass={cs.AI},\n      url={https:\u002F\u002Farxiv.org\u002Fabs\u002F2512.24601},\n}\n```\n\n## Optional: Trajectory metadata and logging\n`RLMChatCompletion` has an optional `metadata` field (default `None`) that holds the full trajectory (run config + all iterations and sub-calls) so you can reconstruct the run. Pass an `RLMLogger` to capture it:\n\n- **In-memory only** (trajectory on `completion.metadata`): `logger=RLMLogger()` (no `log_dir`).\n- **Also save to disk** (JSONL for the visualizer): `logger=RLMLogger(log_dir=\".\u002Flogs\")`.\n\n## Optional Debugging: Visualizing RLM Trajectories\nWe provide a simple visualizer to inspect code, sub-LM, and root-LM calls. Use `RLMLogger(log_dir=\".\u002Flogs\")` so each completion writes a `.jsonl` file:\n```python\nfrom rlm.logger import RLMLogger\nfrom rlm import RLM\n\nlogger = RLMLogger(log_dir=\".\u002Flogs\")\nrlm = RLM(..., logger=logger)\n```\n\nTo run the visualizer locally, we use Node.js and shadcn\u002Fui:\n```\ncd visualizer\u002F\nnpm run dev        # default localhost:3001\n```\n\nYou'll have the option to select saved `.jsonl` files \n\u003Cp align=\"center\">\n  \u003Cimg src=\"media\u002Fvisualizer.png\" alt=\"RLM Visualizer Example\" width=\"800\"\u002F>\n\u003C\u002Fp>\n","Recursive Language Models (RLMs) 是一个通用的即插即用推理库，支持多种沙箱环境。该项目的核心功能是通过递归调用自身来处理近乎无限长度的上下文，从而让语言模型能够以编程方式检查、分解和处理输入。技术特点包括使用 Python 3.11 或更高版本，提供标准 API 和本地 LLMs 的扩展推理引擎。适用于需要处理长文本或复杂任务的场景，如自然语言处理中的多轮对话系统、文档摘要生成等。项目开源并欢迎贡献，由 MIT OASYS 实验室维护。",2,"2026-06-11 03:40:43","high_star"]