← Back to Leaderboard
KOpenSPG

OpenSPG/KAG

OpenSPG graph-and-text RAG for multi-hop reasoning and domain Q&A

Engineering Health (Methodology)
A · 80/100
Maintenance Activity
● Updated 15d ago
Latest Release
v0.8.0
Commercial License Check
Apache-2.0 · Commercial Friendly

Automated SPDX check for reference only — not legal advice. Disclaimer

Maintenance31/35
Fork Adoption18/25
Release Cadence11/20
License Clarity20/20
DockerSelf-HostedMCP
Total Stars
★ 9,212
24h Growth
+1
7d Growth
+16
Forks
729

GitHub Star History

Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.

OpenSPG/KAG Star History (2024-09-20 - 2026-12-04) ALL-TIME STAR HISTORY (2024-09 – 2026-12) +9.2k in 805d · avg +11/day 9.7k 4.9k 0 2024-09-20: ★ 12024-11-09: ★ 4952024-12-28: ★ 1,6872025-02-15: ★ 4,9822025-04-05: ★ 6,0592025-05-24: ★ 6,7852025-07-12: ★ 7,2422025-08-30: ★ 7,6122025-10-18: ★ 7,8152025-12-06: ★ 8,1572026-01-24: ★ 8,3242026-03-14: ★ 8,4732026-05-02: ★ 8,5982026-06-20: ★ 8,7552026-08-08: ★ 8,9042026-09-26: ★ 9,0422026-12-04: ★ 9,212 ★ 9.2k 2024-09 2025-10 2026-12

Evidence-Backed Technical Brief

AI Deep Review

Architecture & Core Mechanics

KAG is a Python framework built on the OpenSPG engine. Its two released components divide ingestion from query execution. The kg-builder extracts and normalizes knowledge, supports open extraction alongside schema-constrained construction for the same entity or event type, and cross-indexes graph structures with source text chunks. The kg-solver turns a natural-language question into a logical-form plan: planning, retrieval, and reasoning operators can combine exact matches, text search, graph relationships, semantic reasoning, and numerical computation in one workflow.

The architecture also names a third component, kag-model, which is not part of the released builder and solver. Adaptation for KAG-Thinker in v0.8.0 does not imply that the model ships with the framework. The Python dependency set includes NetworkX, the Neo4j client, OpenAI, DashScope, Ollama, and mcp==1.6.0; those entries do not establish that every integration is enabled or required in every deployment. MCP is the explicit protocol boundary for connecting public sources and making KAG question answering available to agent workflows.

Key Capabilities & Differentiators

KAG fits questions that require more than fetching a similar passage: resolve an entity, follow a relationship, retrieve its source context, and perform a calculation where needed. The builder aligns concepts and normalizes properties to bring structured records, unstructured documents, and expert rules into a shared graph. The dependency manifest includes PDF, DOCX, and Markdown tooling, but parser availability does not establish reliable extraction for every document layout.

In v0.8.0, private knowledge bases support Outline, Summary, KnowledgeUnit, AtomicQuery, Chunk, and Table indexes; public knowledge bases can draw on sources such as web search and location-based services through MCP. Applications can attach multiple knowledge bases and select retrievers according to the indexes built for each. The v0.7 solver refactor added static and iterative planning, Simple and Deep Reasoning modes, streamed output, and links to original sources. Those links make answers easier to audit, but do not by themselves verify that the cited material supports every inference.

Trade-offs & Limitations

A vector-only RAG pipeline is the cheaper baseline to build and maintain when most questions are answered by one or two passages. A simpler GraphRAG pipeline may be enough when graph traversal primarily supplies additional context. KAG earns its extra complexity when a query needs to execute different steps, such as joining facts across entities, looking up an exact value, and calculating a result while preserving access to source text.

The cost is more work on schemas, extraction quality, entity alignment, and index rebuilds as the corpus changes. A wrong entity match can contaminate a multi-hop answer, and iterative planning can introduce variable latency and model spend. Evaluate those risks on representative questions, including cases with missing evidence, rather than assuming that a richer reasoning pipeline improves all answers. Apache-2.0 supports commercial use, but model, image, API, and public-data terms still need separate review.

Hardware & Deployment Guide

For product mode, start the OpenSPG engine and dependent images with Docker Compose using dev/release/docker-compose-west.yml from the separate OpenSPG/openspg repository. The documented download tracks the master branch, so review the Compose file and pin a tested revision and image versions for repeatable deployments. Windows requires WSL 2 or Hyper-V alongside Docker and Docker Compose. Developer mode uses the same backend services and installs the Python toolkit with pip install -e . from the KAG checkout. Change the default product credentials before exposing the service.

