# document.ai (EAER)

> Traceable, version- and time-aware enterprise RAG: every answer names the document, version and passage it came from, and whether that rule was in force on the date you ask about

- Category: Retrieval & Knowledge (RAG) / RAG Frameworks & Platforms
- Language: Python
- Licence: AGPL-3.0
- Repository: https://github.com/GanymedeNil/document.ai
- Canonical page: https://ai-tldr.dev/tools/document-ai-eaer/

## In short

document.ai (EAER) is Traceable, version- and time-aware enterprise RAG: every answer names the document, version and passage it came from, and whether that rule was in force on the date you ask about. It sits in the RAG Frameworks & Platforms category of the Retrieval & Knowledge (RAG) tools and is open-source, written in Python and licensed AGPL-3.0.

## Overview

document.ai, whose current engine is called EAER, is a self-hosted question-answering system for an organisation's internal documents such as policies and regulations. Its premise is that finding a similar-looking paragraph is not the same as answering correctly: rules get revised, repealed and overridden by later notices. So every answer shows which document it came from, which version, which passage, and whether that evidence was valid on the date the question cares about. Versions, validity periods, permissions and verification are treated as part of answering, not as add-ons.

Questions go through a router that picks one of three modes. Fast answers from a single retrieval; Deep follows plan templates (comparison, multi-hop, causal) and retrieves step by step; Verified adds a semantic check and targeted re-retrieval after answering. When evidence is insufficient the router escalates, and if the budget runs out without confirmation it refuses to answer. A verification layer runs deterministic code checks (the cited evidence was retrieved in this run, the user may see it, the location matches the source text, numbers and dates appear in the evidence, the evidence was in force at the target time) and leaves the model only the judgement of whether the evidence supports the conclusion.

The stack is a FastAPI service described by an OpenAPI 3.1 spec, LangGraph orchestration, OpenSearch for retrieval and PostgreSQL for versions, validity periods, permissions, audit records, jobs and checkpoints, plus a simple Next.js web UI and a reference model server for Qwen3-Embedding and Qwen3-Reranker. Generation goes to any OpenAI-compatible service such as DeepSeek. The repository has existed since 2023, when document.ai was a vector-database plus GPT-3.5 local knowledge base with a medical Q&A demo; that version is kept under legacy/ and tagged msd-demo-2023. The project is licensed AGPL-3.0, and its documentation is written in Chinese.

## What it does

- Three execution modes (Fast, Deep, Verified) chosen by a router that escalates when evidence is thin and refuses to answer once the budget is spent without confirmation
- A verification layer where code checks citations, permissions, source locations, numbers, dates and validity, and the model only judges whether the evidence supports the claim; unverified points are labelled and unsupported ones removed
- Three kinds of time query: what is in force now, what was actually in force on a given day, and what the system knew as of a given day, with each effective date marked as stated, inferred or unknown
- A document lifecycle of upload, review, searchable and archived, where a new version's effective date sets the old version's expiry and version history is append-only so past answers can be reproduced
- Permissions enforced in code on every retrieval and re-checked in the database before results return, with inaccessible and non-existent documents both answering 404
- Parsing of Word and HTML natively and of PDF, scans, PPTX, XLSX and images through Docling with OCR, with tables split into captioned cell-level evidence
- Prompt-injection defences that fence evidence inside a randomised boundary, flag instruction-like text to reviewers at ingestion, and route answers that cite it to Verified mode

## Getting started

The README's quick start needs Python 3.14, Docker, Node.js 20.9 or later for the web UI, and an OpenAI-compatible generation service such as DeepSeek. These steps follow it for a local development setup; the production deployment with admission checks, backups and smoke tests is described in the repository's deployment guide.

1. Start PostgreSQL and OpenSearch

   Clone the repository and bring up the development dependencies (PostgreSQL 18.6 and OpenSearch 3.9.0) with Docker Compose.

```bash
git clone https://github.com/GanymedeNil/document.ai.git
cd document.ai
docker compose -f docker-compose.dev.yml up -d
```

2. Install the Python dependencies

   Create a Python 3.14 virtual environment. To parse PDFs, scans, PPTX, XLSX and images, install requirements-docling.txt instead, which includes PyTorch.

```bash
python3.14 -m venv .venv && .venv/bin/pip install -r requirements.txt
```

3. Configure the models in .env

   Generation, embedding and reranking are configured separately in a .env file at the repository root (the template is deploy/eaer.env.example). This example from the README uses DeepSeek for generation and local Qwen3 models for embedding and reranking.

```bash
EAER_GEN_BASE_URL=https://api.deepseek.com
EAER_GEN_API_KEY=your-key
EAER_GEN_MODEL=deepseek-flash
EAER_GEN_TEMPERATURE=0
EAER_EMBED_BASE_URL=http://127.0.0.1:8100/v1
EAER_EMBED_MODEL=Qwen3-Embedding-0.6B
EAER_EMBED_DIMS=1024
EAER_RERANK_BASE_URL=http://127.0.0.1:8100/v1
EAER_RERANK_MODEL=Qwen3-Reranker-0.6B
```

4. Run the local model server

   The bundled reference model server serves /v1/embeddings and /v1/rerank on MPS (Mac) or CUDA (Linux) and downloads the models on first run.

```bash
.venv/bin/python -m modelserver --port 8100 --env-file .env
```

5. Create the database and index, then start the API and worker

   Point EAER at the database, a file storage directory, a token file (format in deploy/tokens.example.json) and OpenSearch. EAER_ADMISSION=off skips the admission checks for local development so Deep and Verified modes are available straight away.

```bash
export EAER_DATABASE_URL=postgresql://postgres:postgres@localhost:5432/eaer
export EAER_STORAGE_DIR=$PWD/files
export EAER_TOKENS_FILE=$PWD/deploy/tokens.json
export EAER_OPENSEARCH_URL=http://localhost:9200
export EAER_ADMISSION=off
set -a; . ./.env; set +a
.venv/bin/alembic upgrade head
.venv/bin/python -m eaer.ingestion rebuild --build-id b1
.venv/bin/uvicorn eaer.api.main:app --port 8000 &
.venv/bin/python -m eaer.ingestion &
```

6. Open the web UI

   The Next.js demo UI covers chat, evidence and full-text views, upload, review, archiving and identity switching to compare permissions. It runs on port 3200.

```bash
cd web && npm ci && npm run dev
```

## When to use it

- Answer staff questions about internal policies and regulations where the correct answer depends on which version was in force on a particular date
- Run a document Q&A service that must show auditable citations to the exact document version and passage behind each conclusion
- Serve one knowledge base to users with different access rights without the answers revealing that restricted documents exist
- Replace a plain hybrid-RAG setup that returns similar but superseded text with one that tracks versions, validity periods and refusals
