


















https://github.com/fanqingsong/graphrag/blob/main/docs/GRAPH_RAG_EXPLAINED.md
假设你上传了三个文档:
文档1:Microsoft投资新闻
Microsoft宣布向OpenAI投资100亿美元,这是AI领域最大的投资之一。
OpenAI的CEO Sam Altman表示这次合作将加速AI技术的发展。
文档2:OpenAI技术报告
OpenAI开发了GPT-4模型,在多个领域取得突破。
公司总部位于旧金山,由Sam Altman领导。
文档3:AI行业分析
AI领域的投资正在快速增长。Microsoft、Google等科技巨头都在加大投入。
旧金山湾区是AI创新的中心。
系统处理这些文档时,会:
提取实体(Entity):
Microsoft (COMPANY, 重要性: 0.9)OpenAI (COMPANY, 重要性: 0.9)Sam Altman (PERSON, 重要性: 0.8)旧金山 (LOCATION, 重要性: 0.6)GPT-4 (TECHNOLOGY, 重要性: 0.7)建立关系(Relationship):
Microsoft --[投资于]--> OpenAI (强度: 0.9)Sam Altman --[领导]--> OpenAI (强度: 0.95)OpenAI --[位于]--> 旧金山 (强度: 0.8)OpenAI --[开发了]--> GPT-4 (强度: 0.85)创建图结构(在Neo4j中):
(Microsoft:COMPANY) --[投资于]--> (OpenAI:COMPANY)
(OpenAI:COMPANY) <--[领导]-- (Sam Altman:PERSON)
(OpenAI:COMPANY) --[位于]--> (旧金山:LOCATION)
(OpenAI:COMPANY) --[开发了]--> (GPT-4:TECHNOLOGY)
用户问:"Sam Altman领导的公司在AI领域有什么重要投资?"
可能只返回:
问题:可能遗漏间接相关的信息。
系统会:
初始检索:找到包含"Sam Altman"的chunk
Chunk A: "OpenAI的CEO Sam Altman表示这次合作..."
图遍历扩展:
# 从Sam Altman实体开始
Sam Altman --[领导]--> OpenAI (找到!)
# 从OpenAI继续扩展
OpenAI <--[投资于]-- Microsoft (找到!)
# 通过图关系找到相关chunk
Chunk B: "Microsoft宣布向OpenAI投资100亿美元..."
Chunk C: "OpenAI开发了GPT-4模型..."
多跳推理路径:
查询: Sam Altman领导的公司的投资
↓
路径1: Sam Altman → 领导 → OpenAI → 被投资于 → Microsoft
路径2: Sam Altman → 领导 → OpenAI → 开发了 → GPT-4
最终返回的增强上下文:
Chunk A (直接匹配): "OpenAI的CEO Sam Altman..."
Chunk B (图扩展): "Microsoft宣布向OpenAI投资100亿美元..."
Chunk C (图扩展): "OpenAI开发了GPT-4模型..."
有了这些通过graph连接的上下文,LLM可以生成更完整的答案:
"Sam Altman领导的OpenAI公司获得了Microsoft的100亿美元投资,这是AI领域最大的投资之一。同时,OpenAI还开发了GPT-4等重要的AI技术。"
1. 文档上传
↓
2. 文档分割成 Chunks
↓
3. 为每个 Chunk 生成向量嵌入
↓
4. 创建 Document 和 Chunk 节点
↓
5. 提取实体(Entity)
↓
6. 建立实体关系(Relationship)
↓
7. 创建 Entity 节点和关系
↓
8. 计算 Chunk 之间的相似度
↓
9. 创建 SIMILAR_TO 关系
1. 用户查询
↓
2. 查询分析(分析查询类型、复杂度等)
↓
3. 生成查询向量嵌入
↓
4. 向量相似度搜索(找到初始 Chunks)
↓
5. 图扩展(通过图关系找到相关 Chunks)
↓
6. 多跳推理(可选,通过实体关系进行多跳遍历)
↓
7. 合并和排序结果
↓
8. 传递给 LLM 生成答案
| 模式 | 向量搜索 | 图扩展 | 多跳推理 | 适用场景 |
|---|---|---|---|---|
GraphRAG 的核心优势在于:
这就是为什么这个项目叫 GraphRAG:它使用图(Graph)来增强检索增强生成(RAG),使系统能够理解实体之间的关系,而不仅仅是文本相似度。
参考:
https://github.com/fanqingsong/GustoBot
本项目致力于打造一个可迁移、可扩展、面向垂直领域的智能客服模板系统。通过清晰的三层架构设计(主路由层 → 多工具子图层 → 原子工具层),你可以轻松将其迁移至其他垂直领域(如「宝可梦百科」、「中医药典」、「法律咨询」、「政务服务」等)中打造专域智能客服。仅需更换知识源与图谱结构,即可实现:
https://github.com/HKUDS/LightRAG?tab=readme-ov-file
https://arxiv.org/abs/2410.05779
Retrieval-Augmented Generation (RAG) systems enhance large language models (LLMs) by integrating external knowledge sources, enabling more accurate and contextually relevant responses tailored to user needs. However, existing RAG systems have significant limitations, including reliance on flat data representations and inadequate contextual awareness, which can lead to fragmented answers that fail to capture complex inter-dependencies. To address these challenges, we propose LightRAG, which incorporates graph structures into text indexing and retrieval processes. This innovative framework employs a dual-level retrieval system that enhances comprehensive information retrieval from both low-level and high-level knowledge discovery. Additionally, the integration of graph structures with vector representations facilitates efficient retrieval of related entities and their relationships, significantly improving response times while maintaining contextual relevance. This capability is further enhanced by an incremental update algorithm that ensures the timely integration of new data, allowing the system to remain effective and responsive in rapidly changing data environments. Extensive experimental validation demonstrates considerable improvements in retrieval accuracy and efficiency compared to existing approaches. We have made our LightRAG open-source and available at the link: this https URL
https://github.com/HKUDS/RAG-Anything
Next-Generation Multimodal Intelligence
Modern documents increasingly contain diverse multimodal content—text, images, tables, equations, charts, and multimedia—that traditional text-focused RAG systems cannot effectively process. RAG-Anything addresses this challenge as a comprehensive All-in-One Multimodal Document Processing RAG system built on LightRAG.
As a unified solution, RAG-Anything eliminates the need for multiple specialized tools. It provides seamless processing and querying across all content modalities within a single integrated framework. Unlike conventional RAG approaches that struggle with non-textual elements, our all-in-one system delivers comprehensive multimodal retrieval capabilities.
Users can query documents containing interleaved text, visual diagrams, structured tables, and mathematical formulations through one cohesive interface. This consolidated approach makes RAG-Anything particularly valuable for academic research, technical documentation, financial reports, and enterprise knowledge management where rich, mixed-content documents demand a unified processing framework.
RAG-Anything implements an effective multi-stage multimodal pipeline that fundamentally extends traditional RAG architectures to seamlessly handle diverse content modalities through intelligent orchestration and cross-modal understanding.
📄
Document Parsing
→
🧠
Content Analysis
→
🔍
Knowledge Graph
→
🎯
Intelligent Retrieval
The system provides high-fidelity document extraction through adaptive content decomposition. It intelligently segments heterogeneous elements while preserving contextual relationships. Universal format compatibility is achieved via specialized optimized parsers.
Key Components:
⚙️ MinerU Integration: Leverages MinerU for high-fidelity document structure extraction and semantic preservation across complex layouts.
🧩 Adaptive Content Decomposition: Automatically segments documents into coherent text blocks, visual elements, structured tables, mathematical equations, and specialized content types while preserving contextual relationships.
📁 Universal Format Support: Provides comprehensive handling of PDFs, Office documents (DOC/DOCX/PPT/PPTX/XLS/XLSX), images, and emerging formats through specialized parsers with format-specific optimization.
The system automatically categorizes and routes content through optimized channels. It uses concurrent pipelines for parallel text and multimodal processing. Document hierarchy and relationships are preserved during transformation.
Key Components:
🎯 Autonomous Content Categorization and Routing: Automatically identify, categorize, and route different content types through optimized execution channels.
⚡ Concurrent Multi-Pipeline Architecture: Implements concurrent execution of textual and multimodal content through dedicated processing pipelines. This approach maximizes throughput efficiency while preserving content integrity.
🏗️ Document Hierarchy Extraction: Extracts and preserves original document hierarchy and inter-element relationships during content transformation.
The system deploys modality-aware processing units for heterogeneous data modalities:
Specialized Analyzers:
🔍 Visual Content Analyzer:
📊 Structured Data Interpreter:
📐 Mathematical Expression Parser:
🔧 Extensible Modality Handler:
The multi-modal knowledge graph construction module transforms document content into structured semantic representations. It extracts multimodal entities, establishes cross-modal relationships, and preserves hierarchical organization. The system applies weighted relevance scoring for optimized knowledge retrieval.
Core Functions:
🔍 Multi-Modal Entity Extraction: Transforms significant multimodal elements into structured knowledge graph entities. The process includes semantic annotations and metadata preservation.
🔗 Cross-Modal Relationship Mapping: Establishes semantic connections and dependencies between textual entities and multimodal components. This is achieved through automated relationship inference algorithms.
🏗️ Hierarchical Structure Preservation: Maintains original document organization through "belongs_to" relationship chains. These chains preserve logical content hierarchy and sectional dependencies.
⚖️ Weighted Relationship Scoring: Assigns quantitative relevance scores to relationship types. Scoring is based on semantic proximity and contextual significance within the document structure.
The hybrid retrieval system combines vector similarity search with graph traversal algorithms for comprehensive content retrieval. It implements modality-aware ranking mechanisms and maintains relational coherence between retrieved elements to ensure contextually integrated information delivery.
Retrieval Mechanisms:
🔀 Vector-Graph Fusion: Integrates vector similarity search with graph traversal algorithms. This approach leverages both semantic embeddings and structural relationships for comprehensive content retrieval.
📊 Modality-Aware Ranking: Implements adaptive scoring mechanisms that weight retrieval results based on content type relevance. The system adjusts rankings according to query-specific modality preferences.
🔗 Relational Coherence Maintenance: Maintains semantic and structural relationships between retrieved elements. This ensures coherent information delivery and contextual integrity.
出处:http://www.cnblogs.com/lightsong/ 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。