Self-hosting OpenSPG is separate from running model inference locally. The manifest includes clients for hosted providers and Ollama, but an offline deployment also needs local model and embedding endpoints, pre-staged dependencies and images, and an audit of public MCP integrations. Size storage for source chunks and indexes, measure ingestion separately from online query load, and budget for model calls on iterative queries. v0.7 refactored planning and reasoning; v0.8.0 separated applications from knowledge bases. When upgrading, validate application-to-base mappings and retriever selection before moving traffic.

Evidence linkage: Graph structures and source chunks are cross-indexed so retrieval can use relationships without discarding original context.
Knowledge construction: Schema-free extraction and schema-constrained modeling can coexist for the same entity or event type.
Query execution: Logical-form planning combines exact lookup, text retrieval, graph reasoning, semantic reasoning, and numerical computation.
Retrieval routing: In v0.8.0, applications can span multiple knowledge bases and select retrievers based on the indexes each base provides.
Index coverage: Private knowledge bases support Outline, Summary, KnowledgeUnit, AtomicQuery, Chunk, and Table indexes.
MCP integration: Public sources such as web search and location-based services can feed KAG, while agents can call KAG question answering.
Best For

Teams building professional Q&A over records, documents, and expert rules, where answers need multi-step reasoning and traceable source evidence.

Skip If

Most questions are single-passage lookups, or the team cannot maintain schemas, extraction quality, and a separate OpenSPG deployment.

Reviewed on 2026-12-04 · Grounded in GitHub README, root file tree & releasesMethodology

Quick Start & Installation

DockerSelf-HostedMCP
# set the HOME environment variable (only Windows users need to execute this command)
# set HOME=%USERPROFILE%

curl -sSL https://raw.githubusercontent.com/OpenSPG/openspg/refs/heads/master/dev/release/docker-compose-west.yml -o docker-compose-west.yml
docker compose -f docker-compose-west.yml up -d

Comparison vs. Top RAG, Data & Memory Alternatives

Full comparison →
RepositoryStars7d TrendStackLicenseCore Positioning
KAG ★9.2k+16PythonApache-2.0OpenSPG graph-and-text RAG for multi-hop reasoning and domain Q&A
auto-ontology19.1k+3.2kPythonApache-2.0An ontology framework that grounds agent-generated SQL in reviewed business defi
llama_index53.1k+110PythonMITA modular Python SDK for document ingestion, indexing, and RAG
langextract39.5k+85PythonApache-2.0Python SDK for extracting structured data with traceable source spans

AI Context Briefing (for Claude / Cursor / Windsurf)

Standardized architecture summary & quickstart commands ready to paste into coding agents.

Raw .md ↗
curl -sL https://repoforai.com/repo/OpenSPG/KAG.md

Embed Star History Chart & Badges in README.md

Full-history Star History SVGs and velocity cards on GitHub Camo: drop-in replacement for OSSInsight and Star History widgets.

OpenSPG/KAG Star History on RepoForAI

Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).

Frequently Asked Questions about KAG

How do applications connect to knowledge bases and agents?

In v0.8.0, an application can attach multiple knowledge bases. KAG selects retrievers based on the index types built for each base. MCP serves two distinct integration paths: bringing public sources such as web search into KAG, and exposing KAG question answering to an agent workflow.

Do I need a GPU, and what should I size for?

There is no fixed GPU or VRAM requirement for the framework. With a hosted LLM, size the self-hosted services for ingestion throughput, index storage, and concurrent queries. If you run model inference locally, size it separately for the chosen model, context length, and concurrency. Load-test ingestion and query traffic independently before setting capacity targets.

Can I use KAG commercially and keep the deployment private?

KAG is licensed under Apache-2.0, which permits commercial use and self-hosting subject to its terms, including applicable notice obligations on redistribution. Review the terms of separately deployed images, models, and external APIs. Self-hosting the engine does not keep data local if model calls or MCP integrations send it to external services.

When should I choose KAG over vector RAG or a simpler GraphRAG pipeline?

Start with vector RAG if most answers are supported by a single passage. If retrieval needs to follow entity relationships, benchmark a graph-based baseline. KAG is most worth testing when a query must combine graph traversal with exact lookup, supporting text, or arithmetic. Compare answer correctness, source support, and ingestion and query costs on the same corpus.

Upstream README & Documentation

This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.

Maintaining OpenSPG/KAG? Pin to Homepage + competitor /alternatives pages with a custom Cloud/Demo CTA.Feature OpenSPG/KAG on Homepage & Alternatives ($19)
WEEKLY BREAKOUT DIGEST

Top 10 Breakout Open-Source AI Repos, Every Thursday

Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.

Zero spam · 1-click unsubscribe · Privacy Policy

Saved in your browser · Export Markdown RFC tables or jump into /vs compare