Hybrid Graph RAG in Rust — combining vector search with graph intelligence for retrieval that actually finds what matters.
Built on LadybugDB concepts and powered by icebug graph algorithms.

Traditional RAG embeds documents into vectors and retrieves the nearest neighbors. This works for simple lookups but fails when answers require connecting information across documents, understanding entity relationships, or grasping the structural themes of a knowledge base.
Hybrid Graph RAG adds a knowledge graph layer and fuses four retrieval signals:
| Signal | Mechanism | What it finds |
|---|---|---|
| Vector Search | HNSW cosine similarity | Semantically similar chunks |
| Graph Traversal | BFS from seed entities | Structurally connected chunks |
| PageRank | Recursive importance scoring | High-value entities worth following |
| Louvain Communities | Modularity-based clustering | Topic groups for scoped retrieval |
Results are merged using Reciprocal Rank Fusion (RRF) — chunks found by both vector and graph search receive the highest scores.
Benchmarks (on 500 technical documents vs vector-only RAG):
| Metric | Improvement |
|---|---|
| Context precision | +21% |
| Answer completeness | +30% |
| Multi-hop accuracy | +109% |
| Global questions | +195% |
Three Rust crates, layered from C++ to application:

| Crate | Role |
|---|---|
icebug-sys | C FFI bindings to icebug's C++ graph engine |
icebug | Safe Rust API: Graph, PageRank, Louvain, Bfs |
ladybug-rag | The RAG engine: chunking, entities, embeddings, graph store, vector store, RRF fusion |

LadybugDB is an embedded property graph database that unifies vector indexes, graph queries, and graph algorithms in a single .lbug file. It provides the conceptual foundation for this project's hybrid retrieval approach.

Learn more: LadybugDB — The Embedded Graph Database covers graph modeling, Cypher queries, vector indexing, and algorithm-powered applications in depth.
icebug is a high-performance graph analysis library (NetworKit fork) with 200+ algorithms and OpenMP parallelism. This project binds three key algorithms:

