# vector-graph-rag
**Repository Path**: cangmj/vector-graph-rag
## Basic Information
- **Project Name**: vector-graph-rag
- **Description**: mirror: https://github.com/zilliztech/vector-graph-rag.git
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2026-04-23
- **Last Updated**: 2026-04-23
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
Vector Graph RAG
Graph RAG with pure vector search β no graph database needed.
> π‘ Encode entities and relations as vectors in [Milvus](https://milvus.io/), replace iterative LLM agents with a single reranking pass β achieve state-of-the-art multi-hop retrieval at a fraction of the operational and computational cost.
## β¨ Features
- **No Graph Database Required** β Pure vector search with Milvus, no Neo4j or other graph databases needed
- **Single-Pass LLM Reranking** β One LLM call to rerank, no iterative agent loops (unlike IRCoT or multi-step reflection)
- **Knowledge-Intensive Friendly** β Optimized for domains with dense factual content: legal, finance, medical, literature, etc.
- **Zero Configuration** β Uses Milvus Lite by default, works out of the box with a single file
- **Multi-hop Reasoning** β Subgraph expansion enables complex multi-hop question answering
- **State-of-the-Art Performance** β 87.8% avg Recall@5 on multi-hop QA benchmarks, outperforming HippoRAG
## π¦ Installation
```bash
pip install vector-graph-rag
# or
uv add vector-graph-rag
```
With document loaders (PDF, DOCX, web pages)
```bash
pip install "vector-graph-rag[loaders]"
# or
uv add "vector-graph-rag[loaders]"
```
## π Quick Start
```python
from vector_graph_rag import VectorGraphRAG
rag = VectorGraphRAG() # reads OPENAI_API_KEY from environment
rag.add_texts([
"Albert Einstein developed the theory of relativity.",
"The theory of relativity revolutionized our understanding of space and time.",
])
result = rag.query("What did Einstein develop?")
print(result.answer)
```
> **Note:** Set `OPENAI_API_KEY` environment variable before running.
π With pre-extracted triplets β click to expand
Skip LLM extraction if you already have knowledge graph triplets:
```python
rag.add_documents_with_triplets([
{
"passage": "Einstein developed relativity at Princeton.",
"triplets": [
["Einstein", "developed", "relativity"],
["Einstein", "worked at", "Princeton"],
],
},
])
```
π Import from URLs and files β click to expand
```python
from vector_graph_rag import VectorGraphRAG
from vector_graph_rag.loaders import DocumentImporter
# Import from URLs, PDFs, DOCX, etc. (with automatic chunking)
importer = DocumentImporter(chunk_size=1000, chunk_overlap=200)
result = importer.import_sources([
"https://en.wikipedia.org/wiki/Albert_Einstein",
"/path/to/document.pdf",
"/path/to/report.docx",
])
rag = VectorGraphRAG(milvus_uri="./my_graph.db")
rag.add_documents(result.documents, extract_triplets=True)
result = rag.query("What did Einstein discover?")
print(result.answer)
```
βοΈ Custom configuration β click to expand
```python
rag = VectorGraphRAG(
milvus_uri="./my_data.db", # or remote Milvus / Zilliz Cloud
llm_model="gpt-4o",
embedding_model="text-embedding-3-large",
collection_prefix="my_project", # isolate multiple datasets
)
```
All settings can also be configured via environment variables with `VGRAG_` prefix or a `.env` file:
```bash
VGRAG_LLM_MODEL=gpt-4o
VGRAG_EMBEDDING_MODEL=text-embedding-3-large
VGRAG_MILVUS_URI=http://localhost:19530
```
> π Full Python API reference β [Python API docs](https://zilliztech.github.io/vector-graph-rag/python-api/)
## π¬ How It Works
**Indexing:**
```
Documents β Triplet Extraction (LLM) β Entities + Relations β Embedding β Milvus
```
**Query:**
```
Question β Entity Extraction β Vector Search β Subgraph Expansion β LLM Reranking β Answer
```
**Example:** *"What did Einstein develop?"*
1. Extract entity: `Einstein`
2. Vector search finds similar entities and relations in Milvus
3. Subgraph expansion collects neighboring relations
4. **Single-pass LLM reranking** selects the most relevant passages
5. Generate answer from selected passages
> π Detailed pipeline walkthrough with diagrams β [How It Works](https://zilliztech.github.io/vector-graph-rag/how-it-works/) Β· [Design Philosophy](https://zilliztech.github.io/vector-graph-rag/design-philosophy/)
## π Evaluation Results
Evaluated on three multi-hop QA benchmarks (Recall@5):
| Method | MuSiQue | HotpotQA | 2WikiMultiHopQA | Average |
|--------|---------|----------|-----------------|---------|
| Naive RAG | 55.6% | 90.8% | 73.7% | 73.4% |
| IRCoT + HippoRAGΒΉ | 57.6% | 83.0% | 93.9% | 78.2% |
| HippoRAG 2Β² | **74.7%** | **96.3%** | 90.4% | 87.1% |
| **Vector Graph RAG** | 73.0% | **96.3%** | **94.1%** | **87.8%** |
ΒΉ [HippoRAG (NeurIPS 2024)](https://arxiv.org/abs/2405.14831) Β² [HippoRAG 2 (2025)](https://arxiv.org/abs/2502.14802)
> π Detailed analysis and reproduction steps β [Evaluation](https://zilliztech.github.io/vector-graph-rag/evaluation/)
## ποΈ Milvus Backend
Just change `milvus_uri` to switch between deployment modes:
**Milvus Lite** (default) β zero config, single-process, data stored in a local file. Great for prototyping and small datasets:
```python
rag = VectorGraphRAG(milvus_uri="./my_graph.db") # just works
```
β **Zilliz Cloud** β fully managed, [free tier available](https://cloud.zilliz.com/signup?utm_source=github&utm_medium=referral&utm_campaign=vector-graph-rag-readme) β [sign up](https://cloud.zilliz.com/signup?utm_source=github&utm_medium=referral&utm_campaign=vector-graph-rag-readme) π:
```python
rag = VectorGraphRAG(
milvus_uri="https://in03-xxx.api.gcp-us-west1.zillizcloud.com",
milvus_token="your-api-key",
)
```
β Sign up for a free Zilliz Cloud cluster
You can [sign up](https://cloud.zilliz.com/signup?utm_source=github&utm_medium=referral&utm_campaign=vector-graph-rag-readme) on Zilliz Cloud to get a free cluster and API key.

Self-hosted Milvus Server (Docker) β for advanced users
If you need a dedicated Milvus instance for multi-user or team environments, you can deploy Milvus standalone with Docker Compose. This requires Docker and some infrastructure knowledge. See the [official installation guide](https://milvus.io/docs/install_standalone-docker-compose.md) for detailed steps.
```python
rag = VectorGraphRAG(milvus_uri="http://localhost:19530")
```
## π₯οΈ Frontend & REST API
Vector Graph RAG includes a React-based frontend for interactive graph visualization and a FastAPI backend.
```bash
# Backend
uv sync --extra api
uv run uvicorn vector_graph_rag.api.app:app --host 0.0.0.0 --port 8000
# Frontend
cd frontend && npm install && npm run dev
```
| Endpoint | Method | Description |
|----------|--------|-------------|
| `/api/health` | GET | Health check |
| `/api/graphs` | GET | List available graphs |
| `/api/graph/{name}/stats` | GET | Get graph statistics |
| `/api/query` | POST | Query the knowledge graph |
| `/api/documents` | POST | Add documents |
| `/api/import` | POST | Import from URLs/paths |
| `/api/upload` | POST | Upload files |
See API docs at `http://localhost:8000/docs` after starting the server.
> π Full endpoint reference β [REST API docs](https://zilliztech.github.io/vector-graph-rag/rest-api/) Β· [Frontend guide](https://zilliztech.github.io/vector-graph-rag/frontend/)
## π Links
- [Documentation](https://zilliztech.github.io/vector-graph-rag/) β full guides, API reference, and architecture details
- [How It Works](https://zilliztech.github.io/vector-graph-rag/how-it-works/) β pipeline walkthrough with diagrams
- [Design Philosophy](https://zilliztech.github.io/vector-graph-rag/design-philosophy/) β why pure vector search, no graph DB
- [Milvus](https://milvus.io/) β the vector database powering Vector Graph RAG
- [FAQ](https://zilliztech.github.io/vector-graph-rag/faq/) β common questions and troubleshooting
## Contributing
Bug reports, feature requests, and pull requests are welcome! For questions and discussions, join us on [Discord](https://discord.com/invite/FG6hMJStWu).
## π License
[MIT](LICENSE)