KAG (Knowledge Augmented Generation) is an open source large model knowledge service framework launched by Ant Group, which aims to solve the shortcomings of traditional retrieval augmented generation (RAG) technology in multi-hop reasoning and complex logic processing.
The framework significantly improves the accuracy and efficiency of large language models in professional field question and answer by combining knowledge graphs (KGs) and innovative technologies.
This article will introduce the technical principles, core functions, application scenarios, advantages and characteristics, and future development of the KAG framework in detail.

SPG (Semantic-enhanced Programmable Graph) framework
Keywords: KAG; large model; knowledge service framework; knowledge graph; logical reasoning
1. Introduction
With the rapid development of artificial intelligence technology, large language models (LLMs) have achieved remarkable results in the field of natural language processing. However, when dealing with knowledge questions and answers in professional fields, traditional large language models often face problems such as insufficient knowledge and limited logical reasoning ability. In order to solve these problems, Ant Group launched the KAG framework, which equips large language models with a “knowledge brain” through knowledge augmentation generation, enabling them to better understand and apply professional knowledge.
2. Overview of KAG Framework
(I) Definition and Objective
KAG is a knowledge enhancement generation framework based on the OpenSPG engine and large language models, which aims to build a more intelligent and reliable logical reasoning question answering solution for vertical domain knowledge bases. The goal of this framework is to enable large language models to not only “remember” knowledge, but also “understand” and “apply” knowledge, surpassing the traditional retrieval enhancement generation (RAG) method in multi-hop question answering tasks.
(II) Technical Background
Traditional RAG technology provides a way for large language models to obtain external knowledge through external knowledge bases, but when dealing with knowledge questions and answers in professional fields, there are often problems such as vector retrieval ambiguity and logical reasoning insensitivity. The KAG framework optimizes these problems and significantly improves generation and reasoning performance by combining knowledge graphs and vector retrieval technologies.
3. Technical Principles of KAG Framework
(I) LLM-friendly Knowledge Representation
KAG proposes an LLM-friendly knowledge representation framework that breaks the barrier between large language models and knowledge. Based on the hierarchical structure of DIKW (data, information, knowledge and wisdom), this framework upgrades the knowledge representation capability of SPG, making it compatible with information extraction without schema constraints and professional knowledge construction with schema constraints. Specifically, KAG implements the following functions:
- Inter-index representation: Supports bidirectional indexing between graph structure and original text blocks, so that large models can quickly locate relevant original texts based on graph structure queries, and can also quickly locate corresponding entities and relationships in the graph based on text information.
- Knowledge alignment: Reduce the noise of information extraction through knowledge understanding, semantic alignment and other technologies, and improve the accuracy and consistency of knowledge.
(II) Hybrid reasoning engine guided by logical form
KAG introduces a hybrid reasoning engine guided by logical symbols, which organically combines three types of operators: planning, reasoning and retrieval, and transforms natural language problems into a problem-solving process that combines language and symbols. The engine integrates four problem-solving processes:
- Graph reasoning: Reasoning based on the structural information and semantic relationships of the knowledge graph, such as multi-hop reasoning based on the relationship chain between entities.
- Logical calculation: Perform logical operations such as numerical calculation and time inference to handle problems that require precise calculation.
- Chunk retrieval: Retrieve relevant information from the original text block to provide richer contextual information for the large model.
- LLM reasoning: Use the reasoning ability of the large model to complete and generate information to improve the accuracy and completeness of the answer.