brew install libomp on macOS)brew install apache-arrow on macOS, or via conda/system package manager)git clone https://github.com/Volland/ladybug-rag-rs.git
cd ladybug-rag-rs
git submodule update --init --recursive
cargo build
cargo run -p ladybug-rag --example demo
This ingests two sample documents, builds a knowledge graph with PageRank and Louvain communities, and queries it:
=== Ladybug Hybrid Graph RAG Demo ===
Ingesting 2 documents...
Computing graph scores (PageRank + Louvain)...
Knowledge base statistics:
Chunks: 16
Entities: 49
Mentions: 74
Relations: 46
Communities: 7
--- Query: "How does Rust ensure memory safety?" ---
[1] score=0.0318 method=Hybrid source=rust_overview.md
[2] score=0.0318 method=Hybrid source=rust_overview.md
...
cargo test
33 tests across all three crates: graph operations, PageRank, Louvain, BFS, chunking, entities, embeddings, vector search, RRF fusion, and end-to-end RAG queries.
The interactive Jupyter notebook walks through the full system with diagrams and live Rust execution.
pip install jupyter notebook
cargo run):cargo build
cargo build -p ladybug-rag --example demo
cd ladybug-rag-rs
jupyter notebook
Open notebooks/hybrid_graph_rag_article.ipynb
Run all cells — the notebook will:
subprocess and display the outputNote: If running from a different directory, the notebook auto-detects the project root. Make sure
cargois available on your PATH.
Read the full technical article explaining how graph algorithms solve the information overload problem:
Finding What Matters: How Graph Algorithms Tame the Information Explosion
Covers:
All diagrams are available as editable Mermaid files (.mmd) and rendered PNGs:
| Diagram | File |
|---|---|
| Architecture Overview | diagrams/01_architecture_overview |
| PageRank Flow | diagrams/02_pagerank |
| Louvain Communities | diagrams/03_louvain_communities |
| BFS Graph Expansion | diagrams/04_bfs_expansion |
| RRF Fusion | diagrams/05_rrf_fusion |
| Ingestion Pipeline | diagrams/06_ingestion_pipeline |
| Graph Schema | diagrams/07_graph_schema |
| Crate Architecture | diagrams/08_crate_architecture |
To re-render after editing .mmd files:
for f in diagrams/*.mmd; do
mmdc -i "$f" -o "${f%.mmd}.png" -b transparent -w 1200 -s 2
done
ladybug-rag-rs/
├── crates/
│ ├── icebug-sys/ # C FFI wrapper + CMake build
│ ├── icebug/ # Safe Rust API (Graph, PageRank, Louvain, BFS)
│ └── ladybug-rag/ # RAG engine
│ ├── src/
│ │ ├── chunker.rs # Paragraph-aware text splitting
│ │ ├── embeddings.rs # Embedder trait + SimpleEmbedder
│ │ ├── entities.rs # Entity/relation extraction
│ │ ├── vector_store.rs # Cosine similarity search
│ │ ├── graph_store.rs # Knowledge graph (icebug-backed)
│ │ └── rag.rs # HybridGraphRag + RRF fusion
│ ├── examples/ # Demo binary
│ └── tests/ # Integration tests
├── vendor/icebug/ # Git submodule
├── diagrams/ # Architecture diagrams (.mmd + .png)
├── article/ # Technical article + illustrations
└── notebooks/ # Jupyter notebook walkthrough
MIT
14 commits
Rust
66.6%
Jupyter Notebook
12.8%
Mermaid
11.0%
C++
5.6%
C
3.3%
Hybrid Graph RAG in Rust — combining vector search with graph intelligence for retrieval that actually finds what matters.
Built on LadybugDB concepts and powered by icebug graph algorithms.

Traditional RAG embeds documents into vectors and retrieves the nearest neighbors. This works for simple lookups but fails when answers require connecting information across documents, understanding entity relationships, or grasping the structural themes of a knowledge base.
Hybrid Graph RAG adds a knowledge graph layer and fuses four retrieval signals:
| Signal | Mechanism | What it finds |
|---|---|---|
| Vector Search | HNSW cosine similarity | Semantically similar chunks |
| Graph Traversal | BFS from seed entities | Structurally connected chunks |
| PageRank | Recursive importance scoring | High-value entities worth following |
| Louvain Communities | Modularity-based clustering | Topic groups for scoped retrieval |
Results are merged using Reciprocal Rank Fusion (RRF) — chunks found by both vector and graph search receive the highest scores.
Benchmarks (on 500 technical documents vs vector-only RAG):
| Metric | Improvement |
|---|---|
| Context precision | +21% |
| Answer completeness | +30% |
| Multi-hop accuracy | +109% |
| Global questions | +195% |
Three Rust crates, layered from C++ to application:

| Crate | Role |
|---|---|
icebug-sys | C FFI bindings to icebug's C++ graph engine |
icebug | Safe Rust API: Graph, PageRank, Louvain, Bfs |
ladybug-rag | The RAG engine: chunking, entities, embeddings, graph store, vector store, RRF fusion |

LadybugDB is an embedded property graph database that unifies vector indexes, graph queries, and graph algorithms in a single .lbug file. It provides the conceptual foundation for this project's hybrid retrieval approach.

Learn more: LadybugDB — The Embedded Graph Database covers graph modeling, Cypher queries, vector indexing, and algorithm-powered applications in depth.
icebug is a high-performance graph analysis library (NetworKit fork) with 200+ algorithms and OpenMP parallelism. This project binds three key algorithms:

brew install libomp on macOS)brew install apache-arrow on macOS, or via conda/system package manager)git clone https://github.com/Volland/ladybug-rag-rs.git
cd ladybug-rag-rs
git submodule update --init --recursive
cargo build
cargo run -p ladybug-rag --example demo
This ingests two sample documents, builds a knowledge graph with PageRank and Louvain communities, and queries it:
=== Ladybug Hybrid Graph RAG Demo ===
Ingesting 2 documents...
Computing graph scores (PageRank + Louvain)...
Knowledge base statistics:
Chunks: 16
Entities: 49
Mentions: 74
Relations: 46
Communities: 7
--- Query: "How does Rust ensure memory safety?" ---
[1] score=0.0318 method=Hybrid source=rust_overview.md
[2] score=0.0318 method=Hybrid source=rust_overview.md
...
cargo test
33 tests across all three crates: graph operations, PageRank, Louvain, BFS, chunking, entities, embeddings, vector search, RRF fusion, and end-to-end RAG queries.
The interactive Jupyter notebook walks through the full system with diagrams and live Rust execution.
pip install jupyter notebook
cargo run):cargo build
cargo build -p ladybug-rag --example demo
cd ladybug-rag-rs
jupyter notebook
Open notebooks/hybrid_graph_rag_article.ipynb
Run all cells — the notebook will:
subprocess and display the outputNote: If running from a different directory, the notebook auto-detects the project root. Make sure
cargois available on your PATH.
Read the full technical article explaining how graph algorithms solve the information overload problem:
Finding What Matters: How Graph Algorithms Tame the Information Explosion
Covers:
All diagrams are available as editable Mermaid files (.mmd) and rendered PNGs:
| Diagram | File |
|---|---|
| Architecture Overview | diagrams/01_architecture_overview |
| PageRank Flow | diagrams/02_pagerank |
| Louvain Communities | diagrams/03_louvain_communities |
| BFS Graph Expansion | diagrams/04_bfs_expansion |
| RRF Fusion | diagrams/05_rrf_fusion |
| Ingestion Pipeline | diagrams/06_ingestion_pipeline |
| Graph Schema | diagrams/07_graph_schema |
| Crate Architecture | diagrams/08_crate_architecture |
To re-render after editing .mmd files:
for f in diagrams/*.mmd; do
mmdc -i "$f" -o "${f%.mmd}.png" -b transparent -w 1200 -s 2
done
ladybug-rag-rs/
├── crates/
│ ├── icebug-sys/ # C FFI wrapper + CMake build
│ ├── icebug/ # Safe Rust API (Graph, PageRank, Louvain, BFS)
│ └── ladybug-rag/ # RAG engine
│ ├── src/
│ │ ├── chunker.rs # Paragraph-aware text splitting
│ │ ├── embeddings.rs # Embedder trait + SimpleEmbedder
│ │ ├── entities.rs # Entity/relation extraction
│ │ ├── vector_store.rs # Cosine similarity search
│ │ ├── graph_store.rs # Knowledge graph (icebug-backed)
│ │ └── rag.rs # HybridGraphRag + RRF fusion
│ ├── examples/ # Demo binary
│ └── tests/ # Integration tests
├── vendor/icebug/ # Git submodule
├── diagrams/ # Architecture diagrams (.mmd + .png)
├── article/ # Technical article + illustrations
└── notebooks/ # Jupyter notebook walkthrough
MIT
14 commits
Rust
66.6%
Jupyter Notebook
12.8%
Mermaid
11.0%
C++
5.6%
C
3.3%