Skip to content

omardimarzio/RLM-Graph

Repository files navigation

RLM-Graph: Recursive Language Models over Knowledge Graphs

arXiv Python 3.9+ License: MIT

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.

🧠 Why RLM-Graph?

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.

🚀 Key Features

  • 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.

🛠️ Installation

# Clone the repository
git clone https://github.com/omardimarzio/RLM-Graph.git
cd RLM-Graph

# Install dependencies
pip install -r requirements.txt

📖 Getting Started

1. Ingest Documents

Transform your documentation into a Knowledge Graph:

python -m rlm_graph.ingest --dir ./your_docs_folder

2. Run the Agent

Ask 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.py

🧪 Benchmark Results

We 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.

⚖️ License

Distributed under the MIT License. See LICENSE for more information.

📚 References

About

RLM-Graph - a system based on Recursive Language Models but structured on a directed graph

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors