Support text2gql search for GraphRAG (#2227)

Co-authored-by: aries_ckt <916701291@qq.com>
This commit is contained in:
SonglinLyu
2025-01-22 16:30:17 +08:00
committed by GitHub
parent 9336e80f1d
commit e0081e6b0a
23 changed files with 791 additions and 165 deletions

View File

@@ -473,3 +473,48 @@ Furthermore, as shown in the following figure, compared to RAG, GraphRAG with si
</p>
In conclusion, enabling similarity search in GraphRAG significantly expands the scope and relevance of its responses.
### Text2GQL Search in GraphRAG:
In the latest version of DB-GPT, we have implemented a new feature:
- **Text2GQL search** for GraphRAG retrieval
#### How to use?
Set the variables below in the `.env` file to enable text2gql search in DB-GPT.
```
TEXT2GQL_SEARCH_ENABLED=True # enable the text2gql search for entities and relations.
```
#### Why to use?
Keywords or vectors based retrieval will generate large multihop subgraph for LLM to summarize information, but this method is costive when questions asked by users can be simply expressed by a single graph query. Text2GQL search can effectively reduce the cost of graph search and increase the accuracy of the retrieved subgraph under above situation.
In the future, we hope to further improve the ability of Text2GQL translation to compete with keywords or vectors based retrieval under complicated questions with both prompt based method and finetune based method.
#### Comparison of Text2GQL Search Results
Given identical documents and questions in the same environment, the results of the keyword mode are as follows:
<p align="left">
<img src={'/img/chat_knowledge/graph_rag/comparison_result_for_keywords_search.png'} width="1000px"/>
</p>
The results of the text2gql search mode are as follows:
<p align="left">
<img src={'/img/chat_knowledge/graph_rag/comparison_result_for_text2gql_search.png'} width="1000px"/>
</p>
Compared to the keyword search method, the text2gql search method can generate an accurate graph query laguage to query the entity of DB-GPT in knowledge graph, which is
```cypher
MATCH (n) WHERE n.id = 'DB-GPT' RETURN n LIMIT 10
```
This implies that in scenarios where questions can be expressed by a single graph query, the text2gql search approach can retrieve more accurate information with lower cost.
In conclusion, enabling text2gql search in GraphRAG significantly increase the accuracy and lower the cost when questions are concise and clear.

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 KiB