KAG

OpenSPGApache-2.0更新放缓

基于 OpenSPG 引擎和大模型构建的逻辑推理与检索框架,用逻辑形式引导专业领域知识库做事实问答,解决传统 RAG 向量相似度检索在多跳推理上不可靠的问题。

KAG is a logical form-guided reasoning and retrieval framework based on OpenSPG engine and LLMs. It is used to build logical reasoning and factual Q&A solutions for professional domain knowledge bases. It can effectively overcome the shortcomings of the traditional RAG vector similarity calculation model.

v0.8.0发布于 2025-06-28 04:45 UTC9,163star +6 / 7 天719fork同步于 2026-11-10 11:30 UTC

怎么上手

由 README 提炼,执行前请确认
git clone https://github.com/OpenSPG/KAG.git
cd KAG && pip install -e .
硬件要求按 README 说明

README 未说明显存、GPU 型号或 CPU 运行要求

有 Docker 镜像
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

基于 OpenSPG 引擎与大模型的逻辑推理问答框架,用逻辑形式引导检索,解决传统 RAG 向量相似度歧义问题

基于 OpenSPG 引擎和大模型构建的逻辑推理与检索框架,用逻辑形式引导专业领域知识库做事实问答,解决传统 RAG 向量相似度检索在多跳推理上不可靠的问题。

核心能力

  • 知识与 Chunk 互索引,融合图结构与原文上下文
  • 概念语义推理做知识对齐,缓解 OpenIE 噪声
  • Schema 约束的知识构建,承载领域专家知识
  • 逻辑形式引导规划/推理/检索算子混合求解
  • 支持逻辑推理与多跳事实问答,内置基准对比

容易踩的坑