KAG: Boosting LLMs in Professional Domains via Knowledge Augmented Generation
4. Core functions of the KAG framework
(I) Knowledge and Chunk mutual indexing structure
KAG realizes the mutual indexing between the knowledge graph and the original text block, which not only improves the accuracy and efficiency of data retrieval, but also enhances the ability of knowledge integration. Through semantic chunking, information injection and domain knowledge constraints, KAG can effectively improve the efficiency of knowledge retrieval and representation.
(II) Support Schema-Constraint knowledge construction
KAG supports the representation and construction of domain expert knowledge, and can be compatible with information extraction without schema constraints and professional knowledge construction with schema constraints on the same knowledge type. This flexibility enables KAG to handle various complex knowledge structures.
(III) Domain knowledge injection and customization
The KAG framework supports domain knowledge injection and domain schema customization. Users can customize the structure and content of the knowledge graph according to specific needs to meet the knowledge service needs of different fields.
(IV) Summary generation task support
KAG provides support for summary generation tasks, which can automatically generate text summaries to help users quickly understand the main content of the document.
(V) Visual graph analysis query
KAG supports visual graph analysis query. Users can intuitively view the structure and relationship of the knowledge graph through a graphical interface to better understand the relationship between knowledge.
(VI) KAG-Model module
The KAG-Model module uses instruction synthesis technology to make the language model with small parameters close to the performance of the large model while reducing the coupling cost with the large model. This module is particularly suitable for application scenarios that require efficient computing and low resource consumption.
5. Application scenarios of the KAG framework
(I) E-government question and answer
The KAG framework has been successfully applied in the field of e-government. For example, in Alipay’s latest AI native app “Zhi Xiao Bao”, the KAG framework is used to build a government service question-and-answer system. The system can answer users’ questions about service methods, required materials, service conditions, and service locations with an accuracy rate of 91%.
(II) Electronic health question-and-answer
In the medical field, the KAG framework is also used to build a medical question-and-answer system. The system can answer users’ questions about disease symptoms, vaccinations, medical indicators, etc. with an accuracy rate of more than 90%. For example, users can ask “What are the methods for treating thyroid nodules?” The KAG framework can combine medical knowledge graphs and expert-defined rules to give professional treatment suggestions.
(III) Financial risk assessment
Financial institutions can use the KAG reasoning model to conduct credit assessments on borrowers, mine and infer borrowers’ public information, and identify risk signals such as related transactions and negative public opinion, thereby improving the accuracy of risk warnings.
(IV) Intelligent customer service and product recommendations
In the e-commerce field, the KAG framework can be used for intelligent customer service and product recommendations. Intelligent customer service can handle user inquiries, understand the intention of questions, and provide accurate answers; the product recommendation system can analyze product knowledge graphs and user behavior data to make personalized product recommendations.
6. Advantages and characteristics of the KAG framework
(I) Support logical reasoning and multi-hop factual question and answer
The KAG framework can not only handle simple retrieval questions and answers, but also perform complex logical reasoning and multi-hop factual question and answer, meeting the high requirements of professional fields for reasoning ability.
(II) Better performance
In public data sets and actual application scenarios, the performance of the KAG framework exceeds the current SOTA (State-Of-The-Art) method. For example, on the hotpotQA data set, KAG’s F1 score increased by 19.6%; on the 2wiki data set, the F1 score increased by 33.5%.
(III) Better understanding of professional knowledge
The KAG framework is designed for vertical field knowledge question and answer, which can better understand and utilize professional knowledge and give more professional and accurate answers.
(IV) Reduce the hallucination rate
Through the feedback of the knowledge graph and the constraints of the logical reasoning engine, the KAG framework helps to suppress the hallucination phenomenon in the generation of language models and improve the accuracy of answers.
(V) Open source and community co-construction
The KAG framework has been open sourced on GitHub, and developers can explore and apply it through the official documents and sample codes. At the same time, Ant Group welcomes community co-construction to jointly promote the development and improvement of the KAG framework.
7. Future development of the KAG framework
(I) Technical optimization and upgrading
In the future, the KAG framework will continue to be optimized and upgraded in technology. For example, further improve the knowledge representation method, improve the efficiency and accuracy of knowledge graph construction; optimize the hybrid reasoning engine, and enhance the ability of logical reasoning and complex problem solving.
(II) Application scenario expansion
The application scenarios of the KAG framework will continue to expand. In addition to the existing e-government, e-health, financial risk assessment and other fields, it can also be applied to education, law, scientific research and other fields to provide intelligent knowledge services for various industries.
(III) Integration with other technologies
The KAG framework will be integrated with other technologies, such as multimodal large models, reinforcement learning, etc. By combining with other technologies, the KAG framework will further enhance its performance and functions, and provide users with more comprehensive and intelligent knowledge services.
(IV) Community co-construction and ecological development
Ant Group will continue to promote the community co-construction and ecological development of the KAG framework. Through cooperation with developers, research institutions, enterprises and other parties, we will jointly improve the functions and application scenarios of the KAG framework and promote the technical development of the combination of knowledge graphs and large language models.
8. Conclusion
As an open source large model knowledge service framework, the KAG framework significantly improves the accuracy and efficiency of large language models in professional field question and answer by combining knowledge graphs and vector retrieval technologies. The framework not only supports logical reasoning and multi-hop factual question and answer, but also has better performance and better professional knowledge.
In the future, the KAG framework will continue to optimize and upgrade its technology, expand application scenarios, integrate with other technologies, and promote community co-construction and ecological development. I believe that in the near future, the KAG framework will become one of the important tools for knowledge services in professional fields, providing more intelligent and efficient knowledge services for various industries.
About All AI Applications
AllAIApplications.com focuses on all AI applications, all AI tools, global AI ideas, AI stores and AI product advertising services. We are committed to AI technology research, AI idea exploration, using AI for business, AI for education, AI for cross-border e-commerce and other projects. If you have this idea, please contact us to discuss it together. If you need to place AI ads on our website, you can also contact us at any time.
FAQs
FAQs about KAG open source large model knowledge service framework:
KAG (Knowledge Augmented Generation) is an open-source large-model knowledge service framework of Ant Group. It is based on the OpenSPG engine and a large language model. It aims to solve the limitations of traditional RAG (retrieval augmented generation) in professional knowledge question and answer, and improve logical reasoning and multi-hop question and answer capabilities.
Logical reasoning ability: supports complex logical reasoning and multi-hop factual question and answer, surpassing traditional RAG.
Knowledge representation enhancement: through the LLM-friendly knowledge representation framework, it is compatible with schema-free information extraction and schema-constrained professional knowledge construction.
Hybrid reasoning engine: combines graph reasoning, logical calculation, text retrieval and LLM reasoning to achieve more accurate reasoning.
Performance exceeds SOTA: On public data sets (such as HotpotQA, 2Wiki), the F1 score is significantly improved (such as HotpotQA increased by 19.6%, 2Wiki increased by 33.5%).
Vertical field knowledge question and answer: such as e-government, e-health, etc.
Complex reasoning tasks: scenarios that require multi-hop reasoning and logical calculations.
Knowledge graph applications: combining knowledge graphs and text retrieval to improve information utilization efficiency.
Ambiguity of vector retrieval: Reduce information extraction noise through knowledge alignment and semantic alignment technology.
Insufficient logical reasoning: Introduce a hybrid reasoning engine guided by logical forms to support complex logical operations.
Knowledge accuracy: Through the mutual indexing representation mechanism, realize bidirectional indexing of graph structure and original text to improve retrieval accuracy.
KAG-Builder: Responsible for building offline indexes and realizing LLM-friendly knowledge representation.
KAG-Solver: Adopts a hybrid reasoning engine guided by logical forms to integrate LLM reasoning, knowledge reasoning and mathematical logic reasoning.
KAG-Model (open source in the future): Optimize natural language understanding, reasoning and generation capabilities.
Ant Group internal verification: In e-government Q&A and e-health Q&A, the accuracy has been significantly improved (e.g., the accuracy of e-government Q&A has reached 91.6%).
Black market mining application: Use knowledge graphs and logical reasoning capabilities to mine hidden black market gangs.
Medical graph application: Quickly and accurately answer health questions and provide professional treatment advice.
Four problem-solving processes:
Graph reasoning: Reasoning based on the structural information and semantic relationships of the knowledge graph.
Logical calculation: Perform logical operations such as numerical calculations and time inference.
Chunk retrieval: Retrieve relevant information from the original text block.
LLM reasoning: Use the reasoning ability of the large model to complete and generate information.
Hybrid reasoning: Generate executable logical query expressions through symbol-driven methods and call external knowledge bases when necessary.
Open source status: It is open source, and the code is hosted on GitHub.
How to obtain it: Visit the KAG GitHub repository to obtain source code, documents, and sample code.
Support: Users can build private knowledge bases based on KAG to complete the construction of domain graphs and knowledge question and answer.
Continuous optimization: Improve natural language understanding, reasoning and generation capabilities.
Expand application scenarios: Explore knowledge service needs in more vertical fields.
Open ecology: Cooperate with the community to promote the technical development of combining knowledge graphs with large language models.
Knowledge representation: KAG provides LLM-friendly knowledge representation, while RAG mainly relies on vector retrieval.
Reasoning ability: KAG supports complex logical reasoning, while RAG is insensitive to logical relationships.
Performance: KAG is significantly better than RAG in multi-hop question and answer tasks.
Support: KAG is compatible with GPT large models, domestic large models (such as Tongyi Qianwen, Xinghuo) and open source local large models.
Deployment mode: Supports product mode and developer mode, and provides detailed documentation and sample code.
Development environment: Anaconda and PyCharm are recommended for development.
Medical knowledge Q&A: Help users quickly obtain medical information and answer health questions.
Treatment suggestions: Combined with medical knowledge graphs, provide professional treatment suggestions (such as radioactive iodine therapy, compound iodine oral solution, etc.).
Mutual indexing representation mechanism: Supports bidirectional indexing between graph structures and original text blocks to improve retrieval efficiency and information integration capabilities.
Support: Users can define business rules (such as gambling app identification rules, App developer identification rules), and KAG can reason based on these rules.
Main indicators: F1 score, accuracy, recall, etc.
Public data set performance: On data sets such as HotpotQA and 2Wiki, the F1 score has been significantly improved.
Hardware requirements: Depends on the application scenario. Conventional hardware can be used in general development environments, and GPU acceleration may be required for large-scale deployment.
Open source community: KAG is open source on GitHub, and the community is active, providing technical support and problem solving.
E-government Q&A: Improve the accuracy and professionalism of government Q&A.
E-health Q&A: Quickly answer medical and health questions.
Black industry mining: Use knowledge graphs and logical reasoning capabilities to dig out hidden black industry gangs.