Zleap-AI/SAG
A new SOTA for RAG — an original retrieval architecture and an open-source knowledge base for humans and agents.
What it solves
Traditional RAG retrieves chunks mainly by semantic similarity, and GraphRAG adds expensive offline graph construction with triple extraction, entity merging, relation normalization, and difficult incremental updates. SAG replaces both with one original retrieval architecture, so users get semantic retrieval and relational reasoning in a single system without maintaining two RAG systems or merging two retrieval paths. It also provides a complete knowledge base app for individuals and agents: upload documents, get structured knowledge, search across sources with source tracing, ask questions with citations, and reuse knowledge through an API or MCP.
How it works
SAG is built on the SAG architecture (SQL-Retrieval Augmented Generation with Query-Time Dynamic Hyperedges). At indexing time, each document chunk is parsed into one semantically complete event plus multiple indexing entities; events, entities, and their associations are persisted to relational storage, while chunk/event/entity representations go to vector/full-text indexes. At query time, it finds seed entities and events using semantic and lexical signals, uses SQL joins over shared entities to expand into a local candidate space, instantiates only the hyperedges relevant to the current query (no global graph traversal or rebuild), then selects the strongest event and direct-chunk candidates and returns original evidence chunks. Incremental writes are natural because a new chunk adds just its own event/entities/associations without recomputing a global graph. The system starts with SQLite and LanceDB, requires no external database, and has a path to PostgreSQL/pgvector for production.
Who it's for
Individuals and agents who want a self-hosted, local-first knowledge base with grounded, cited answers. It serves end users via a desktop app (macOS and Windows) or Docker self-hosted deployment, and also serves developers or agent frameworks through REST/OpenAPI, an OpenAI-compatible chat endpoint, MCP integration, a CLI, a Python package, and a DeepSeek Harness plugin. Users need to configure an LLM for event extraction, query understanding, and generation, and embeddings for indexing/vector retrieval.
Highlights
- Original retrieval architecture, not a fusion of RAG and GraphRAG; the paper is on arXiv and benchmarks are reproducible.
- Events carry complete chunk meaning without fragmenting into triples; entities are lightweight indexes and expansion points.
- Query-time dynamic hyperedges are created locally by SQL joins over shared entities, avoiding global graph maintenance.
- Every retrieval result and citation maps back to the original chunk for source tracing and inspectability.
- Desktop app bundles web workspace and local backend; no Python, Node, or database install needed.
- Supports cross-source or source-scoped search, event-entity graph exploration (2D and 3D), and an interactive Explore mode.
- Integrations include MCP mounting via CLI, an OpenAI-compatible endpoint, and a DeepSeek Harness plugin with a skill.
- Reports state-of-the-art results on HotpotQA, 2WikiMultiHopQA, and MuSiQue, averaging 90.07% Recall@5 and 72.96% F1, beating baselines by 6.79 and 4.33 points respectively.
- Optional parser flexibility: MinerU for PDFs, local MarkItDown, or AnyDoc with local conversion and encoding detection for CSV.
Related
- Project
- Project
- Project
- Project
- Project