XR

xiaoconstantine/rlm-go

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

21 stars 质量 54 趋势 14MIT

递归语言模型(RLM)的实现——针对任意长上下文的推理时间尺度

概览

递归语言模型(RLM)的Go实现——一种推理时间缩放策略,使LLM能够处理任意长上下文,将提示符视为可编程检查和递归处理的外部对象。 RLM-go 提供了一个 Go REPL 环境,LLM 生成的代码可以: - 访问以变量形式存储的上下文 - 通过 Query() 和 QueryBatched() 进行递归子 LLM 调用 - 使用标准 Go 操作进行文本处理 - 使用 FINAL() 或 FINAL_VAR() 进行信号补全 与使用 socket IPC 的 Python RLM 不同,rlm-go 通过 Yaegi 使用一个 Go 解释器。这消除了以下问题:- 套接字服务器开销 - 序列化/反序列化 - 进程边界 结果是每个子LLM调用的延迟比套接字IPC低约100倍。 - 开始1。

概述(AI 翻译)

递归语言模型(RLM)的Go实现——一种推理时间缩放策略,使LLM能够处理任意长上下文,将提示符视为可编程检查和递归处理的外部对象。

概述

RLM-go 提供了一个 Go REPL 环境,LLM 生成的代码可以:

  • 访问以变量形式存储的上下文
  • 通过Query()和[[T1]进行递归子LLM调用]
  • 使用标准围棋操作进行文本处理
  • 信号完成时使用 FINAL() 或 [[T3] ]

关键设计决策

与使用 socket IPC 的 Python RLM 不同,rlm-go 采用了通过 Yaegi - Go 解释器的直接函数注入。这消除了:

  • 套接字服务器开销
  • 序列化/反序列化
  • 流程边界

结果是每个子LLM调用的延迟比套接字IPC低约100倍。

要求

  • Go 1.23或更高版本(用于源代码构建)
  • LLM API 密钥:
  • ANTHROPIC_API_KEY 用于 Claude 模型(默认)
  • GEMINI_API_KEY 针对 Gemini 型号
  • OPENAI_API_KEY 用于 OpenAI 模型
  • (可选)Podman 或 Docker 用于隔离沙箱执行

支持的型号

|提供者 |模型 |环境变量 |

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

rlm-go

A Go implementation of Recursive Language Models (RLM) - an inference-time scaling strategy that enables LLMs to handle arbitrarily long contexts by treating prompts as external objects that can be programmatically examined and recursively processed.

Overview

RLM-go provides a Go REPL environment where LLM-generated code can:

  • Access context stored as a variable
  • Make recursive sub-LLM calls via Query() and QueryBatched()
  • Use standard Go operations for text processing
  • Signal completion with FINAL() or FINAL_VAR()

Key Design Decisions

Unlike the Python RLM which uses socket IPC, rlm-go uses direct function injection via Yaegi - a Go interpreter. This eliminates:

  • Socket server overhead
  • Serialization/deserialization
  • Process boundaries

The result is ~100x less latency per sub-LLM call compared to socket IPC.

Requirements

  • Go 1.23 or later (for building from source)
  • An LLM API key:
    • ANTHROPIC_API_KEY for Claude models (default)
    • GEMINI_API_KEY for Gemini models
    • OPENAI_API_KEY for OpenAI models
  • (Optional) Podman or Docker for isolated sandbox execution

Supported Models

Provider Models Env Variable
Anthropic claude-sonnet-4-20250514, claude-opus-4-20250514, etc. ANTHROPIC_API_KEY
Google gemini-3-flash-preview, gemini-3-pro-preview GEMINI_API_KEY
OpenAI gpt-5, gpt-5-mini OPENAI_API_KEY

The provider is auto-detected based on model name. Anthropic is the default.

Installation

# Download and install the latest release
curl -fsSL https://raw.githubusercontent.com/XiaoConstantine/rlm-go/main/install.sh | bash

This installs the rlm binary to ~/.local/bin/rlm.

Go Install

go install github.com/XiaoConstantine/rlm-go/cmd/rlm@latest

From Source

git clone https://github.com/XiaoConstantine/rlm-go.git
cd rlm-go
go build -o rlm ./cmd/rlm

As a Library

go get github.com/XiaoConstantine/rlm-go

Claude Code Integration

RLM includes a skill for Claude Code that provides documentation and usage guidance for large context processing.

Install the Skill

rlm install-claude-code

This creates a skill at ~/.claude/skills/rlm/SKILL.md that teaches Claude Code:

  • When to use RLM (contexts >50KB, token efficiency needed)
  • Command usage and options
在 GitHub 查看完整 README

推荐工具

换一个关键词,或者移除筛选条件。

安装

npx skillfish add xiaoconstantine/rlm-go
新手?先看 mcpskill.org 教程 →