Project 05 / 10 · RAG & NLP
DocuQuery AI Assistant
Production RAG system for natural-language QA over PDFs — hybrid retrieval with LangGraph multi-intent orchestration. Submitted to IEEE Access.
01 / Context
The problem
Document questions vary between conceptual paraphrases, noisy OCR text, multilingual passages, and exact identifiers. A single fixed retrieval blend can silently favor one query type while weakening another.
02 / System workflow
From input to output
- 01PDF upload
- 02Hierarchical chunks
- 03Three retrievers
- 04Rerank + diversify
- 05LangGraph intent
- 06Grounded answer
03 / Architecture
Inside the system
pypdf extraction with OCR fallback feeds a two-scale hierarchical chunker that preserves semantic boundaries.
FAISS dense search, BM25, and TF-IDF candidates are fused, cross-encoder reranked, and diversified with MMR; Pinecone is available as an optional cloud index.
LangGraph routes QA, summarisation, comparison, and refinement before Gemini generates an answer with confidence and evidence chunks.
04 / Engineering decisions
What shaped the build
Decision 01
Hybrid by evidence
Lexical and dense retrieval are benchmarked separately so fusion strengths and failure modes remain visible.
Decision 02
CPU-aware embeddings
MiniLM remains the default for accessible deployment, while the benchmark documents the quality lift from a larger MPNet embedder.
Decision 03
Reproducible evaluation
The benchmark covers 1,000 passages and 100 queries across four scenarios with McNemar tests and bootstrap confidence intervals.
05 / Evidence
Measured, not implied
1.00
Clean Recall@5
Hybrid retrieval on clean paraphrase and multilingual scenarios.
+73pp
OCR robustness
Gain over dense-only retrieval with 2% character corruption.
47ms
P95 end to end
Local query-to-extractive-answer latency over 1,000 chunks.
06 / Delivery
What shipped
- 01The Gradio application accepts multiple PDFs, supports follow-up questions and document comparison, and exposes extracted text and chunk previews.
- 02Conversations export to TXT, PDF, or DOCX.
- 03The application is deployed as a Hugging Face Space with configurable Gemini and Pinecone integrations.
Constraint documented
Pure BM25 beats the fixed hybrid on rare identifier lookups because dense scores dilute exact-match evidence. That documented failure motivates query-aware fusion gating.