AI Contract & Policy Assistant (RAG)
✦ Project Overview
An enterprise-ready Retrieval-Augmented Generation system purpose-built for legal and HR document workflows. Users upload contracts or policy documents (PDF, DOCX, TXT) and immediately ask plain-English questions, extract specific clauses, generate concise summaries, or compare clauses against standard templates — all grounded in the actual document text with zero hallucination risk.
✦ Key Features
- ♥Multi-format document ingestion (PDF via PDFPlumber, DOCX via python-docx, TXT) with automatic text chunking and FAISS-indexed dense vector embeddings using Sentence-Transformers (all-MiniLM-L6-v2).
- ♥Natural language Q&A over any contract clause with retrieved-chunk transparency — users see exactly which passages informed each answer, building trust in the system's responses.
- ♥One-click document summarization and clause comparison against standard templates, highlighting deviations — designed for legal professionals and HR teams who need fast insights without reading entire documents.
- ♥Full-stack delivery: a FastAPI + Python RAG backend, a React + TypeScript (Vite) frontend, and a lightweight Flask news proxy service — all running concurrently for a complete, production-like architecture.
- ♥Persistent multi-query session support: upload once and ask unlimited questions without re-processing the document, significantly reducing latency for iterative contract reviews.
✦ Methodology
A clean, enterprise-oriented RAG pipeline designed to ground every answer in source material and expose retrieval evidence to the user:
Document Parsing & Chunking
PDFPlumber and python-docx extract raw text from uploaded files. The text is split into semantically coherent chunks that balance retrieval precision (small enough to be specific) with context completeness (large enough to be meaningful).
FAISS Vector Indexing
Each chunk is encoded into a dense embedding vector using Sentence-Transformers (all-MiniLM-L6-v2) and indexed in a local FAISS store, enabling sub-millisecond similarity search across arbitrarily large documents without any cloud dependency.
Grounded Generation & Clause Comparison
Retrieved top-k chunks are injected directly into the Gemini LLM prompt as grounding context, constraining the model to only draw on document content. For clause comparison, the same pipeline diffs extracted clauses against a stored standard template and surfaces deviations in plain language.