[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-71979":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":25,"hasPages":23,"topics":26,"createdAt":10,"pushedAt":10,"updatedAt":32,"readmeContent":33,"aiSummary":34,"trendingCount":16,"starSnapshotCount":16,"syncStatus":35,"lastSyncTime":36,"discoverSource":37},71979,"KAG","OpenSPG\u002FKAG","OpenSPG","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.","https:\u002F\u002Fspg.openkg.cn\u002Fen-US",null,"Python",8815,684,73,163,0,4,18,84,12,39.51,"Apache License 2.0",false,"master",true,[27,28,29,30,31],"knowledge-graph","large-language-model","logical-reasoning","multi-hop-question-answering","trustfulness","2026-06-12 02:02:56","# KAG: Knowledge Augmented Generation\n\n\u003Cdiv align=\"center\">\n\u003Ca href=\"https:\u002F\u002Fspg.openkg.cn\u002Fen-US\">\n\u003Cimg src=\".\u002F_static\u002Fimages\u002FOpenSPG-1.png\" width=\"520\" alt=\"openspg logo\">\n\u003C\u002Fa>\n\u003C\u002Fdiv>\n\n\u003Cp align=\"center\">\n  \u003Ca href=\".\u002FREADME.md\">English\u003C\u002Fa> |\n  \u003Ca href=\".\u002FREADME_cn.md\">简体中文\u003C\u002Fa> |\n  \u003Ca href=\".\u002FREADME_ja.md\">日本語版ドキュメント\u003C\u002Fa>\n\u003C\u002Fp>\n\n\u003Cp align=\"center\">\n    \u003Ca href='https:\u002F\u002Farxiv.org\u002Fpdf\u002F2409.13731'>\u003Cimg src='https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FarXiv-2409.13731-b31b1b'>\u003C\u002Fa>\n    \u003Ca href=\"https:\u002F\u002Fgithub.com\u002FOpenSPG\u002FKAG\u002Freleases\u002Flatest\">\n        \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Fv\u002Frelease\u002FOpenSPG\u002FKAG?color=blue&label=Latest%20Release\" alt=\"Latest Release\">\n    \u003C\u002Fa>\n    \u003Ca href=\"https:\u002F\u002Fopenspg.yuque.com\u002Fndx6g9\u002Fdocs_en\">\n        \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FUser%20Guide-1e8b93?logo=readthedocs&logoColor=f5f5f5\" alt=\"User Guide\">\n    \u003C\u002Fa>\n    \u003Ca href=\"https:\u002F\u002Fgithub.com\u002FOpenSPG\u002FKAG\u002Fblob\u002Fmain\u002FLICENSE\">\n        \u003Cimg height=\"21\" src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-Apache--2.0-ffffff?labelColor=d4eaf7&color=2e6cc4\" alt=\"license\">\n    \u003C\u002Fa>\n    \u003Ca href=\"https:\u002F\u002Fdeepwiki.com\u002FLike0x\u002FKAG\">\u003Cimg src=\"https:\u002F\u002Fdeepwiki.com\u002Fbadge.svg\" alt=\"Ask DeepWiki\">\u003C\u002Fa>\n\u003C\u002Fp>\n\u003Cp align=\"center\">\n   \u003Ca href=\"https:\u002F\u002Fdiscord.gg\u002FPURG77zhQ7\">\n        \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fdiscord\u002F1329648479709958236?style=for-the-badge&logo=discord&label=Discord\" alt=\"Discord\">\n   \u003C\u002Fa>\n\u003C\u002Fp>\n\n# 1. What is KAG?\n\nKAG is a logical reasoning and Q&A framework based on the [OpenSPG](https:\u002F\u002Fgithub.com\u002FOpenSPG\u002Fopenspg) 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.\n\nThe 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:\n\n- Knowledge and Chunk Mutual Indexing structure to integrate more complete contextual text information\n- Knowledge alignment using conceptual semantic reasoning to alleviate the noise problem caused by OpenIE\n- Schema-constrained knowledge construction to support the representation and construction of domain expert knowledge\n- Logical form-guided hybrid reasoning and retrieval to support logical reasoning and multi-hop reasoning Q&A\n\n⭐️ Star our repository to stay up-to-date with exciting new features and improvements! Get instant notifications for new releases! 🌟\n\n![Star KAG](.\u002F_static\u002Fimages\u002Fstar-kag.gif)\n\n# 2. Core Features\n\n## 2.1 Knowledge Representation\n\nIn 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. \n\nFor 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.\n\n![KAG Diagram](.\u002F_static\u002Fimages\u002Fkag-diag.jpg)\n\nThis 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. \n\nThis 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.\n\n## 2.2 Mixed Reasoning Guided by Logic Forms\n\n![Logical Form Solver](.\u002F_static\u002Fimages\u002Fkag-lf-solver.png)\n\nKAG proposes a logically formal guided hybrid solution and inference engine. \n\nThe engine includes three types of operators: planning, reasoning, and retrieval, which transform natural language problems into problem solving processes that combine language and notation. \n\nIn 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.\n\n# 3. Release Notes\n\n## 3.1 Latest Updates\n* 2025.06.27 : Released KAG 0.8.0 Version \n  * 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.\n  * Enhanced Private Knowledge Base indexing capabilities, with built-in fundamental index types such as Outline, Summary, KnowledgeUnit, AtomicQuery, Chunk, and Table.\n  * 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.\n  * Fully embraced MCP, enabling KAG-powered inference QA (via MCP protocol) within agent workflows.\n  * 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. \n* 2025.04.17 : Released KAG 0.7 Version \n  * 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. \n  * 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. \n  * 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. \n  * Introduced a \"Lightweight Build\" mode, reducing knowledge construction token costs by 89%.\n* 2025.01.07 : Support domain knowledge injection, domain schema customization, QFS tasks support, Visual query analysis, enables schema-constraint mode for extraction, etc.\n* 2024.11.21 : Support Word docs upload, model invoke concurrency setting, User experience optimization, etc.\n* 2024.10.25 : KAG initial release\n\n## 3.2 Future Plans\n\n* 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.\n\n# 4. Quick Start\n\n## 4.1 product-based (for ordinary users)\n\n### 4.1.1 Engine & Dependent Image Installation\n\n* **Recommend System Version:**\n\n  ```text\n  macOS User：macOS Monterey 12.6 or later\n  Linux User：CentOS 7 \u002F Ubuntu 20.04 or later\n  Windows User：Windows 10 LTSC 2021 or later\n  ```\n\n* **Software Requirements:**\n\n  ```text\n  macOS \u002F Linux User：Docker，Docker Compose\n  Windows User：WSL 2 \u002F Hyper-V，Docker，Docker Compose\n  ```\n\nUse the following commands to download the docker-compose.yml file and launch the services with Docker Compose.\n\n```bash\n# set the HOME environment variable (only Windows users need to execute this command)\n# set HOME=%USERPROFILE%\n\ncurl -sSL https:\u002F\u002Fraw.githubusercontent.com\u002FOpenSPG\u002Fopenspg\u002Frefs\u002Fheads\u002Fmaster\u002Fdev\u002Frelease\u002Fdocker-compose-west.yml -o docker-compose-west.yml\ndocker compose -f docker-compose-west.yml up -d\n```\n\n### 4.1.2 Use the product\n\nNavigate to the default url of the KAG product with your browser: \u003Chttp:\u002F\u002F127.0.0.1:8887>\n```text\nDefault Username: openspg\nDefault password: openspg@kag\n```\nSee [KAG usage (product mode)](https:\u002F\u002Fopenspg.yuque.com\u002Fndx6g9\u002Fcwh47i\u002Frs7gr8g4s538b1n7#rtOlA) for detailed introduction.\n\n## 4.2 toolkit-based (for developers)\n\n### 4.2.1 Engine & Dependent Image Installation\n\nRefer to the 3.1 section to complete the installation of the engine & dependent image.\n\n### 4.2.2 Installation of KAG\n\n\n**macOS \u002F Linux developers**\n\n```text\n# Create conda env: conda create -n kag-demo python=3.10 && conda activate kag-demo\n\n# Clone code: git clone https:\u002F\u002Fgithub.com\u002FOpenSPG\u002FKAG.git\n\n# Install KAG: cd KAG && pip install -e .\n```\n\n**Windows developers**\n\n```text\n# Install the official Python 3.10 or later, install Git.\n\n# Create and activate Python venv: py -m venv kag-demo && kag-demo\\Scripts\\activate\n\n# Clone code: git clone https:\u002F\u002Fgithub.com\u002FOpenSPG\u002FKAG.git\n\n# Install KAG: cd KAG && pip install -e .\n```\n\n### 4.2.3 Use the toolkit\n\nPlease refer to [KAG usage (developer mode)](https:\u002F\u002Fopenspg.yuque.com\u002Fndx6g9\u002Fcwh47i\u002Frs7gr8g4s538b1n7#cikso) 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.\n\n# 5. Technical Architecture\n\n![KAG technical architecture](.\u002F_static\u002Fimages\u002Fkag-arch.png)\n\nThe 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.\n\nkg-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.\n\nkg-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.\n\n# 6. Community & Support\n\n**GitHub**: \u003Chttps:\u002F\u002Fgithub.com\u002FOpenSPG\u002FKAG>\n\n**Website**: \u003Chttps:\u002F\u002Fopenspg.github.io\u002Fv2\u002Fdocs_en>\n\n## Discord \u003Ca href=\"https:\u002F\u002Fdiscord.gg\u002FPURG77zhQ7\"> \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fdiscord\u002F1329648479709958236?style=for-the-badge&logo=discord&label=Discord\" alt=\"Discord\">\u003C\u002Fa>\n\nJoin our [Discord](https:\u002F\u002Fdiscord.gg\u002FPURG77zhQ7) community.\n\n## WeChat\n\nFollow OpenSPG Official Account to get technical articles and product updates about OpenSPG and KAG.\n\n\u003Cimg src=\".\u002F_static\u002Fimages\u002Fopenspg-qr.png\" alt=\"Contact Us: OpenSPG QR-code\" width=\"200\">\n\nScan the QR code below to join our WeChat group. \n\n\u003Cimg src=\".\u002F_static\u002Fimages\u002Frobot-qr.JPG\" alt=\"Join WeChat group\" width=\"200\">\n\n\n# 7. Differences between KAG, RAG, and GraphRAG\n\n**KAG introduction and applications**: \u003Chttps:\u002F\u002Fgithub.com\u002Forgs\u002FOpenSPG\u002Fdiscussions\u002F52>\n\n# 8. Citation\n\nIf you use this software, please cite it as below:\n\n* [KAG: Boosting LLMs in Professional Domains via Knowledge Augmented Generation](https:\u002F\u002Farxiv.org\u002Fabs\u002F2409.13731)\n\n* KGFabric: A Scalable Knowledge Graph Warehouse for Enterprise Data Interconnection\n\n```bibtex\n@article{liang2024kag,\n  title={KAG: Boosting LLMs in Professional Domains via Knowledge Augmented Generation},\n  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},\n  journal={arXiv preprint arXiv:2409.13731},\n  year={2024}\n}\n\n@article{yikgfabric,\n  title={KGFabric: A Scalable Knowledge Graph Warehouse for Enterprise Data Interconnection},\n  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}\n}\n```\n\n# License\n\n[Apache License 2.0](LICENSE)\n\n# KAG Core Team\nLei 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\n","KAG是一个基于OpenSPG引擎和大语言模型的逻辑推理与问答框架，专为构建专业领域知识库中的逻辑推理和事实问答解决方案而设计。它通过知识与块互索引结构、概念语义推理的知识对齐、模式约束的知识构建以及逻辑形式引导的混合推理和检索等核心功能，有效克服了传统RAG向量相似度计算模型的模糊性和由OpenIE引入的噪音问题。特别适用于需要处理复杂逻辑推理和多跳事实查询的专业场景，如医疗、法律或金融等领域，能够显著提升专业知识服务的质量和准确性。",2,"2026-06-11 03:39:47","high_star"]