# OpenSPG/KAG

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.

Repository: https://github.com/OpenSPG/KAG
Canonical: https://ross.abutalabs.com/products/kag
Homepage: https://spg.openkg.cn/en-US
Language: Python
License: Apache-2.0
License Family: permissive
Topics: knowledge-graph, large-language-model, logical-reasoning, multi-hop-question-answering, trustfulness
Last push: 2026-01-28T13:30:54+00:00

## Health v2 (maintenance only)
Score: 49/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 64, release rhythm 28, longevity 50
- inputs: {"age_days": 711, "days_push": 217, "days_rel": 431, "gap_med": 47, "n_releases_24m": 6}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 9018, forks 709 (observed 2026-08-28T04:10:26.782474+00:00)

## What it is
KAG (Knowledge Augmented Generation) is a Python framework built on the OpenSPG engine and large language models for logical form-guided reasoning and retrieval over domain knowledge bases. It combines knowledge graphs with mutual indexing of knowledge and text chunks to support logical reasoning and multi-hop factual Q&A, overcoming the ambiguity of vector-similarity RAG and the noise of OpenIE-based GraphRAG.

## Use cases
- build a factual Q&A assistant over a professional domain knowledge base
- answer multi-hop questions requiring logical reasoning across documents
- reduce hallucinations compared to vector-similarity RAG
- construct a schema-constrained knowledge graph from unstructured and structured data
- replace or augment GraphRAG pipelines with semantic reasoning alignment
- query private enterprise knowledge bases with trustworthy, cited answers

## When to choose
- you need multi-hop or logical reasoning Q&A rather than simple semantic retrieval
- your domain benefits from a structured knowledge graph with schema constraints
- you want to combine unstructured documents, structured data, and expert knowledge in one reasoning framework
- you need higher factual accuracy than vanilla vector RAG or OpenIE-based GraphRAG

## When to avoid
- you need a simple plug-and-play RAG pipeline with minimal setup
- your corpus is small and vector search already gives sufficient accuracy
- you cannot invest in schema design and knowledge graph construction
- you need a managed cloud service rather than a self-hosted framework

## Facets
- artifact type: framework
- maturity: active
- function: rag, search-engine, nlp, llm-inference, agent-framework
- domain: large-language-models, artificial-intelligence, databases
- platform: python, self-hosted, cross-platform
- tags: knowledge-graph, logical-reasoning, multi-hop-question-answering, openspg, knowledge-augmented-generation, graphrag, retrieval-augmented-generation, natural-language-processing, docker

## Member repositories
- OpenSPG/KAG (main) score 49

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:10:26.782474+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T17:24:20.401683+00:00, confidence not recorded.
  - readme: https://github.com/OpenSPG/KAG (fetched 2026-08-28T04:10:26.782474+00:00, sha 6173752f8b79)
  - homepage: https://spg.openkg.cn/en-US (fetched 2026-08-29T08:24:16.228505+00:00, sha 44136fa355b3)
- Data as of 2026-08-30T08:39:29.467469+00:00.
