Skip to content

Commit 7bf3ec6

Browse files
zc277584121claude
andcommitted
docs: add design philosophy, use cases, and enrich documentation
- Add design philosophy: no graph DB, single-pass LLM reranking, knowledge-intensive domain focus - Add use cases page with domain examples (legal, finance, medical, literature, academic) - Update README features to highlight key differentiators - Enrich getting-started with collection_prefix and milvus_db usage - Add comparison table with other RAG approaches Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6959021 commit 7bf3ec6

6 files changed

Lines changed: 237 additions & 26 deletions

File tree

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Vector Graph RAG
22

3-
🔗 A Graph RAG implementation using pure vector search with Milvus.
3+
Graph RAG with pure vector search — no graph database needed, single-pass LLM reranking, optimized for knowledge-intensive domains.
44

55
## ✨ Features
66

7-
- **🚀 No Graph Database Required** - Pure vector search approach, no need for Neo4j or other graph databases
8-
- **📦 Zero Configuration** - Uses Milvus Lite by default, works out of the box with a single file
9-
- **🎯 High Accuracy** - LLM-based reranking for precise relation filtering
10-
- **🔍 Multi-hop Reasoning** - Subgraph expansion enables complex multi-hop question answering
11-
- **📊 State-of-the-Art Performance** - Outperforms HippoRAG on multi-hop QA benchmarks (87.8% avg Recall@5)
12-
- **🛠️ Simple API** - Just 3 lines of code to get started
7+
- **No Graph Database Required** - Pure vector search with Milvus, no Neo4j or other graph databases needed
8+
- **Single-Pass LLM Reranking** - One LLM call to rerank, no iterative agent loops (unlike IRCoT or multi-step reflection)
9+
- **Knowledge-Intensive Friendly** - Optimized for domains with dense factual content: legal, finance, medical, literature, etc.
10+
- **Zero Configuration** - Uses Milvus Lite by default, works out of the box with a single file
11+
- **Multi-hop Reasoning** - Subgraph expansion enables complex multi-hop question answering
12+
- **State-of-the-Art Performance** - 87.8% avg Recall@5 on multi-hop QA benchmarks, outperforming HippoRAG
1313

1414
## 📦 Installation
1515

docs/getting-started.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,40 @@ print(result.answer)
3333
!!! note
3434
Set the `OPENAI_API_KEY` environment variable before running.
3535

36-
## Custom Configuration
36+
## Configuration
37+
38+
### Basic
3739

3840
```python
3941
rag = VectorGraphRAG(
40-
milvus_uri="./my_data.db",
42+
milvus_uri="./my_data.db", # local file (Milvus Lite)
4143
llm_model="gpt-4o",
4244
embedding_model="text-embedding-3-large",
4345
)
4446
```
4547

48+
### With Remote Milvus
49+
50+
```python
51+
rag = VectorGraphRAG(
52+
milvus_uri="http://localhost:19530",
53+
milvus_db="my_database", # optional: specify database
54+
collection_prefix="my_project", # optional: isolate collections
55+
)
56+
```
57+
58+
Collections will be named `my_project_vgrag_entities`, `my_project_vgrag_relations`, `my_project_vgrag_passages`.
59+
60+
### Multiple Knowledge Bases
61+
62+
Use `collection_prefix` to maintain separate graphs in the same Milvus instance:
63+
64+
```python
65+
# Different documents → different prefixes
66+
legal_rag = VectorGraphRAG(milvus_uri="./data.db", collection_prefix="legal")
67+
finance_rag = VectorGraphRAG(milvus_uri="./data.db", collection_prefix="finance")
68+
```
69+
4670
## With Pre-extracted Triplets
4771

