Elffuss BraidHub

kikocis/lancedb public

85830ec79fd2 路 2.0 KiBRenderedRawPermalink
1**Graph RAG 馃搳**
2====================================================================
3Graph RAG uses knowledge graphs together with large language models (LLMs) to improve how information is retrieved and generated. It overcomes the limits of traditional search methods by using knowledge graphs, which organize data as connected entities and relationships.
4
5One of the main benefits of Graph RAG is its ability to capture and represent complex relationships between entities, something that traditional text-based retrieval systems struggle with. By using this structured knowledge, LLMs can better grasp the context and details of a query, resulting in more accurate and insightful answers.
6
7**[Official Paper](https://arxiv.org/pdf/2404.16130)**
8
9**[Offical Implementation](https://github.com/microsoft/graphrag)**
10
11[Microsoft Research Blog](https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/)
12
13!!! note "Default VectorDB"
14
15 Graph RAG uses LanceDB as the default vector database for performing vector search to retrieve relevant entities.
16
17Working with Graph RAG is quite straightforward
18
19- **Installation and API KEY as env variable**
20
21Set `OPENAI_API_KEY` as `GRAPHRAG_API_KEY`
22
23```bash
24pip install graphrag
25export GRAPHRAG_API_KEY="sk-..."
26```
27
28- **Initial structure for indexing dataset**
29
30```bash
31python3 -m graphrag.index --init --root dataset-dir
32```
33
34- **Index Dataset**
35
36```bash
37python3 -m graphrag.index --root dataset-dir
38```
39
40- **Execute Query**
41
42Global Query Execution gives a broad overview of dataset
43
44```bash
45python3 -m graphrag.query --root dataset-dir --method global "query-question"
46```
47
48Local Query Execution gives a detailed and specific answers based on the context of the entities
49
50```bash
51python3 -m graphrag.query --root dataset-dir --method local "query-question"
52```
53
54[![Open In Colab](../assets/colab.svg)](https://colab.research.google.com/github/lancedb/vectordb-recipes/blob/main/examples/Graphrag/main.ipynb)