RLM-Graph is an evolution of the Recursive Language Model (RLM) paradigm.
Original RLM, developed at MIT, allows LLMs to effectively manage potentially infinite contexts by using an agentic system that iteratively extracts relevant information from a vast external corpus. RLM-Graph takes this concept a step further: it replaces unstructured external text with a deterministic Knowledge Graph, enabling the "curious agent" to explore, reason, and recurse with topological precision.
Based on the official RLM implementation: alexzhang13/rlm.
Traditional RLM enables models to reason over large contexts by exploring them adaptively. However, exploring raw text is like "exploring in a fog"—relationships are implicit and navigation is heuristic.
RLM-Graph provides the map.
| Feature | RLM (Baseline) | RLM-Graph |
|---|---|---|
| Environment | Unstructured text | Structured Knowledge Graph |
| Exploration | Semantic/Keyword search | Topological Navigation (Neighbors, Hops) |
| Grounding | Text Chunks | Typed Nodes & Explicit Edges |
| Efficiency | High Drift / High Hallucination | High Precision / Low Hallucination |
For a deep dive into our philosophy, see Why We Move to RLM-Graph.
- Graphification Pipeline: Automatically transforms Markdown documents into a structured graph (Docs, Sections, Chunks, Entities).
- Hybrid Search: Combines semantic vector search (via
sentence-transformers) with topological graph traversal. - Recursive Reasoning: Native support for nested RLM calls scoped to specific subgraphs.
- Persistent Knowledge: Built on Kùzu, an ultra-fast embedded graph database.
- Audit-Ready: Full tracing of exploration paths and evidence accumulation.
# Clone the repository
git clone https://github.com/omardimarzio/RLM-Graph.git
cd RLM-Graph
# Install dependencies
pip install -r requirements.txtTransform your documentation into a Knowledge Graph:
python -m rlm_graph.ingest --dir ./your_docs_folderAsk questions to the RLM-Graph agent:
# Set your API key
export OPENAI_API_KEY=your_key_here
# Run the demo
python examples/demo_graph_agent.pyWe compared RLM-Graph against the baseline RLM on complex technical queries:
- Accuracy: RLM-Graph resolved 100% of queries that the baseline either hallucinated on or failed to resolve.
- Reliability: Evidence is cited via explicit Graph IDs, ensuring that every claim is anchored to a specific chunk of the corpus.
Distributed under the MIT License. See LICENSE for more information.
- RLM Paper: Recursive Language Models
- Original Code: alexzhang13/rlm