# KAG

> Open-source logical-form-guided reasoning and retrieval framework built on the OpenSPG engine and LLMs for professional-domain knowledge base Q&A.

KAG (Knowledge Augmented Generation) is an open-source framework from the OpenSPG project for building logical reasoning and factual question-answering solutions over vertical-domain knowledge bases. It combines the OpenSPG knowledge graph engine with large language models. The latest release listed in the repository is v0.8.0, published in June 2025.

## What It Is

KAG is a knowledge-enhanced LLM service framework for professional domains. The README says it aims to overcome the ambiguity of vector-similarity retrieval in traditional RAG and the noise that OpenIE introduces into GraphRAG. It supports logical reasoning and multi-hop fact Q&A over private knowledge bases that mix unstructured data, structured data, and expert rules.

## How It Works

The framework has three parts: kg-builder, kg-solver, and kag-model. Only kg-builder and kg-solver are covered by the release described in the README.

- **kg-builder** builds an LLM-friendly knowledge representation based on the DIKW hierarchy. It uses layout analysis, knowledge extraction, property normalization, and semantic alignment to turn raw data and expert rules into a unified knowledge graph. It supports schema-free extraction and schema-constrained construction, with mutual indexing between graph structure and source text chunks.
- **kg-solver** is a logical-form-guided hybrid reasoning engine. Planning, reasoning, and retrieval operators turn natural-language questions into solving steps that can use exact-match retrieval, text retrieval, numerical calculation, or semantic reasoning.

## Update: Version 0.8.0

The 0.8.0 release, dated 2025-06-27 in the README, adds private and public-network knowledge base modes, and public data sources such as LBS and web search can be integrated through MCP. Built-in index types include Outline, Summary, KnowledgeUnit, AtomicQuery, Chunk, and Table. Knowledge bases are now decoupled from applications, and KAG-powered inference Q&A can run inside agent workflows over MCP. The release also adapts the KAG-Thinker model. Version 0.7 added static and iterative task planning, Simple and Deep Reasoning modes, streaming output, and a Lightweight Build mode, which the README says cuts knowledge-construction token cost by 89%.

## Setup Path

Users can run the product mode by launching the engine and dependent images with Docker Compose and opening the web UI at a local address. Developers can instead install the toolkit with pip from a cloned repository on Python 3.10 or later. The project is licensed under Apache 2.0.

## Features
- Logical-form-guided hybrid reasoning and retrieval
- Multi-hop fact Q&A
- Knowledge and chunk mutual indexing
- Schema-constrained knowledge construction
- Conceptual semantic alignment to reduce OpenIE noise
- Built-in index types (Outline, Summary, KnowledgeUnit, AtomicQuery, Chunk, Table)
- Private and public-network knowledge base modes
- MCP support for agent workflows
- Simple and Deep Reasoning modes with streaming output
- Lightweight Build mode
- Docker Compose product mode and pip-installable developer toolkit

## Integrations
OpenSPG, MCP, Docker Compose

## Platforms
WINDOWS, MACOS, LINUX, WEB, CLI

## Pricing
Open Source

## Version
v0.8.0

## Links
- Website: https://spg.openkg.cn/en-US
- Documentation: https://openspg.yuque.com/ndx6g9/docs_en
- Repository: https://github.com/OpenSPG/KAG
- EveryDev.ai: https://www.everydev.ai/tools/kag