4872
Skip LLM extraction if you already have knowledge graph triplets:
@@ -61,7 +85,7 @@ rag.add_documents_with_triplets([
6185

6286
## Import from URLs and Files
6387

64-
Import web pages, PDFs, and other documents:
88+
Import web pages, PDFs, and other documents with automatic chunking:
6589

6690
```bash
6791
pip install "vector-graph-rag[loaders]"

docs/how-it-works.md

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,46 @@
11
# How It Works
22

3-
## Overview
3+
## Design Philosophy
44

5-
Vector Graph RAG builds a knowledge graph stored entirely in a vector database (Milvus). It uses vector similarity search instead of graph traversal to find relevant entities and relations, eliminating the need for a separate graph database.
5+
Vector Graph RAG is built on three key principles:
66

7-
## Indexing Pipeline
7+
### 1. No Graph Database
8+
9+
Traditional Graph RAG systems store knowledge in a graph database (Neo4j, ArangoDB, etc.) and use graph traversal queries (Cypher, Gremlin) to retrieve relevant subgraphs. This adds operational complexity: another database to deploy, a query language to learn, schema to maintain.
10+
11+
We store the entire knowledge graph — entities, relations, and passages — as vectors in Milvus. Retrieval becomes vector similarity search, which is simple, scalable, and requires no additional infrastructure.
12+
13+
### 2. Single-Pass LLM Reranking
14+
15+
Many RAG systems use iterative, agentic retrieval — the LLM decides what to retrieve next, reflects on results, and repeats. For example:
16+
17+
- **IRCoT** (Interleaving Retrieval with Chain-of-Thought) alternates between retrieval and reasoning over multiple rounds
18+
- **Self-RAG** uses the LLM to critique and re-retrieve documents
19+
- **Agentic RAG** gives the LLM tools to search iteratively
20+
21+
These approaches are powerful but expensive — each iteration costs an LLM call, adding latency and cost.
22+
23+
Vector Graph RAG uses a **single LLM reranking pass**. After vector search and subgraph expansion produce candidate relations, the LLM scores them once. This is sufficient because the vector search + subgraph expansion already provides high-quality candidates, and a single reranking step can effectively filter the best results.
24+
25+
### 3. Knowledge-Intensive Domains
26+
27+
Vector Graph RAG is especially effective for **knowledge-intensive content** — documents where dense factual relationships are the core value:
28+
29+
| Domain | Why Graph RAG Helps |
30+
|--------|-------------------|
31+
| **Legal** | Statutes reference other statutes, precedents cite precedents — graph captures these cross-references |
32+
| **Finance** | Company relationships, ownership chains, transaction flows form natural graphs |
33+
| **Medical** | Drug interactions, symptom-disease-treatment pathways are inherently relational |
34+
| **Literature** | Character relationships, plot connections, thematic links across chapters |
35+
| **Academic** | Citation networks, concept dependencies, methodology chains |
36+
37+
In these domains, naive RAG often fails because the answer requires connecting facts across multiple documents. The knowledge graph captures these connections explicitly.
38+
39+
---
40+
41+
## Architecture
42+
43+
### Indexing Pipeline
844

945
```mermaid
1046
flowchart LR
@@ -18,7 +54,7 @@ flowchart LR
1854
2. **Entity & Relation Storage** — Entities and relations are stored as vectors in Milvus collections.
1955
3. **Embedding** — All text is embedded for vector similarity search.
2056

21-
## Query Pipeline
57+
### Query Pipeline
2258

2359
```mermaid
2460
flowchart LR
@@ -32,7 +68,7 @@ flowchart LR
3268
1. **Entity Extraction** — Extract key entities from the user's question.
3369
2. **Vector Search** — Find similar entities and relations in Milvus.
3470
3. **Subgraph Expansion** — Collect candidate relations by expanding around matched entities.
35-
4. **LLM Reranking** — Use an LLM to score and filter the most relevant relations.
71+
4. **LLM Reranking** — Use an LLM to score and filter the most relevant relations (single pass).
3672
5. **Answer Generation** — Generate the final answer from the selected context.
3773

3874
## Worked Example
@@ -57,13 +93,23 @@ flowchart TD
5793
VS --> SE["Subgraph expansion → candidate relations"]
5894
SE --> R1["(Einstein, developed, theory of relativity)"]
5995
SE --> R2["(Einstein, worked at, Princeton)"]
60-
R1 --> LLM["LLM reranking"]
96+
R1 --> LLM["LLM reranking (single pass)"]
6197
R2 --> LLM
62-
LLM --> A["Einstein developed the theory of relativity."]
98+
LLM --> A["Einstein developed the theory of relativity."]
6399
```
64100

65101
1. Extract entity: `Einstein`
66102
2. Vector search finds similar entities and relations
67103
3. Subgraph expansion collects candidate relations
68-
4. **LLM reranking** selects `(Einstein, developed, theory of relativity)`
104+
4. **LLM reranking** selects `(Einstein, developed, theory of relativity)` — one call, no iteration
69105
5. Generate answer: *"Einstein developed the theory of relativity."*
106+
107+
## Comparison with Other Approaches
108+
109+
| Approach | Graph DB | LLM Calls per Query | Iterative | Complexity |
110+
|----------|----------|---------------------|-----------|------------|
111+
| **Naive RAG** | No | 1 (generation) | No | Low |
112+
| **IRCoT** | No | Multiple (retrieve + reason loops) | Yes | High |
113+
| **HippoRAG** | No | 1-2 | No | Medium |
114+
| **Microsoft GraphRAG** | Yes (Neo4j) | Multiple | Yes | High |
115+
| **Vector Graph RAG** | **No** | **2** (rerank + generation) | **No** | **Low** |

docs/index.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
# Vector Graph RAG
22

3-
A Graph RAG implementation using pure vector search with [Milvus](https://milvus.io/).
3+
Graph RAG with pure vector search — no graph database needed, single-pass LLM reranking, optimized for knowledge-intensive domains.
4+
5+
## Why Vector Graph RAG?
6+
7+
Most Graph RAG systems require a dedicated graph database (Neo4j, etc.) and complex multi-step retrieval with iterative LLM calls. Vector Graph RAG takes a fundamentally different approach:
8+
9+
- **No graph database** — The entire knowledge graph lives in Milvus as vectors. No extra infrastructure, no schema management, no graph query language.
10+
- **Single-pass reranking** — Unlike agentic approaches (IRCoT, multi-step reflection), we call the LLM just once to rerank candidate relations. This is simpler, faster, and cheaper.
11+
- **Knowledge-intensive friendly** — Designed for domains where dense factual knowledge matters: legal documents, financial reports, medical literature, novels, and more.
412

513
## Features
614

7-
- **No Graph Database Required** — Pure vector search approach, no need for Neo4j or other graph databases
8-
- **Zero Configuration** — Uses Milvus Lite by default, works out of the box with a single file
9-
- **High Accuracy** — LLM-based reranking for precise relation filtering
10-
- **Multi-hop Reasoning** — Subgraph expansion enables complex multi-hop question answering
11-
- **State-of-the-Art Performance** — Outperforms HippoRAG on multi-hop QA benchmarks (87.8% avg Recall@5)
12-
- **Simple API** — Just 3 lines of code to get started
15+
| | |
16+
|---|---|
17+
| **No Graph Database** | Pure vector search with Milvus — no Neo4j, no ArangoDB, no extra infra |
18+
| **Single-Pass Reranking** | One LLM call, no iterative agent loops like IRCoT |
19+
| **Knowledge-Intensive** | Optimized for legal, finance, medical, literature domains |
20+
| **Zero Configuration** | Milvus Lite by default, works out of the box |
21+
| **Multi-hop Reasoning** | Subgraph expansion for complex multi-hop QA |
22+
| **State-of-the-Art** | 87.8% avg Recall@5 on standard benchmarks |
1323

1424
## Quick Example
1525

@@ -27,7 +37,7 @@ result = rag.query("What did Einstein develop?")
2737
print(result.answer)
2838
```
2939

30-
## Performance at a Glance
40+
## Performance
3141

3242
| Method | MuSiQue | HotpotQA | 2WikiMultiHopQA | Average |
3343
|--------|---------|----------|-----------------|---------|

docs/use-cases.md

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# Use Cases
2+
3+
Vector Graph RAG is designed for **knowledge-intensive domains** where documents contain dense factual relationships and answers often require connecting information across multiple sources.
4+
5+
## When to Use Graph RAG vs Naive RAG
6+
7+
**Use Naive RAG when:**
8+
9+
- Questions can be answered from a single passage
10+
- Content is self-contained (e.g., FAQ, product docs)
11+
- Low latency is critical and accuracy trade-off is acceptable
12+
13+
**Use Vector Graph RAG when:**
14+
15+
- Answers require connecting facts across multiple documents
16+
- Content has rich entity relationships (people, organizations, concepts)
17+
- Multi-hop reasoning is needed ("Who worked with X at Y?")
18+
- Domain has dense factual knowledge
19+
20+
## Domain Examples
21+
22+
### Legal
23+
24+
Legal documents are full of cross-references: statutes cite other statutes, court opinions reference precedents, contracts refer to defined terms across sections.
25+
26+
```python
27+
rag = VectorGraphRAG(collection_prefix="legal_contracts")
28+
29+
rag.add_texts([
30+
"Section 3.1 defines the indemnification obligations of the Seller.",
31+
"Under Section 5.2, breach of Section 3.1 triggers termination rights.",
32+
"The Buyer may exercise termination rights within 30 days of notice.",
33+
])
34+
35+
result = rag.query("What happens if the Seller breaches indemnification obligations?")
36+
# Graph connects: Seller → indemnification (3.1) → breach triggers termination (5.2) → 30 days
37+
```
38+
39+
### Finance
40+
41+
Financial data forms natural graphs: companies own subsidiaries, executives serve on boards, transactions flow between entities.
42+
43+
```python
44+
rag = VectorGraphRAG(collection_prefix="financial_reports")
45+
46+
rag.add_texts([
47+
"Berkshire Hathaway acquired See's Candies in 1972 for $25 million.",
48+
"See's Candies generated $383 million in pre-tax earnings by 2007.",
49+
"Warren Buffett has called See's the ideal business.",
50+
])
51+
52+
result = rag.query("How has Berkshire's candy acquisition performed?")
53+
# Graph connects: Berkshire → acquired See's → earnings growth → Buffett's assessment
54+
```
55+
56+
### Medical & Biomedical
57+
58+
Drug interactions, symptom-disease-treatment pathways, and clinical trial relationships are inherently relational.
59+
60+
```python
61+
rag = VectorGraphRAG(collection_prefix="medical_literature")
62+
63+
rag.add_texts([
64+
"Metformin is the first-line treatment for type 2 diabetes.",
65+
"Patients on metformin should have renal function monitored.",
66+
"Impaired renal function may require dose adjustment or alternative therapy.",
67+
])
68+
69+
result = rag.query("What monitoring is needed for first-line diabetes treatment?")
70+
# Graph connects: diabetes → metformin (first-line) → renal monitoring → dose adjustment
71+
```
72+
73+
### Literature & Novels
74+
75+
Character relationships, plot events, and thematic connections across chapters benefit from graph representation.
76+
77+
```python
78+
from vector_graph_rag.loaders import DocumentImporter
79+
80+
importer = DocumentImporter(chunk_size=1500, chunk_overlap=200)
81+
result = importer.import_sources(["/path/to/novel.pdf"])
82+
83+
rag = VectorGraphRAG(collection_prefix="novel_analysis")
84+
rag.add_documents(result.documents, extract_triplets=True)
85+
86+
result = rag.query("How does the protagonist's relationship with the antagonist evolve?")
87+
# Graph captures character interactions across the entire novel
88+
```
89+
90+
### Academic Research
91+
92+
Citation networks, concept dependencies, and cross-paper methodology comparisons.
93+
94+
```python
95+
from vector_graph_rag.loaders import DocumentImporter
96+
97+
importer = DocumentImporter(chunk_size=1000, chunk_overlap=200)
98+
result = importer.import_sources([
99+
"/path/to/paper1.pdf",
100+
"/path/to/paper2.pdf",
101+
"/path/to/paper3.pdf",
102+
])
103+
104+
rag = VectorGraphRAG(collection_prefix="research_survey")
105+
rag.add_documents(result.documents, extract_triplets=True)
106+
107+
result = rag.query("What methods achieve the best performance on this task?")
108+
# Graph connects methods, results, and comparisons across papers
109+
```
110+
111+
## Organizing Multiple Knowledge Bases
112+
113+
Use `collection_prefix` to separate different document sets in the same Milvus instance:
114+
115+
```python
116+
# Each domain gets its own isolated graph
117+
legal_rag = VectorGraphRAG(milvus_uri="http://localhost:19530", collection_prefix="legal")
118+
finance_rag = VectorGraphRAG(milvus_uri="http://localhost:19530", collection_prefix="finance")
119+
medical_rag = VectorGraphRAG(milvus_uri="http://localhost:19530", collection_prefix="medical")
120+
```
121+
122+
Or use `milvus_db` for database-level isolation:
123+
124+
```python
125+
rag = VectorGraphRAG(
126+
milvus_uri="http://localhost:19530",
127+
milvus_db="production",
128+
collection_prefix="legal_v2",
129+
)
130+
```

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,5 @@ nav:
4646
- Home: index.md
4747
- Getting Started: getting-started.md
4848
- How It Works: how-it-works.md
49+
- Use Cases: use-cases.md
4950
- Evaluation: evaluation.md

0 commit comments

Comments
 (0)