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
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
Related repositories
Similar repositories that may be relevant next.

web-design: Create Consistent Web Pages with a Claude Code Skill
October 3, 2026
web-design is a Claude Code skill that turns product briefs, reference URLs, or screenshots into an editable design specification before generating web code. It is suited to developers and designers who want a repeatable, spec-led workflow for building consistent pages.

oomwoo: Build a DIY Robot Vacuum
October 2, 2026
OOMWOO is a planned, hackable robot vacuum built around Raspberry Pi, ROS2 and 2D LiDAR. It is aimed at makers who want to build and customize a locally controlled vacuum, but its hardware and build instructions are still in development.

shepherd: Supervise Agents with Reversible Execution Traces
October 2, 2026
Shepherd records agent work as inspectable, reversible execution traces and keeps changes as proposals for review. It is aimed at developers building systems that supervise, replay, or manage the work of other agents.

agent-anvil: Test AI Agent Tool Use in CI
October 1, 2026
Agent Anvil evaluates tool-using AI agents through scenario-based runs, trace checks, and optional semantic grading. It helps teams catch unsafe or incorrect tool behavior before it reaches production.