需 Python 3.10 或以上并先创建虚拟环境;kag-model 部分尚未开源,本版本只含 kg-builder 与 kg-solver;需按官方使用指南配置才能跑通内置数据集

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v0.8.0
  1. v0.8.0Version 0.8.0最新正式版2025-06-28 · 2025-06-28 04:45 UTC

    Version 0.8.0 (2025-06-27)

    1、Overview

    We are excited to announce the official release of KAG version 0.8. This update focuses on continuously enhancing the consistency, rigor, and accuracy of large model knowledge base-driven reasoning and question-answering. It also introduces several significant new features and capabilities. First, we have upgraded the capabilities of the KAG knowledge base. We have expanded support for two modes: private domain knowledge bases (including structured and unstructured data) and public domain knowledge bases. This includes the ability to integrate public web data sources such as LBS and WebSearch via the MCP protocol. Additionally, we have improved the management of private domain knowledge base indexing, incorporating multiple foundational index types such as Outline, Summary, KnowledgeUnit, AtomicQuery, Chunk, and Table. This supports developers in customizing indexes and synchronizing them with product interfaces. Users can select the most appropriate index type based on their specific scenarios, achieving a balance between construction costs and business outcomes. Second, we have optimized the product experience and refined the system integration interfaces. On the product front, we have decoupled the knowledge base from applications. The knowledge base now manages private domain data (both structured and unstructured) and public domain data, while applications can link to multiple knowledge bases. Based on the index types used during knowledge base construction, the system automatically adapts the corresponding retrieval engine to recall data. Both applications and knowledge bases independently manage model dependencies and task scheduling, enhancing flexibility. In terms of system integration, we have refined the KAG recall and Q&A interfaces, adding support for embedding reasoning and Q&A pages within business applications. We have fully embraced the MCP protocol, enabling seamless integration of KAG reasoning and Q&A into agent workflows (based on the MCP protocol). Third, KAG has successfully adapted to the KAG-Thinker model. Through optimizations such as broad decomposition and deep solving of complex problems, knowledge boundary determination, and noise-resistant retrieval results, the stability of the KAG framework's reasoning paradigm and the rigor of its reasoning logic have been significantly improved under the guidance of iterative thinking paradigms. Further details on the release and usage of the KAG-Thinker model will be provided in our upcoming announcements. In addition to the aforementioned framework and product optimizations, we have also enhanced Q&A efficiency and the stability of streaming outputs. This update is based on the Qwen2.5-72B foundation model and has achieved performance alignment across various RAG frameworks and selected KG datasets. The overall benchmark results of this release are illustrated in Figures 1~3, with detailed metrics available in the open_benchmark section.

    2、Framework Enhancements

    2.1、Configurable Index Management

    Index extraction and retrieval are core capabilities of knowledge base applications. KAG v0.8 has upgraded its architecture to support configurable management of index construction and retrieval. Each index type is equipped with its own extractor (Extractor) and retriever (Retriever), managed through the IndexManager. KAG comes with built-in foundational index types such as KnowledgeUnit (an enhanced version of graph triples), Outline, Summary, Chunk, AtomicQuery, and Table, along with their corresponding extractors and retrievers. During the knowledge base construction phase, the platform invokes the appropriate extractor based on the index types selected by the user to perform index extraction. In the application phase, based on the knowledge bases associated with the application, the platform automatically calls the corresponding retriever to complete the recall of graph/chunk/doc data and integrates w

  2. v0.7.1Version 0.7.12025-04-25 · 2025-04-25 07:23 UTC
    查看更新说明

    Version 0.7.1 (2025-04-25)

    Dear Open Source Community,We are excited to officially announce the release of version 0.7.1 for OpenSPG/KAG! This release represents the collaborative efforts of both our core technical team and contributors from the global open source community. The update focuses on improving user experience, optimizing system performance, and addressing key issues based on your feedback. Below are the highlights of this release:

    🛠️ Fixes & Optimization Highlights:

    1. Resolved source code compilation errors: Fixed NoSuchBeanDefinitionException issues during openspg compilation to ensure a smooth development experience.
    2. Enhanced error diagnostics: Resolved the issue where timeout errors for vectorizer calls couldn't be traced, enabling quicker troubleshooting.
    3. Improved task performance: Optimized small task construction times by adjusting the scheduling interval, allowing asynchronous tasks to trigger immediately without waiting.
    4. Enhanced container stability: Fixed the issue where container restarts caused scheduling states to hang or crash.
    5. Reasoning Q&A Stream output optimization: Improved the responsiveness and fluidity of streaming outputs for Reasoning Q&A scenarios.
    6. Task details page upgrades: Added auto-refresh capabilities for logs and time cost statistics, allowing users to monitor system and task performance in real time.
    7. Simplified task splitting configuration: Disable the semantic segmentation module to avoid excessive token consumption caused by misoperations.
    8. Website updates: Added a new partner showcase section to the homepage and included a redirect to the OpenKG official website to foster collaborative opportunities.
    9. Bug fixes and product optimization: Implemented multiple fixes and refinements to address reported issues, enhancing product stability.

    🌟 Join Our Community

    The OpenSPG community thrives on collective wisdom and the shared mission of advancing open-source technology. We warmly invite you to contribute, share your insights, and collaborate on exciting projects. For more details about this release and user guides, please visit our official website.

    Thank you for your continued support and enthusiasm for OpenSPG! If you have questions or suggestions, feel free to reach out through our community channels or via email.


    Version 0.7.1 (2025-04-25)

    亲爱的开源社区伙伴们,非常高兴地宣布 OpenSPG/KAG 发布了最新版本 0.7.1!这一版本是我们的技术团队与社区开发者们共同努力的成果,其目标旨在提升用户体验、优化性能,并解决用户反馈的若干问题。以下是本次版本更新的核心内容概要:

    🛠️ 问题修复 & 功能优化

    1. 修复源码编译问题:解决 openspg 编译时可能遇到的 NoSuchBeanDefinitionException 报错问题,确保开发者可以顺利构建项目。
    2. 诊断优化:解决 vectorizer 调用超时异常信息无法透出的问题,帮助用户快速定位故障原因。
    3. 任务性能提升:优化小任务构建耗时,将任务调度间隔调整为更高效的频率,同时确保异步任务在无需等待的条件下立即触发。
    4. 镜像稳定性提升:解决镜像重启时调度状态异常卡死的问题,增强运行环境的稳定性。
    5. 推理问答流式输出优化:显著改善推理问答场景中流式输出的慢速和卡顿问题,提供更流畅的用户体验。
    6. 任务详情页面增强:新增日志自动刷新功能和任务耗时统计,帮助用户实时监控系统状态和任务性能。
    7. 构建任务切分调整:下线语义化切分的选项,避免误操作带来的大量tokens 消耗
    8. 官网功能更新:为官网主页新增合作伙伴信息板块,同时添加 OpenKG 官网跳转链接以促进资源共享。
    9. Bug修复和产品优化:针对社区反馈的问题做出多项功能修复与细节优化,提高整体产品的稳定性。

    🌟 加入我们的社区

    我们的开源社区凝聚了多方智慧,推动了开源技术的发展。我们诚挚邀请您参与项目的共建,共同探索更优秀的解决方案。有关本次更新的更多信息和操作指南,请访问 官网。

    感谢您对 OpenSPG 的关注和支持!如果有任何问题或建议,欢迎通过社区或邮件与我们联系。

  3. v0.7Version 0.72025-04-17 · 2025-04-17 10:07 UTC
    查看更新说明

    Version 0.7 (2025-04-17)

    1、Overview

    We are very pleased to announce the release of KAG 0.7. This update continues our commitment to increasing the consistency, rigor, and precision of large language models leveraging external knowledge bases, while introducing several important new features.

    Firstly, we have completely refactored the framework. The update adds support for both static and iterative task planning modes, along with a more rigorous hierarchical knowledge mechanism during the reasoning phase. Additionally, the new multi-executor extension mechanism and MCP protocol integration enable horizontal scaling of various symbolic solvers (such as math-executor and cypher-executor). These improvements not only help users quickly build knowledge-augmented applications to validate innovative ideas or domain-specific solutions, but also support continuous optimization of KAG Solver's capabilities, thereby further enhancing reasoning rigor in vertical applications.

    Secondly, we have comprehensively optimized the product experience: during the reasoning phase, we introduced dual modes "Simple Mode" and "Deep Reasoning" and added support for streaming reasoning output, significantly reducing user wait times. Particularly noteworthy is the introduction of the "Lightweight Construction" mode to better facilitate the large-scale business application of KAG and address the community's most pressing concern about high knowledge construction costs. As shown in the KAG-V0.7LC column of Figure 1, we tested a hybrid approach where a 7B model handles knowledge construction and a 72B model handles knowledge-based question answering. The results on the two_wiki, hotpotqa, and musique benchmarks showed only minor declines of 1.20%, 1.90%, and 3.11%, respectively. However, the token cost(Refer to Aliyun Bailian pricing)for constructing a 100,000-character document was reduced from 4.63¥ to 0.479¥, a 89% reduction, which substantially saves users both time and financial costs. Additionally, we will release a KAG-specific extraction model and a distributed offline batch construction version, continuously compressing model size and improving construction throughput to achieve daily construction capabilities for millions or even tens of millions of documents in a single scenario.

    Finally, to better promote business applications, technological advancement, and community exchange for knowledge-augmented LLMs, we have added an open_benchmark directory at the root level of the KAG repository. This directory includes reproduction methods for various datasets to help users replicate and improve KAG's performance across different tasks. Moving forward, we will continue to expand with more vertical scenario task datasets to provide users with richer resources.

    Beyond these framework and product optimizations, we've fixed several bugs in both reasoning and construction phases. This update uses Qwen2.5-72B as the base model, completing effect alignment across various RAG frameworks and partial KG datasets. For overall benchmark results, please refer to Figures 1 and 2, with detailed rankings available in the open_benchmark section.

    Figure1. Performance of KAG V0.7 and baselines on Multi-hop QA benchmarks

    _Figure2. Performance of KAG V0.7 and baselines(from OpenKG OneEval) on _Knowledge based QA benchmarks

    2、Framework Enhancements

    2.1、Hybrid Static-Dynamic Task Planning

    This release introduces optimizations to the KAG-Solver framework implementation, providing more flexible architectural support for: "Retrieval during reasoning" workflows, Multi-scenario algorithm experimentation, LLM-symbolic engine integration (via MCP protocol).

    The fr

  4. v0.6Version 0.62025-01-08 · 2025-01-08 03:50 UTC
    查看更新说明

    Version 0.6 (2025-01-07)

    On January 7, 2025, OpenSPG officially released version 0.6, bringing updates across multiple areas, including domain knowledge mounting, vertical domain schema management, visual knowledge exploration, and support for summary generation tasks. In terms of user experience, it offers a mechanism for resuming knowledge base tasks from breakpoints, introduces a user login and permission system, and optimizes task scheduling for building processes. In developer mode, it supports configuring different models for different stages and enables schema-constraint mode for extraction, significantly enhancing the system's flexibility, usability, performance, and security. This release provides users with a more powerful knowledge management platform that adapts to diverse application scenarios.


    🌟 New Features

    1. Support for Summary Generation Tasks

      • Native support for abstractive summarization tasks without sacrificing multi-hop factual reasoning accuracy. On the CSQA dataset, while comprehensiveness, diversity, and empowerment metrics are slightly lower than LightRAG (-1.2/10), the factual accuracy metric is better than LightRAG (+0.1/10). On multi-hop question answering datasets such as HotpotQA, TwoWiki, and MuSiQue, since LightRAG and GraphRAG do not provide a factual QA evaluation entry, the EM metric using the default entry is close to 0. For quantitative evaluation results, please refer to the KAG code repository under examples/csqa/README.md and follow the steps to reproduce.
    2. Domain Schema Management

      • The product provides SPG schema management capabilities, allowing users to optimize knowledge base construction and inference Q&A performance by customizing schemas.
    3. Knowledge Exploration

      • Added a knowledge exploration feature to enable visual query and analysis of knowledge base data, and provided an HTTP API for integration with other systems.
    4. Support for Mounting Domain Knowledge in KAG-Builder(Developer Mode)

      • In developer mode, the system supports injecting domain knowledge (domain vocabulary, relationships between terms) into the knowledge base, which can significantly improve knowledge base construction and inference Q&A performance (with a 10%+ improvement in the medical domain).
    5. Adding Knowledge Alignment Component to the KAG-Builder Pipeline

      • Kag-Builder provides a default knowledge alignment component that includes features such as filtering out invalid data and linking similar entities. This optimizes the structure and data quality of the graph.

    ⚙️ User Experience Optimizations

    1. Resumable Tasks

      • Provide resumable capabilities for knowledge base construction tasks at the file level and chunk level in both product mode and developer mode, to reduce the time and token consumption caused by full re-runs after task failures.
    2. User Login & Permission System

      • Implement a user login and permission system to prevent unauthorized access and operations on the knowledge base data.
    3. Optimized Knowledge Base Construction Task Scheduling

      • Provide database-based knowledge base construction task scheduling to avoid task anomalies or interruptions after container restarts.
    4. Support for Configuring Different Models at Different Stages (Developer Mode)

      • The system provides a component management mechanism based on a registry, allowing users to instantiate component objects via configuration files. This supports users in developing and embedding custom components into the KAG-Builder and KAG-Solver workflows. Additionally, it enables the configuration of different-sized models at different stages of the workflow, thereby enhancing the overall reasoning and question-answering performance.
    5. Optimization of Layout Analysis for Markdown, PDF, and Word Files

      • For Markdown, PDF, and Word files, the system prioritizes dividing the content into chunk
  5. v0.5.1Version 0.5.12024-11-21 · 2024-11-21 12:11 UTC
    查看更新说明

    Version 0.5.1 (2024-11-21)

    OpenSPG released version v0.5.1 on November 21, 2024. This version focuses on addressing user feedback and introduces a series of new features and user experience optimizations.


    🌟 New Features

    1. Support for Word Documents

      • Users can now directly upload .doc or .docx files to streamline the knowledge base construction process.
    2. New Project Deletion API

      • Quickly clear and delete projects and related data through an API, compatible with the latest Neo4j image version.
    3. Model Call Concurrency Setting

      • Added the builder.model.execute.num parameter, with a default concurrency of 5, to improve efficiency in large-scale knowledge base construction.
    4. Improved Logging

      • Added a startup success marker in the logs to help users quickly verify if the service is running correctly.

    ⚙️ User Experience Optimizations

    1. Neo4j Memory Overflow Issues
      • Addressed memory overflow problems in Neo4j during large-scale data processing, ensuring stable operation for extensive datasets.
    2. Concurrent Neo4j Query Execution Issues
      • Optimized execution strategies to resolve Graph Data Science (GDS) library conflicts or failures in high-concurrency scenarios.
    3. Schema Preview Prefix Issue
      • Fixed issues where extracted schema preview entities lacked necessary prefixes, ensuring consistency between extracted entities and predefined schemas.
    4. Default Neo4j Password for Project Creation/Modification
      • Automatically fills a secure default password if none is specified during project creation or modification, simplifying the configuration process.
    5. Frontend Bug Fixes
      • Resolved issues with JS dependencies relying on external addresses and embedded all frontend files into the image. Improved the knowledge base management interface for a smoother user experience.
    6. Empty Node/Edge Type in Neo4j Writes
      • Enhanced writing logic to handle empty node or edge types during knowledge graph construction, preventing errors or data loss in such scenarios.

    Version 0.5.1 (2024-11-21)

    OpenSPG 在 2024 年 11 月 21 日发布了 v0.5.1 版本。此版本重点解决了用户反馈的问题,并带来了一系列新功能和用户体验的优化。

    🌟 新增功能

    1. 支持 word 文档的构建

      • 用户现可通过知识库管理页面直接上传 .doc 或 .docx 后缀的文件,进行知识库的构建流程。这一更新使得知识内容的导入更加便捷,提高效率。
    2. 提供项目删除接口

      • 为了帮助用户更高效地管理项目,我们新增了一个项目删除接口。用户可以通过访问 http://127.0.0.1:8887/project/api/delete?projectId=xx 完成项目的快速清空与删除操作。该接口会同步清理项目下的所有schema、知识库任务、知识库问答任务以及关联的 Neo4j 数据库。 Tips:使用此功能前,需确保已将 openspg-neo4j 镜像更新至最新版本
    3. 支持模型调用并发度设置

      • 在大规模知识库构建过程中,为了提高构建效率,我们引入了模型调用的并发控制机制。用户可以通过设置 builder.model.execute.num 参数来调整并发数量,默认值设定为5。这有助于避免因模型服务性能瓶颈而导致的任务失败或系统卡顿。
    4. 日志中添加启动成功标识

      • 为了让用户能够更直观地判断 OpenSPG 服务是否启动成功,我们在日志输出中加入了明确的启动成功标识。openspg-server 成功启动后,会输出这一标识。

    ⚙️ 用户体验优化

    1. 解决大规模数据构建下 Neo4j 调用内存超限问题
      • 针对在处理大规模数据集时出现的 Neo4j 内存溢出问题,我们进行了深入分析并实施了有效的解决方案。现在,面对大规模数据集Neo4j 能保持稳定运行,有效防止了因内存不足而导致的服务中断。
    2. 解决多并发下执行 Neo4j 查询导致的 GDS 加载问题
      • 在多并发场景下执行 Neo4j 查询时,图数据科学 (GDS) 库的加载会出现冲突或失败的情况。为此,我们优化了查询执行策略,确保了在高并发环境下的查询性能和稳定性。
    3. 解决抽取结果 Schema 预览实体无前缀问题
      • 在之前版本中,部分用户反馈在查看抽取结果的 Schema 预览时,实体名称缺少必要的前缀信息导致抽取的实体和预定义的Schema不一致。此次更新修正了这一问题,保证了所有实体名称的完整性和准确性。
    4. 创建修改项目时 Neo4j 无密码时填充默认值
      • 当用户在创建或修改项目时,如果未指定

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    KAG: Knowledge Augmented Generation

    1. What is KAG?

    KAG is a logical reasoning and Q&A framework based on the OpenSPG engine and large language models, which is used to build logical reasoning and Q&A solutions for vertical domain knowledge bases. KAG can effectively overcome the ambiguity of traditional RAG vector similarity calculation and the noise problem of GraphRAG introduced by OpenIE. KAG supports logical reasoning and multi-hop fact Q&A, etc., and is significantly better than the current SOTA method.

    The goal of KAG is to build a knowledge-enhanced LLM service framework in professional domains, supporting logical reasoning, factual Q&A, etc. KAG fully integrates the logical and factual characteristics of the KGs. Its core features include:

    • Knowledge and Chunk Mutual Indexing structure to integrate more complete contextual text information
    • Knowledge alignment using conceptual semantic reasoning to alleviate the noise problem caused by OpenIE
    • Schema-constrained knowledge construction to support the representation and construction of domain expert knowledge
    • Logical form-guided hybrid reasoning and retrieval to support logical reasoning and multi-hop reasoning Q&A

    ⭐️ Star our repository to stay up-to-date with exciting new features and improvements! Get instant notifications for new releases! 🌟

    Star KAG

    2. Core Features

    2.1 Knowledge Representation

    In the context of private knowledge bases, unstructured data, structured information, and business expert experience often coexist. KAG references the DIKW hierarchy to upgrade SPG to a version that is friendly to LLMs.

    For unstructured data such as news, events, logs, and books, as well as structured data like transactions, statistics, and approvals, along with business experience and domain knowledge rules, KAG employs techniques such as layout analysis, knowledge extraction, property normalization, and semantic alignment to integrate raw business data and expert rules into a unified business knowledge graph.

    KAG Diagram

    This makes it compatible with schema-free information extraction and schema-constrained expertise construction on the same knowledge type (e. G., entity type, event type), and supports the cross-index representation between the graph structure and the original text block.

    This mutual index representation is helpful to the construction of inverted index based on graph structure, and promotes the unified representation and reasoning of logical forms.

    2.2 Mixed Reasoning Guided by Logic Forms

    Logical Form Solver

    KAG proposes a logically formal guided hybrid solution and inference engine.

    The engine includes three types of operators: planning, reasoning, and retrieval, which transform natural language problems into problem solving processes that combine language and notation.

    In this process, each step can use different operators, such as exact match retrieval, text retrieval, numerical calculation or semantic reasoning, so as to realize the integration of four different problem solving processes: Retrieval, Knowledge Graph reasoning, language reasoning and numerical calculation.

    3. Release Notes

    3.1 Latest Updates

    • 2025.06.27 : Released KAG 0.8.0 Version
      • Expanded two modes: Private Knowledge Base (including structured & unstructured data) and Public Network Knowledge Base, supporting integration of LBS, WebSearch, and other public data sources via MCP protocol.
      • Enhanced Private Knowledge Base indexing capabilities, with built-in fundamental index types such as Outline, Summary, KnowledgeUnit, AtomicQuery, Chunk, and Table.
      • Decoupled knowledge bases from applications: Knowledge Bases manage private data (structured & unstructured) and public data; Applications can associate with multiple knowledge bases and automatically adapt corresponding retrievers for data recall based on index types established during knowledge base construction.
      • Fully embraced MCP, enabling KAG-powered inference QA (via MCP protocol) within agent workflows.
      • Completed adaptation for the KAG-Thinker model. Through optimizations in breadth-wise problem decomposition, depth-wise solution derivation, knowledge boundary determination, and noise-resistant retrieval results, the framework's reasoning paradigm stability and logical rigor have been improved under the guidance of multi-round iterative thinking frameworks.
    • 2025.04.17 : Released KAG 0.7 Version
      • First, we refactored the KAG-Solver framework. Added support for two task planning modes, static and iterative, while implementing a more rigorous knowledge layering mechanism for the reasoning phase.
      • Second, we optimized the product experience: introduced dual modes—"Simple Mode" and "Deep Reasoning"—during the reasoning phase, along with support for streaming inference output, automatic rendering of graph indexes, and linking generated content to original references.
      • Added an open_benchmark directory to the top level of the KAG repository, comparing various RAG methods under the same base to achieve state-of-the-art (SOTA) results.
      • Introduced a "Lightweight Build" mode, reducing knowledge construction token costs by 89%.
    • 2025.01.07 : Support domain knowledge injection, domain schema customization, QFS tasks support, Visual query analysis, enables schema-constraint mode for extraction, etc.
    • 2024.11.21 : Support Word docs upload, model invoke concurrency setting, User experience optimization, etc.
    • 2024.10.25 : KAG initial release

    3.2 Future Plans

    • We will continue to focus on enhancing large models' ability to leverage external knowledge bases. Our goal is to achieve bidirectional enhancement and seamless integration between large models and symbolic knowledge, improving the factuality, rigor, and consistency of reasoning and Q&A in professional scenarios. We will also keep releasing updates to push the boundaries of capability and drive adoption in vertical domains.

    4. Quick Start

    4.1 product-based (for ordinary users)

    4.1.1 Engine & Dependent Image Installation

    • Recommend System Version:

      macOS User:macOS Monterey 12.6 or later
      Linux User:CentOS 7 / Ubuntu 20.04 or later
      Windows User:Windows 10 LTSC 2021 or later
      
    • Software Requirements:

      macOS / Linux User:Docker,Docker Compose
      Windows User:WSL 2 / Hyper-V,Docker,Docker Compose
      

    Use the following commands to download the docker-compose.yml file and launch the services with Docker Compose.

    # set the HOME environment variable (only Windows users need to execute this command)
    # set HOME=%USERPROFILE%
    
    curl -sSL https://raw.githubusercontent.com/OpenSPG/openspg/refs/heads/master/dev/release/docker-compose-west.yml -o docker-compose-west.yml
    docker compose -f docker-compose-west.yml up -d
    

    4.1.2 Use the product

    Navigate to the default url of the KAG product with your browser: http://127.0.0.1:8887

    Default Username: openspg
    Default password: openspg@kag
    

    See KAG usage (product mode) for detailed introduction.

    4.2 toolkit-based (for developers)

    4.2.1 Engine & Dependent Image Installation

    Refer to the 3.1 section to complete the installation of the engine & dependent image.

    4.2.2 Installation of KAG

    macOS / Linux developers

    # Create conda env: conda create -n kag-demo python=3.10 && conda activate kag-demo
    
    # Clone code: git clone https://github.com/OpenSPG/KAG.git
    
    # Install KAG: cd KAG && pip install -e .
    

    Windows developers

    # Install the official Python 3.10 or later, install Git.
    
    # Create and activate Python venv: py -m venv kag-demo && kag-demo\Scripts\activate
    
    # Clone code: git clone https://github.com/OpenSPG/KAG.git
    
    # Install KAG: cd KAG && pip install -e .
    

    4.2.3 Use the toolkit

    Please refer to KAG usage (developer mode) guide for detailed introduction of the toolkit. Then you can use the built-in components to reproduce the performance results of the built-in datasets, and apply those components to new busineness scenarios.

    5. Technical Architecture

    KAG technical architecture

    The KAG framework includes three parts: kg-builder, kg-solver, and kag-model. This release only involves the first two parts, kag-model will be gradually open source release in the future.

    kg-builder implements a knowledge representation that is friendly to large-scale language models (LLM). Based on the hierarchical structure of DIKW (data, information, knowledge and wisdom), IT upgrades SPG knowledge representation ability, and is compatible with information extraction without schema constraints and professional knowledge construction with schema constraints on the same knowledge type (such as entity type and event type), it also supports the mutual index representation between the graph structure and the original text block, which supports the efficient retrieval of the reasoning question and answer stage.

    kg-solver uses a logical symbol-guided hybrid solving and reasoning engine that includes three types of operators: planning, reasoning, and retrieval, to transform natural language problems into a problem-solving process that combines language and symbols. In this process, each step can use different operators, such as exact match retrieval, text retrieval, numerical calculation or semantic reasoning, so as to realize the integration of four different problem solving processes: Retrieval, Knowledge Graph reasoning, language reasoning and numerical calculation.

    6. Community & Support

    GitHub: https://github.com/OpenSPG/KAG

    Website: https://openspg.github.io/v2/docs_en

    Discord

    Join our Discord community.

    WeChat

    Follow OpenSPG Official Account to get technical articles and product updates about OpenSPG and KAG.

    Scan the QR code below to join our WeChat group.

    7. Differences between KAG, RAG, and GraphRAG

    KAG introduction and applications: https://github.com/orgs/OpenSPG/discussions/52

    8. Citation

    If you use this software, please cite it as below:

    @article{liang2024kag,
      title={KAG: Boosting LLMs in Professional Domains via Knowledge Augmented Generation},
      author={Liang, Lei and Sun, Mengshu and Gui, Zhengke and Zhu, Zhongshu and Jiang, Zhouyu and Zhong, Ling and Zhao, Peilong and Bo, Zhongpu and Yang, Jin and others},
      journal={arXiv preprint arXiv:2409.13731},
      year={2024}
    }
    
    @article{yikgfabric,
      title={KGFabric: A Scalable Knowledge Graph Warehouse for Enterprise Data Interconnection},
      author={Yi, Peng and Liang, Lei and Da Zhang, Yong Chen and Zhu, Jinye and Liu, Xiangyu and Tang, Kun and Chen, Jialin and Lin, Hao and Qiu, Leijie and Zhou, Jun}
    }
    

    License

    Apache License 2.0

    KAG Core Team

    Lei Liang, Mengshu Sun, Zhengke Gui, Zhongshu Zhu, Zhouyu Jiang, Ling Zhong, Peilong Zhao, Zhongpu Bo, Jin Yang, Huaidong Xiong, Lin Yuan, Jun Xu, Zaoyang Wang, Zhiqiang Zhang, Wen Zhang, Huajun Chen, Wenguang Chen, Jun Zhou, Haofen Wang