KAG: Build Knowledge-Grounded Reasoning and Q&A Systems

KAG: Build Knowledge-Grounded Reasoning and Q&A Systems

Summary

KAG is a Python framework for building domain-specific question-answering systems that combine knowledge graphs, source text, and LLMs. It targets factual and multi-hop reasoning where vector similarity alone may be insufficient.

At a glance

Language
Python
License
Apache-2.0
Stars
9.1k
Forks
722
Added to OSRepos
November 27, 2025
Last analyzed
October 3, 2026
View on GitHub

Topics

Click on any tag to explore related repositories

Use at your own risk

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.

Overview

KAG is a framework for building question-answering and reasoning systems over professional-domain knowledge bases. It combines the OpenSPG engine with large language models and links graph knowledge to source text, aiming to support answers that require structured facts, context, or multiple reasoning steps.

It is intended for teams that need more than similarity-based retrieval, such as domain experts and developers building knowledge-backed applications. KAG provides both knowledge construction and a solver that can coordinate retrieval, graph reasoning, language reasoning, and numerical calculation.

Key Features

  • Connects knowledge graph structures with original text blocks through mutual indexing.
  • Supports schema-free extraction as well as schema-constrained construction of domain knowledge.
  • Aligns extracted knowledge semantically to help address noise from automated extraction.
  • Uses logical-form-guided planning, reasoning, and retrieval for question solving.
  • Combines exact-match and text retrieval with graph reasoning, language reasoning, and numerical calculation.
  • Supports multi-hop factual question answering and domain-specific reasoning.
  • Can connect private and public knowledge sources, including MCP integrations described for the 0.8.0 release.

Use Cases

  • Domain experts can organize structured records, documents, and business rules into a shared knowledge base.
  • Application developers can build factual Q&A for professional domains where answers need evidence from both graph facts and source text.
  • Teams can handle questions that require following relationships across multiple entities or combining retrieved facts with calculations.
  • Organizations with private knowledge bases can combine internal material with public sources for knowledge-backed workflows.

Project Facts

  • Language: Python
  • License: Apache-2.0
  • Stars: 9.1k
  • Forks: 722
  • Topics: knowledge-graph, large-language-model, logical-reasoning, multi-hop-question-answering, trustfulness
  • Archived: false

Getting Started

The toolkit requires Python 3.10 or later and an OpenSPG engine setup. A basic developer installation is:

git clone https://github.com/OpenSPG/KAG.git
cd KAG
pip install -e .

See the README and user guide for engine setup and usage details.

Alternatives

  • rag-web-ui: RAG Web UI builds document-QA applications with vector search and configurable models, rather than KAG's knowledge-graph-based reasoning framework.
  • RAG-Anything: RAG-Anything focuses on parsing and querying multimodal documents, while KAG targets knowledge-graph-supported factual and multi-hop reasoning.

Considerations

  • KAG is a framework rather than a ready-made domain knowledge base. Users need to prepare and configure the knowledge sources, schemas, and application workflow.
  • The developer setup depends on the OpenSPG engine and its supporting services. Product-mode installation uses Docker Compose.
  • The project describes a broad reasoning and retrieval architecture, but the README says the release covers kg-builder and kg-solver; kag-model was planned for gradual release.
  • Results depend on the quality of the underlying knowledge and model setup. Evaluate the system against the accuracy and evidence requirements of the intended domain.

Source repository

Open the original repository on GitHub.

15 counted GitHub visits

View on GitHub

Related repositories

Similar repositories that may be relevant next.

OS
OSRepos

Analysis and discovery of open source repositories. Find interesting projects and follow their updates.

Monitor your website with YourWebsiteScore

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of third-party repository code is at your own risk. Always review source code, dependencies, licenses, and security implications before running anything.

© 2025 OSRepos. Built with Nuxt 3 and lots of ❤️