█

AI/TLDR

मुझे पिलाएं कॉफ़ी
मुझे एक कॉफ़ी पिलाएँ

SAG

Event-entity indexing और SQL-driven retrieval पर बना self-hosted knowledge base

RAG Frameworks & Platformsओपन सोर्स
ताज़ा
v1.8.11
अपडेट किया गया
23 सित॰ 2026
भाषा
Python
लाइसेंस
MIT
$git clone https://github.com/Zleap-AI/SAG.git

नया क्या है

v1.8.1123 सित॰ 2026

Removes automatic migration of legacy knowledge-base storage: when incompatible old data is detected, SAG keeps a backup, accounts and model settings and asks the user to confirm a fresh rebuild and re-upload documents.

संक्षेप में

SAG क्या है?

SAG Event-entity indexing और SQL-driven retrieval पर बना self-hosted knowledge base. यह Retrieval & Knowledge (RAG) टूल्स की RAG Frameworks & Platforms श्रेणी में आता है; ओपन सोर्स है, Python में लिखा गया है और MIT लाइसेंस के तहत है। शुरू करने के लिए: docker Compose से SAG शुरू करें.

अपडेट किया गया Markdown वर्शन ↗

सारांश

SAG, Zleap का एक ओपन सोर्स knowledge base application है, जो इसी नाम की retrieval architecture पर बना है (SQL-Retrieval Augmented Generation with Query-Time Dynamic Hyperedges)। आप documents एक बार upload करते हैं; SAG उन्हें Markdown में parse करता है, chunks में बाँटता है, embed करता है, events और entities निकालता है, और हर retrieval result को मूल text से जुड़ा रखता है। इसके बाद आप sources में search कर सकते हैं, event-entity graph देख सकते हैं, ऐसे agent से सवाल पूछ सकते हैं जिसके जवाब clickable citations के साथ आते हैं, या वही knowledge दूसरे applications को दे सकते हैं।

Diagram from the SAG paper showing offline upload of chunks into events and entities stored in SQL and vector indexes, and online search expanding events through SQL joins over entities
The SAG architecture: chunks map to events and entities offline; queries expand through SQL joins at search time.SAG README (paper figure) ↗

Retrieval का डिज़ाइन इस प्रोजेक्ट का अपना है। हर chunk एक semantically complete event और कुछ हल्की entities में बदल जाता है, जो vector और full-text indexes के साथ relational tables में store होते हैं। Query के समय SAG seed entities और events ढूँढता है, shared entities पर SQL joins से एक local candidate set तैयार करता है, और केवल उसी query से जुड़े hyperedges बनाता है। इसलिए न कोई global graph बनाना पड़ता है, न उसे दोबारा बनाना, और नए documents धीरे-धीरे (incrementally) जोड़े जाते हैं। आउटपुट हमेशा मूल evidence chunks ही होता है। प्रोजेक्ट अपने arXiv paper में HotpotQA, 2WikiMultiHopQA और MuSiQue पर औसत Recall@5 90.07% और F1 72.96% बताता है; reproduction scripts एक अलग SAG-Benchmark repository में हैं।

यह app डिफ़ॉल्ट रूप से local-first और single-user है: यह SQLite और LanceDB पर चलता है, जिसके लिए कोई external database नहीं चाहिए, और PostgreSQL/pgvector, MySQL, OceanBase या Elasticsearch backends पर भी जा सकता है। इसकी तीन परतें अलग-अलग इस्तेमाल हो सकती हैं: एक Next.js web UI (जो Apple Silicon वाले macOS और Windows x64 के लिए desktop app के रूप में भी आता है), एक FastAPI backend जिसमें REST/OpenAPI, एक OpenAI-compatible chat endpoint और एक MCP server है, और PyPI पर मौजूद zleap-sag Python engine, जिसे आप अपनी service में embed कर सकते हैं।

SAG system-boundaries diagram: the web UI, custom frontends and external agents reach the FastAPI backend, which runs on the zleap-sag Python engine and relational plus vector storage
One engine, three ways in: the web UI, the self-hosted API and the zleap-sag Python engine.SAG README ↗

यह क्या करता है

  • Markdown, text, PDF और Office files को background में ingest करना: MarkItDown से parsing (configure होने पर PDF के लिए MinerU), chunking, embedding और event/entity extraction
  • दो modes में global या source-scoped search: Fast (vector similarity) और Precise (entity relationships और LLM reranking), और हर result को उसके मूल chunk तक वापस खोला जा सकता है
SAG search view listing ranked results for a query, with the original source chunk opened in a side panel
Search results with the original source chunk open beside them.SAG README ↗
  • एक डिफ़ॉल्ट agent जो आपके जोड़े गए sources से multi-turn सवालों के जवाब देता है, और clickable citations के साथ जवाब stream करता है
  • Event-entity index के लिए graph और 3D views, साथ ही Explore mode, जिससे events, entities और उनके relationships में आगे-पीछे घूमा जा सकता है
  • Integration surfaces: एक self-hosted REST/OpenAPI backend, एक OpenAI-compatible Chat Completions endpoint जो sag.citations field जोड़ता है, एक MCP server, Dify external knowledge base endpoint, और MCP को Codex या Claude Code से जोड़ने के लिए sag CLI
  • एक EngineConfig के पीछे pluggable storage: local में SQLite + LanceDB, और production में PostgreSQL/pgvector, MySQL, OceanBase और Elasticsearch
SAG agent chat view showing a structured answer with numbered citation markers and a sources summary
An agent answer with inline citations to the knowledge base.
Animated SAG Explore mode showing the knowledge base as a star field of events and entities with a search panel
Explore mode renders the whole knowledge base as an interactive map of events and entities.

