Browse by type
GroundedAI (repo: production-rag-assistant)
Your RAG research assistant where citations are enforced by code, not requested by prompts.
Ask your statutes, contracts, and papers questions. Grounded answers scoped to the legal or academic workspace — every claim carries a verbatim quote, checked against the source it cites.
AI assistants answer questions about your documents — and then guess.
ChatGPT guesses. GroundedAI verifies — every claim, against the source, before you see it.
Retrieval-Augmented Generation (RAG) with a citation validation gate on top: retrieve only your document's passages, ground the answer on them, then reject any sentence that isn't cited.
Upload a PDF → ask a question → get an answer where every factual sentence carries a page-level [SOURCE N] citation, validated by schema before the answer reaches you.
| Step | What happens | Why it matters |
|---|---|---|
| 1. Ingest | PyMuPDF parses pages, text split into tight 256-char chunks, embedded, stored with tenant isolation | Page numbers survive to citation time |
| 2. Retrieve | BM25 (exact keywords) ∥ vector (semantic) → Reciprocal Rank Fusion → cross-encoder rerank | Right passage found even when wording differs |
| 3. Answer | LLM grounded on retrieved chunks only; identifies sources first, then answers | Model reasons over evidence, not memory |
| 4. Validate | Pydantic requires every claim to carry a citation, and checks each quote appears verbatim in the chunk it cites | Uncited or misquoted claims are rejected before you see them |
| 5. Abstain | Sources insufficient → "I don't have enough information" | Honesty over completeness |
Validation is a code-level gate, not a prompt instruction. The model cannot skip it.
| You need | GroundedAI |
|---|---|
| Answers in your domain | Two workspaces on one engine: legal reports what statutes say (no legal advice, strict abstain); academic answers from your papers with provenance |
| Trustworthy answers | Faithfulness 1.00 (n=5) on golden set — every claim grounded in your corpus, or the system says so |
| Verifiable citations | Per-sentence [SOURCE N] + page numbers — click through to the source text |
| Honesty by default | Abstains instead of fabricating when your corpus lacks the answer |
| Choice of models | Groq (free) → Anthropic → OpenAI failover; add your own key in the sidebar |
| Privacy | Multi-tenant isolation (your docs invisible to others) or self-host entirely |
| Free to start | Live demo free; no card required |
| Yours to run | Open source core — FastAPI + React + Qdrant Cloud in one deploy |
| Differentiator | What most demos do | What this does |
|---|---|---|
| Citation enforcement | Prompt says "cite sources" | Pydantic requires a citation on every claim; quote containment checked against the cited chunk |
| Retrieval | Vector-only | BM25 ∥ vector → RRF → cross-encoder rerank |
| Latency forensics | Guess at slowness | Langfuse traces (n=141, local cross-encoder, 2026-06): reranker is the bottleneck — measured, not guessed |
| Provider resilience | Single LLM, dies on rate limit | Groq → Anthropic → OpenAI failover with retry + exponential backoff |
| If you are... | This solves... |
|---|---|
| A researcher | Cross-paper synthesis without manual skimming; every claim traceable to a page |
| A grad student | Citeable answers you can actually reference in writing |
| An engineer | Extracting implementation details from technical papers |
| A lawyer / legal team | Statute and contract Q&A with report-not-advice discipline and strict abstain |
| An academic | Literature review support that won't invent citations |
One engine, domain-specific profiles — prompt behavior, citation format, and retrieval tuned per workspace.
| Workspace | Status | What it does |
|---|---|---|
| Academic | 🟢 Live | Paper citation, cross-paper synthesis, provenance on every claim |
| Legal | 🟢 Live | Statute-focused reporting, no legal advice, strict abstain when sources don't support an answer |
| Medical | 📋 Phase 2 | Clinical guidelines, PubMed corpus, ICD-10 coding assistance — citation-verified medical Q&A |
| Bangla | 📋 Phase 2 | Multilingual embeddings (multilingual-e5) + Bangla OCR for scanned legal docs |
The core engine (hybrid retrieval + citation verification + workspace profiles) is domain-agnostic. Future domains change prompt profiles and chunk metadata — not the pipeline.
tenant_id filter on every read pathHybrid Retrieval-Augmented Generation stack. How each piece solves part of the problem:
| Layer | Technology | Problem it solves |
|---|---|---|
| PDF parsing | PyMuPDF | Page-aware extraction → real page numbers in citations |
| Chunking | LangChain RecursiveCharacterTextSplitter | 256-char chunks, 100 overlap → tight context, less noise to fabricate from |
| Embeddings | Voyage AI voyage-4-lite |
API-only semantic search; Render-safe |
| Vector store | Qdrant Cloud | Managed similarity search + payload filters for tenant/workspace isolation |
| Sparse retrieval | BM25 | Exact keyword match for terms like "scaled dot-product attention" |
| Fusion | Reciprocal Rank Fusion | Combines keyword + semantic rankings without score normalization |
| Reranker | Voyage AI voyage-rerank-3-lite |
API-only cross-encoder reranking |
| LLM | Groq / Anthropic / OpenAI | Fast default (free Groq), user choice, failover on rate limits |
| Orchestration | LangChain | Provider-agnostic chains, retries, structured output |
| Validation | Pydantic | Hard gate: uncited sentence → rejected response |
| UI | React SPA + FastAPI | Modern frontend, scoped API, Render Docker + static deploy |
| Observability | Langfuse (opt-in/sampled) | Production-safe tracing; off by default, sampled when enabled |
| Evaluation | Citation gates + Ragas | Quote-containment, recall and abstention gates on an 8-item adversarial set; Ragas metrics over the 29-item corpus when keys are funded |
| CI | GitHub Actions | ruff + fast tests on every PR and push to main (slow embedder tests skipped) |
PDF Upload
↓
PyMuPDF Parser — page-aware extraction
↓
RecursiveCharacterTextSplitter — 256 character chunks, 100 overlap
↓
Voyage AI `voyage-4-lite` embeddings
↓
Qdrant Cloud — managed vector store (tenant-isolated via payload filters)
↓
User Query
├── BM25 Search (Top 20)
├── Vector Search (Top 20)
↓
Reciprocal Rank Fusion (score = 1 / (k + rank), k=60)
↓
Voyage AI `voyage-rerank-3-lite` reranker
↓
Top 5 Chunks → Citation Prompt Builder (workspace profile)
↓
LLM Provider Chain (retry + exponential backoff + failover)
├── Groq (default llama-3.1-8b-instant) — free
├── Anthropic (Claude) — optional, user-provided key
└── OpenAI (GPT-4o) — optional, user-provided key
↓
Pydantic Citation Validator — every claim must cite; quotes checked against the chunk
↓
Final Response with page-level citations
Matches the in-app pricing modal:
| Free (live) | Pro (coming soon) | |
|---|---|---|
| Price | $0 | $9 / mo |
| Verified answers/day | 10 | 100 |
| Documents | 5 | 50 |
| Storage | 100 MB | 1 GB |
| Support | Community | Priority |
Teams ($29/mo, admin + SSO) planned with billing activation (Stripe; Bangladesh-local rails alongside).
| Domain / capability | Status | Notes |
|---|---|---|
| Medical domain | Planned | Clinical guidelines, PubMed corpus, ICD-10 coding assistance; citation-verified medical Q&A |
| Bangla support | Planned | Multilingual embeddings (multilingual-e5) + Bangla OCR for scanned legal docs |
| Legal domain expansion | Planned | Contract Act 1872, Companies Act 1994, case law corpus; section-aware retrieval |
| Reflective retrieval (T2) | Designed | LangGraph orchestrator: query → retrieve → reflect → re-retrieve → answer |
| Workflow agents (T3) | Designed | Domain agents: contract review, literature review, compliance check |
| bKash payments | Planned | Bangladesh-local payment rail alongside Stripe |
| Teams / orgs | Planned | Shared workspaces, admin controls, SSO |
| SSE streaming | Planned | Token-by-token answer streaming with citation markers |
| SPA frontend | Done | React/Vite SPA replaces Streamlit for production UX |
The engine stays shared; only prompt profiles, chunk metadata schemas, and citation formats change per domain (Legal / Academic / Medical / Bangla).
python3 eval/verify_eval.py, 8 adversarial cases over data/verify_eval.json:
| Gate | Score | Threshold | Status |
|---|---|---|---|
| Citation precision | 1.00 | 1.00 | PASS |
| Citation recall | 1.00 | 0.75 | PASS |
| Abstention accuracy | 1.00 | 1.00 | PASS |
Citation precision 1.00 — every quoted phrase appears verbatim in the chunk it cites.
Citation recall 1.00 — every expected citation is present (was 0.83 before deterministic verification landed).
Abstention accuracy 1.00 — out-of-corpus questions abstain instead of guessing.
Cases: 2 out-of-corpus, 2 conflicting-sources, 2 proviso, 1 missing-cross-reference, 1 grounded-cite. Deliberately adversarial rather than a broad sample — n=8 is small, and these target the failure modes that matter for legal text.
Per-case outcome: 6 verified, 1 partial (legal-conflicting-101), 2 abstained (both out-of-corpus, correctly). The partial is a real gap, not noise — see Known limitations.
| Metric | Score | Threshold | Status |
|---|---|---|---|
| Faithfulness | 1.00 | 0.75 | PASS |
| Answer relevancy | 0.88 | 0.75 | PASS |
| Context recall | 1.00 | 0.70 | PASS |
| Context precision | 0.375 | 0.70 | FAIL |
**Fai
$ claude mcp add production-rag-assistant \
-- python -m otcore.mcp_server <graph>