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

SAG addresses the limitations of traditional dense RAG (which relies primarily on semantic similarity) and GraphRAG (which requires expensive offline graph construction and complex maintenance). It provides a unified retrieval architecture that handles both semantic search and relational reasoning without needing to maintain two separate systems.

How it works

SAG uses a unique data model where documents are parsed into semantically complete "events" and lightweight "entities." Instead of pre-building a global knowledge graph, it creates "query-time dynamic hyperedges" using SQL joins to connect events that share entities based on the specific query.

The process follows two phases:

  1. Offline Indexing: Documents are chunked, and events and entities are extracted and stored in relational storage (SQLite/PostgreSQL) and vector indexes (LanceDB/pgvector).
  2. Online Retrieval: The system finds seed events and entities, expands the candidate space via SQL joins, and returns the original evidence chunks for generation and citation.

Who it’s for

  • Individuals: Users who want a local-first knowledge base for their documents with source tracing and cited answers.
  • AI Agents: Developers building agents that need a structured, searchable knowledge base accessible via API or Model Context Protocol (MCP).
  • Developers: Those looking for a high-performance RAG engine (zleap-sag Python package) to embed in their own applications.

Highlights

  • SOTA Performance: Outperforms HippoRAG 2 on 8 of 9 Recall metrics across HotpotQA, 2WikiMultiHopQA, and MuSiQue datasets.
  • Local-First: Bundled desktop app requires no external database installation; uses SQLite and LanceDB by default.
  • Source Traceability: Every retrieval result and citation maps directly back to the original source chunk.
  • Integration Ready: Includes an OpenAI-compatible chat endpoint and an official MCP Skill for agents like Claude Code.
  • Interactive Exploration: Features an "Explore mode" to visualize the knowledge base as an interactive universe of events and entities.