शुरू करें

README में ये विकल्प दिए गए हैं: GitHub Releases से desktop installer, Docker Compose से self-hosted setup, और standalone zleap-sag Python engine। नीचे के steps Docker वाले रास्ते को फ़ॉलो करते हैं, फिर MCP CLI और Python engine दिखाते हैं। UI model credentials के बिना भी चल जाता है, लेकिन indexing के लिए embedding endpoint चाहिए, और extraction व जवाबों के लिए LLM।

Docker Compose से SAG शुरू करें

इसके लिए Docker Desktop, या Compose v2 वाला Docker Engine चाहिए। जब दोनों services healthy हो जाएँ, तो web app http://localhost:3000 पर और API docs http://localhost:8000/docs पर मिलेंगे। डिफ़ॉल्ट Compose file local (name-only) auth mode में 127.0.0.1 से bind होती है, इसलिए इसे किसी untrusted network पर expose न करें, जब तक SAG_AUTH_MODE को password पर न बदला जाए।

bashbash
git clone https://github.com/Zleap-AI/SAG.git
cd SAG
docker compose up -d --build

मॉडल configure करें और documents जोड़ें

local identity बनाने के लिए नाम दर्ज करें, फिर 302.AI quick setup इस्तेमाल करें या Settings → Models खोलकर किसी भी OpenAI-compatible LLM और embedding endpoint को configure करें। Source बनाएँ, documents upload करें, उनका status Ready होने तक इंतज़ार करें, फिर search करें या cited बातचीत शुरू करें।

MCP के ज़रिए अपने coding agent से SAG जोड़ें

आधिकारिक CLI (Node.js 20.19 या उसके बाद का संस्करण) स्थानीय Docker container खोजता है, जाँचता है कि MCP server जवाब दे रहा है, और उसे Codex या Claude Code में mount कर देता है।

bashbash
npm install --global @zleap-ai/sag-cli
sag mcp test
sag agent connect claude-code
sag agent status

या Python engine को सीधे embed करें

zleap-sag package (Python 3.11+) पूरा ingest, extract और search lifecycle चलाता है, और local storage ./.zleap/ के अंदर बनता है। इसे किसी भी OpenAI-compatible endpoint की ओर point करें।

pythonpython
pip install zleap-sag

# main.py
import asyncio
from zleap.sag import DataEngine, EngineConfig
from zleap.sag.config import EmbeddingConfig, LLMConfig

async def main() -> None:
    config = EngineConfig(
        llm=LLMConfig(
            api_key="sk-...",
            base_url="https://your-openai-compatible-host/v1",
            model="qwen3.6-flash",
        ),
        embedding=EmbeddingConfig(model="bge-large-en-v1.5"),
        language="en",
    )
    async with DataEngine(config) as engine:
        await engine.ingest("knowledge.md")
        await engine.extract()
        result = await engine.search(
            "Why is SAG effective for multi-hop retrieval?",
            strategy="multi",
            top_k=5,
        )
        for section in result.sections:
            print(section.get("content", "")[:200])

asyncio.run(main())

कमांड और कोड प्रोजेक्ट के अपने दस्तावेज़ों से लिए गए हैं — हमेशा जांचें आधिकारिक repo ताज़ा जानकारी के लिए।

कब इस्तेमाल करें

  • अपने documents पर एक निजी, self-hosted knowledge base चलाएँ, जहाँ हर जवाब और search hit को ठीक उसी मूल source chunk तक वापस ट्रेस किया जा सके
  • Claude Code, Codex या किसी दूसरे MCP host को SAG के MCP server और CLI के ज़रिए document collection पर retrieval दें
  • SAG को OpenAI-compatible model की तरह call करके मौजूदा app में cited retrieval जोड़ें, या Dify के लिए external knowledge base के रूप में इस्तेमाल करें
  • zleap-sag engine से अपनी Python service में multi-hop retrieval बनाएँ, शुरुआत SQLite और LanceDB से करें और बाद में PostgreSQL/pgvector पर जाएँ

How SAG compares

SAG alongside other open-source rag frameworks & platforms tools AI/TLDR tracks, ranked by GitHub stars.

टूलस्टारयह क्या करता है
Dify★ 162kLLM और RAG ऐप विज़ुअल कैनवास पर बनाने के लिए ओपन सोर्स प्लेटफ़ॉर्म
graphify★ 156kकोड, डॉक्स, PDF और इमेज वाले फ़ोल्डर को एक ऐसे नॉलेज ग्राफ़ में बदलें जिसमें query की जा सके
RAGFlow★ 95.1kगहरी डॉक्यूमेंट समझ और स्रोत से जुड़े, ट्रेस किए जा सकने वाले उद्धरणों वाला ओपन सोर्स RAG engine
Context7★ 65.8kनवीनतम, वर्ज़न-विशिष्ट लाइब्रेरी डॉक्स सीधे आपके कोडिंग एजेंट के प्रॉम्प्ट में
Pathway★ 61.9kडेटा बदलने के साथ-साथ अपडेट रहने वाली Python ETL और RAG पाइपलाइन
LightRAG★ 41kग्राफ़-आधारित RAG, जो आपके दस्तावेज़ों को क्वेरी योग्य नॉलेज ग्राफ़ में बदल देता है
PageIndex★ 40.9kVectorless, reasoning-based RAG जो लंबे डॉक्युमेंट से tree index बनाता है
SAG★ 3kEvent-entity indexing और SQL-driven retrieval पर बना self-hosted knowledge base