伊洪|跑步爱好者,开源爱好者,NebulaGraph社区布道师 一、GraphRAG介绍 二、GraphRAG能力总结 三、何时使用GraphRAG 四、GraphRAG落地实战 五、GraphRAG的缺点和优化 About Me: https://yihong.run/ https://github.com/yihong0618/ RAG ->GraphRAG •学习从历史开始https://blog.codingnow.com/2007/12/history.html •我有一个忘记从哪继承来的观点:无论我们想学什么,都应该从学习他的历史开始。极端点说,无论学什么,都是在学他的历史。 https://github.com/run-llama/llama_index/pull/2581 https://github.com/microsoft/graphrag RAG VSGraphRAG RAG范式 -Retrieval Augmented •索引:准备数据以进行高效检索 •查询:搜索和检索相关参考材料 -Generation •从检索到的信息中进行上下文学习 RAG VSGraphRAG •细粒度检索:碎片化知识•全局上下文:丢失连接•语义相似度:相关性错配•分层摘要:宏观问题挑战 RAG VSGraphRAG •相似性vs.相关性•语义相似度≠上下文相关性(基于嵌入的RAG)•基础模型通常依赖于常识或字面意义,导致相关性相关性幻觉的错误正例•高相似度(例如,95%)并不保证相关性;上下文无关的片段可能看起来非常相似(例如,虚构的食谱或不存在的情节) 二、GraphRAG能力总结 •Graph Indexing•Text to Query•Chain of Exploration•GraphRAG编排 GraphRAG编排 三、何时使用GraphRAG •大海捞针(Needle in a Haystack) 当需要细粒度检索或连接分散信息时,Graph Index和Retrieval提供最佳解决方案。 •分层索引与摘要 当需要分层索引和摘要时,将RAPTOR/Tree-RAG集成到Graph DB中可以将检索转化为灵活的查询模式模板。 •全局搜索 当需要全局上下文或全面理解时,GraphRAG中的社区检测摘要优于传统方法。 •领域知识集成 当将领域知识嵌入到流程中时,将这些知识投影和抽象到图模式中是元方法,能够实现稳健的推理和高效的检索。 四、GraphRAG落地实战 GraphRAG企业知识管理与应用构建平台 TiDB AI小助手(基于TiDB Vector构建的GraphRAG方案) Intro to TiDB Graph RAG and Demo - https://tidb.ai TiDBdoc Chat everywhere KG Search - Searchrelevant chunks from graph ●Store entities and relationships in RDBMS tables●Use SQL to perform a graph search SELECT… FROMrelationshipsLEFT OUTER JOINentities AS entities_1ONentities_1.id =relationships.source_entity_idLEFT OUTER JOIN entitiesASentities_2ON entities_2.id =relationships.target_entity_idORDER BYVEC_COSINE_DISTANCE(relationships.relationship_desc_vec, [......]) LIMIT 10 Vector RAG ↓ + Graph RAG + Full Text Search (WIP) Query: "Does TiDB offer ascalable andconsistent database solution?" Semantic Search结果排序(VEC_COSINE_DISTANCE) 1."TiDB is a distributed SQL database thatsupports horizontal scalability and strongconsistency."(高度相关,直接回答了查询中的“scalable”和“consistent”)2."You can scale TiDB without sacrificingavailability or performance."(提到了“scalability”和“performance”,间接暗示了一致性)3."TiDB offers a cloud-native, HTAP databasesolution, integrating transactional and analyticalprocessing."(描述了TiDB的特性,但未直接提到scalability或consistency) 假设有一组描述TiDB功能和特性的文档集: ●"TiDB is a distributed SQL databasethat supports horizontal scalability andstrong consistency."●"TiDB offers a cloud-native, HTAPdatabase solution, integratingtransactional and analyticalprocessing."●"You can scale TiDB withoutsacrificing availability or performance." 最后聊聊GraphRAG的缺点和优化 GraphRAG贵么? •广义的角度来说很贵 •存在权衡取舍,有多种可选策略 •这是一种馈赠而非负担,我们可以选择哪些知识进行开卷考试的预先学习 Thanks!