Skip to content
kushwahaamar-devPublic

About

I wanted to try out the RLM paper

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

Recursive Language Models (RLM) Implementation

This project implements the Recursive Language Models (RLMs) paper for processing arbitrarily long contexts with language models.

Paper Reference

Recursive Language Models
Alex L. Zhang, Tim Kraska, Omar Khattab
arXiv:2512.24601
https://arxiv.org/abs/2512.24601

Quick Start

1. Set Up API Key

Create a .env file in the project root:

cp .env.example .env

Edit .env and add your Gemini API key:

GEMINI_API_KEY=your-api-key-here

Get your key at https://aistudio.google.com/apikey

2. Activate Environment

source venv_rlm/bin/activate

3. Run the Demo Notebook

jupyter notebook RLM_demo.ipynb

Or use JupyterLab:

jupyter lab

Select the "Python (venv_rlm)" kernel when running the notebook.

Project Structure

rlm-implementation/
├── RLM_paper.pdf          # The original RLM paper
├── RLM_demo.ipynb         # Demo Jupyter notebook
├── README.md              # This file
├── .env.example           # Template for API keys
├── .env                   # Your API keys (create this)
├── data/
│   └── long_context.txt   # Test document for RLM queries
├── logs/                  # RLM trajectory logs
├── rlm/                   # Official RLM repository (cloned)
│   ├── examples/          # Example scripts
│   ├── rlm/               # Core RLM package
│   ├── visualizer/        # Trajectory visualization tool
│   └── ...
└── venv_rlm/              # Python virtual environment

Models and Datasets

Model

  • Gemini 2.5 Flash (default) via Google AI API
  • Can be changed to other Gemini models in the notebook

Dataset

  • data/long_context.txt - A synthetic narrative document about "Dataville" (~2500 words)
  • Contains embedded facts, questions, and numerical data for Q&A testing

RLM Environment Options

The RLM supports multiple environments:

Environment Description Use Case
local Python exec in host process Development, testing
docker Isolated Docker container Safety-conscious usage
modal Modal cloud sandboxes Production, isolation
prime Prime Intellect sandboxes Production, isolation

Visualizing RLM Trajectories

After running queries, log files are saved to ./logs/. To visualize:

cd rlm/visualizer
npm install
npm run dev

Access the visualizer at http://localhost:3001

Troubleshooting

Import Error

If you see "cannot import name 'RLM' from 'rlm'", ensure you're using the correct kernel:

  • Select "Python (venv_rlm)" in Jupyter

Missing API Key

The notebook will warn you if GEMINI_API_KEY is not set. Create a .env file with your key.

Rate Limits

For large contexts, you may hit OpenAI rate limits. Consider using gpt-4o-mini for testing.

License

The RLM library is under MIT License. See rlm/LICENSE for details.

About

I wanted to try out the RLM paper

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages