# Recursive Language Model (RLM)
Research topic for future trials when Z840 P40 hardware is live.
## Overview
Paper: [arXiv:2512.24601](https://arxiv.org/abs/2512.24601) — “Recursive Language Models” by Alex Zhang, Tim Kraska, Omar Khattab (MIT CSAIL)
Key insight: Instead of forcing a model to process massive context in one call, give it a REPL environment where context is a variable. The model recursively calls itself on chunks of that context.
## Why It Matters
1. Context rot — Performance degrades as context window fills. RLMs avoid this by never giving full context to one call. 2. Unbounded context — Context stored externally, query millions of tokens without hitting limits. 3. Recursive delegation — Model writes code that calls `rlm(chunk)` on subsets, divide-and-conquer strategy.
## How It Works
``` User query + 1M token context
↓
Root RLM gets query + REPL with context as variable
↓
Root RLM writes Python code:
↓ Sub-RLMs process chunks, return results
↓
Root RLM synthesizes final answer ```
## vs Chain of Thought (CoT)
- CoT: Model “thinks” in one long output (still fits in context) - RLM: Model *delegates* to sub-calls, each with their own context window
## vs Hermes Today
- Hermes: `delegate_task` spawns sub-agents with full context → they run independently, return summary - RLM: Sub-calls operate on *chunks* of the parent's context, can be nested recursively
## Performance Claims
- RLM-Qwen3-8B (post-trained 8B model) outperforms vanilla Qwen3-8B by 28.3% - Approaches GPT-5 on long-context tasks - Uses much less compute because each call sees small context
## Implementation
Prime Intellect's [Prime Agent](https://github.com/PrimeIntellect-ai/prime-agent) is a production implementation: - Persistent IPython kernel as REPL - Sub-agents as recursive calls - “Continual harness” — agent can CRUD its own prompts/skills/memory from trajectory
## Future Trials
Trigger: When Z840 P40s are live (3× Tesla P40, 24GB VRAM total)
What to test: 1. Deploy Prime Agent locally on Z840 2. Compare RLM vs Hermes delegation on long-context tasks 3. Evaluate if recursive chunking reduces context rot in practice
Resources needed: - 3× Tesla P40 in Z840 (planned, see z840) - Torch ≤ 2.7.x for Pascal GPU support (P40 is sm_61) - Prime Agent installed via `curl -fsSL https://app.primeintellect.ai/prime-agent/install.sh | sh`
References: - Paper: https://arxiv.org/abs/2512.24601 - Project page: https://alexzhang13.github.io/blog/2025/rlm/ - Code: https://github.com/alexzhang13/rlm - Prime Agent: https://github.com/PrimeIntellect-ai/prime-agent