Grounding-ai is a local-first document processing and retrieval pipeline, positioned to provide AI agents with a standardized, citable local knowledge base. It transforms PDF, EPUB, DOCX, and Markdown documents into a structured, searchable corpus, and generates a separate embedding index for each agent. The entire process runs entirely locally, does not rely on cloud APIs, and does not collect telemetry data.
Purpose
- Build a local document corpus as a knowledge source for AI agents.
- Use retrieval-augmented generation (RAG) to let local language models answer questions based on documents, with citations such as page numbers and section titles.
- Support multi-agent scenarios, where each agent can access a different subset of documents.
Main capabilities
- Deterministic pipeline: The same input produces byte-identical output.
- Content provenance: Every document and chunk carries SHA-1, SHA-256, and BLAKE3 hashes to ensure traceability.
- Agent-based corpus partitioning: Define agents via YAML, filter the corpus by collection tags, and each agent has its own independent FAISS embedding index.
- Persona system: Agents can be configured with communication style, areas of expertise, and greetings.
- Staging watcher: After files are placed in a specified folder, automatically ingest, chunk, hash, and optionally update the embedding index.
- Multi-machine support: Optional Syncthing-based architecture for a dedicated ingestion server.
- Fully local: No cloud APIs, documents remain local.
- Agent RAG: A local LLM autonomously decides when to search the corpus via tool calls.
- MCP server: Provides a corpus search interface for MCP-compatible clients such as Claude Code and Cursor.
Usage
- Installation: Install from PyPI (
pip install grounding-ai) or from source. Get example configuration and agent files from the repository. - First run: Follow the typical session flow: place documents in the staging area, configure the agent YAML file, generate the embedding index, and then query.
- Create an agent: Create a YAML file in the
agents/directory, defining the name, description, persona (icon, style, areas of expertise, greeting), and corpus filter (collection tags). - Ingest documents: Use the
groundingcommand to specify the document path and corpus path, and set collection tags. Documents can belong to multiple collections. - Generate embeddings: Run
grounding embeddings --agent <名称> --corpus ./corpusto build a FAISS index for the agent containing only documents from matching collections. - Query: You can use
scripts/local_rag.pyto query with a local LLM such as Ollama, with agent mode supported; or via the MCP server, callsearch_corpusin a compatible client to search. - Staging watcher: Optional, used for automatic ingestion. On Linux,
inotify-toolsmust be installed; on macOS,fswatchis required, but the provided script usesinotifywait, so macOS users typically need to run the watcher in a Linux VM/container. - Multi-machine setup: Point paths to a Syncthing shared directory, run the watcher on a dedicated ingestion server, and workstations synchronize the corpus and embedding index.
Applicable scenarios
- Teams or individuals that need to process sensitive documents locally and build a private knowledge base.
- Multi-agent systems that want to assign different domains of knowledge to different agents.
- Q&A applications that require citable and verifiable answers.
- Scenarios using local LLMs such as Ollama for retrieval-augmented generation.
Limitations
- Requires Python 3.10 to 3.13; versions 3.14 and above are not supported (due to
unstructuredcompatibility issues). - Requires the system package poppler-utils for PDF text extraction.
- Optional dependency on Ollama for local RAG queries.
- The staging monitor script on macOS is not directly compatible and requires additional handling.
- Scanned PDFs may be skipped due to having no extractable text; use the --ocr option to force OCR.
- Initial run evaluation showed a 96% answer correctness rate with the corpus and 46% without it, but citation verification did not pass its own consistency threshold, so citation accuracy was not reported.
- The public CI only includes a mini corpus of three synthetic documents for regression detection, not as a quality benchmark.
- Financial information such as prices and fees is not provided at this time.