SuperAPI AI Directory

KAG

KAG is a knowledge-enhanced generation framework based on OpenSPG engine, which is used to build knowledge-enhanced rigorous decision-making and information retrieval knowledge services.

Open website

About this tool

What Is KAG

KAG (Knowledge Augmented Generation) is a logical reasoning and question answering framework based on the OpenSPG engine and large language models, used to build logical reasoning and factual question answering solutions for vertical-domain knowledge bases. KAG can effectively overcome the ambiguity of traditional RAG vector similarity computation, as well as the noise problem introduced by GraphRAG due to OpenIE. KAG supports logical reasoning and multi-hop factual question answering, etc., and significantly outperforms current SOTA methods.

KAG's goal is to build an LLM service framework enhanced by professional-domain knowledge, supporting logical reasoning, factual question answering, etc. KAG fully integrates the logical and factual characteristics of knowledge graphs, and its core features include:

  • A mutual indexing structure between knowledge and chunks, integrating more complete contextual text information
  • Knowledge alignment using conceptual semantic reasoning, alleviating the noise problem introduced by OpenIE
  • Schema-constrained knowledge construction, supporting the representation and construction of domain expert knowledge
  • Logical-form-guided hybrid reasoning and retrieval, supporting logical reasoning and multi-hop reasoning question answering

Core Features

Knowledge Representation

In private knowledge base scenarios, unstructured data, structured information, and business expert experience often coexist. Referring to the DIKW hierarchy, KAG upgrades SPG to an LLM-friendly version.

For unstructured data such as news, events, logs, and books, as well as structured data such as transactions, statistics, and approvals, combined with business experience and domain knowledge rules, KAG adopts techniques such as layout analysis, knowledge extraction, attribute normalization, and semantic alignment to integrate raw business data and expert rules into a unified business knowledge graph. This makes it possible for schema-free information extraction and schema-constrained expert knowledge construction on the same knowledge type (such as entity types and event types) to be compatible, and supports cross-indexed representation between graph structures and raw text chunks. This mutual indexing representation helps build an inverted index based on graph structures and facilitates the unified representation and reasoning of logical forms.

Logical-Form-Guided Hybrid Reasoning

KAG proposes a logical-form-guided hybrid solving and reasoning engine. This engine contains three types of operators: planning, reasoning, and retrieval, transforming natural language questions 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 computation, or semantic reasoning, thereby achieving the integration of four different problem-solving processes: retrieval, knowledge graph reasoning, language reasoning, and numerical computation.

Release Notes

Latest Updates

2025.06.27: Released KAG version 0.8.0

  • Expanded two modes: private knowledge base (including structured and unstructured data) and public knowledge base, supporting the integration of public data sources such as LBS and WebSearch through the MCP protocol.
  • Enhanced the indexing capability of private knowledge bases, with built-in basic index types such as Outline, Summary, KnowledgeUnit, AtomicQuery, Chunk, and Table.
  • Decoupled knowledge bases from applications: knowledge bases manage private data (structured and unstructured) and public data; applications can be associated with multiple knowledge bases and automatically adapt to the corresponding retriever for data recall based on the index types established when the knowledge base was built.
  • Fully embraces MCP, allowing KAG-driven reasoning question answering to be used in agent workflows through the MCP protocol.
  • Completed adaptation of the KAG-Thinker model. Through optimizations such as breadth-based problem decomposition, depth-based solution derivation, knowledge boundary determination, and noise-resistant retrieval results, under the guidance of a multi-round iterative thinking framework, the stability and logical rigor of the framework's reasoning paradigm were improved.

2025.04.17: Released KAG version 0.7

  • Refactored the KAG-Solver framework. Added support for two task planning modes, static and iterative, and implemented a more rigorous knowledge layering mechanism during the reasoning stage.
  • Optimized product experience: introduced "simple mode" and "deep reasoning" dual modes during the reasoning stage, supporting streaming reasoning output, automatic graph index rendering, and generated content with original citation links.
  • Added an open_benchmark directory at the top level of the KAG repository to compare multiple RAG methods under the same base, achieving state-of-the-art (SOTA) results.
  • Introduced a "lightweight construction" mode, reducing the token cost of knowledge construction by 89%.

2025.01.07: Support for domain knowledge injection, domain schema customization, QFS task support, visual query analysis, and schema-constrained mode for extraction, etc.

2024.11.21: Support for Word document upload, model invocation concurrency settings, user experience optimization, etc.

2024.10.25: KAG's first release.

Future Plans

KAG will continue to focus on enhancing the ability of large models to utilize external knowledge bases. The goal is to achieve bidirectional enhancement and seamless integration between large models and symbolic knowledge, improve the factuality, rigor, and consistency of reasoning and question answering in professional scenarios, and continue to release updates to promote capability boundaries and adoption in vertical domains.

Usage

For General Users (Product Mode)

Engine and Dependency Image Installation

Recommended system versions:

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

Software requirements:

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

Use the following command to download the docker-compose.yml file and start the service with Docker Compose.

Using the Product

Use a browser to access the default address of the KAG product:http://127.0.0.1:8887

For detailed instructions, see KAG Usage (Product Mode).

For Developers (Toolkit Mode)

Engine and Dependency Image Installation

Refer to Section 3.1 to complete the installation of the engine and dependency image.

Install KAG

macOS / Linux developers and Windows developers should install according to the corresponding method.

Use the Toolkit

For detailed instructions, refer to the KAG Usage (Developer Mode) guide. Afterward, you can use the built-in components to reproduce the performance results of the built-in datasets and apply these components to new business scenarios.

Technical Architecture

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

kg-builder implements a knowledge representation friendly to large language models (LLMs). Based on the DIKW (Data, Information, Knowledge, Wisdom) hierarchy, it enhances the SPG knowledge representation capability, is compatible with both schema-free information extraction and schema-constrained professional knowledge construction on the same knowledge type (such as entity type and event type), and also supports mutual indexing representation between graph structures and original text chunks, providing support for efficient retrieval in the reasoning question answering stage.

kg-solver adopts a hybrid solving and reasoning engine guided by logical symbols, including three types of operators: planning, reasoning, and retrieval, transforming natural language questions 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 computation, or semantic reasoning, thereby achieving the fusion of four different problem-solving processes: retrieval, knowledge graph reasoning, language reasoning, and numerical computation.

Community and Support

  • GitHub:https://github.com/OpenSPG/KAG
  • Website:https://openspg.github.io/v2/docs_en
  • Join the Discord community.
  • Follow the official OpenSPG account to get technical articles and product updates for OpenSPG and KAG.
  • Scan the QR code to join the WeChat group.

Differences Between KAG, RAG, and GraphRAG

KAG Introduction and Applications:https://github.com/orgs/OpenSPG/discussions/52

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

KAG: Boosting LLMs in Professional Domains via Knowledge Augmented Generation

KGFabric: A Scalable Knowledge Graph Warehouse for Enterprise Data Interconnection

Apache License 2.0

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

KAG is a logical-form-guided reasoning and retrieval framework based on the OpenSPG engine and large language models, used to build logical reasoning and factual question answering solutions for professional domain knowledge bases, and can effectively overcome the shortcomings of traditional RAG vector similarity computation models.