# rag-doc-qa

A reference implementation of production-style retrieval-augmented generation for document question answering, combining hybrid retrieval, citation grounding and a streaming chat API.

rag-doc-qa goes beyond a vector-search-and-prompt demo with hybrid retrieval that fuses sparse BM25 and dense embeddings through reciprocal rank fusion, citation grounding that ties every answer token to a verifiable source span, and a streaming FastAPI service built to survive around 1,000 concurrent users.

Ingestion supports PDF, DOCX, HTML, Markdown, Notion exports, plain text and Confluence pages, with recursive character-and-token chunking and per-format heading awareness. Retrieval can use a hosted embedding model or a local model, with an optional cross-encoder reranking step, and evaluation measures context precision and recall, faithfulness and answer relevancy across embedding models and chunk sizes.

Vector storage is pluggable between Chroma for local development and pgvector for production Postgres deployments behind the same interface. The service exposes ingest, query, serve, evaluate and bench commands through a CLI, structured JSON logging, OpenTelemetry hooks and three YAML configuration profiles for base, local and production use.

Website: https://github.com/tainguyen07/rag-doc-qa
