"Your documents. Your device. Your data."
PrivateDoc AI is an offline, privacy-first on-device document intelligence and RAG (Retrieval-Augmented Generation) application built for the AI Build Challenge — Bengaluru (PS-001 Qualcomm Edge AI Track).
Designed for environments handling confidential records (medical dossiers, legal agreements, corporate intellectual property, and financial statements), PrivateDoc AI ensures that all document parsing, chunking, embeddings, vector indexing, and retrieval execute locally on the host device without external cloud AI dependencies.
Organizations and individuals handling confidential documentation face a difficult trade-off:
- They require semantic search, cross-document comparison, and synthesized question-answering across complex documents.
- Public cloud AI services (OpenAI, Anthropic, Gemini, hosted vector DBs) present compliance, confidentiality, and data residency concerns.
- Cloud dependencies fail in air-gapped, field-deployed, or low-connectivity environments.
PrivateDoc AI executes every stage of the document intelligence pipeline on local edge hardware:
- Local Text Extraction: PyMuPDF parses PDF, TXT, and Markdown files locally.
- Page Coordinate Preservation: Every extracted passage strictly retains its source
document_id,filename, and 1-basedpage_number. - Deterministic Chunking: Pages are chunked with configurable token/word boundaries (250 words, 40-word overlap) strictly bounded by page numbers to eliminate cross-page bleeding.
- Local Embeddings: Dense 384-dimensional semantic vectors are generated on-device using local
all-MiniLM-L6-v2weights. - Local Vector Index: Vector indexing and cosine similarity search are executed locally via FAISS (
IndexFlatIP). - Programmatic Citations: Citations are derived directly from deterministic retrieval metadata (filename, page number, chunk ID, exact supporting text)—never hallucinated by an LLM.
- Strictly Grounded RAG Orchestration: Prompts enforce negative constraints ("Answer ONLY using supplied context; if absent, state 'I couldn't find that information in the indexed documents.'").
- Multi-Document Comparison: Queries retrieve and attribute evidence across multiple documents with distinct page-level source citations.
- Zero External API Calls: The core pipeline operates without any external network connections.
[ Sensitive Documents: PDF / TXT / MD ]
│
▼
[ PyMuPDF Local Parser ]
│ (Page metadata preserved)
▼
[ Deterministic Chunker ]
│ (Strictly page-bounded)
▼
[ EmbeddingProvider: Local ] ───────► [ QualcommEmbeddingProvider (Snapdragon Target) ]
│ (384-dim float32)
▼
[ Local FAISS Index ] ◄──────────► [ SQLite Metadata Store ]
│
[ User Query / Prompt ]
│
▼
[ Local Retriever ]
│ (Cosine similarity + Threshold)
▼
[ Relevant Evidence Passages ] ───► [ Programmatic Citation Engine ]
│ │
▼ ▼
[ Grounded Context Prompt ] [ Page-Level Citations ]
│
▼
[ LLMProvider: Local ] ──────────► [ QualcommLLMProvider (Snapdragon Target) ]
│
▼
[ Grounded Answer + Source Passages ]
- Extraction: PyMuPDF extracts text page-by-page, assigning 1-indexed page numbers and checking text density.
- Chunking:
DocumentChunkerapplies a 250-word sliding window with a 40-word overlap, constrained strictly within individual pages. - Embedding:
LocalSentenceTransformerProvidercomputes L2-normalized 384-d vectors withHF_HUB_OFFLINE=1. - Indexing: FAISS
IndexFlatIPindexes vectors with parallel persistence in SQLite andchunks.json. - Retrieval:
LocalRetrievercomputes inner product similarity and filters byRELEVANCE_THRESHOLD(0.25). - Attribution:
CitationBuilderformats source cards containing filename, page number, chunk ID, and exact snippet. - Refusal: If no chunks meet the threshold, the system immediately returns:
"I couldn't find that information in the indexed documents."
| Component | Execution Mode | Cloud AI Used | Telemetry |
|---|---|---|---|
| Document Storage | Local filesystem (backend/data/documents/) |
None | None |
| Metadata Store | Local SQLite (backend/data/metadata/privatedoc.db) |
None | None |
| Text Parsing | Local PyMuPDF (fitz) |
None | None |
| Embeddings | Local CPU (backend/models/all-MiniLM-L6-v2/) |
None | None |
| Vector Search | Local FAISS in-memory index | None | None |
| Generation | Local GGUF (when configured) / Unconfigured fallback | None | None |
| Network Traffic | Bound to 127.0.0.1 / Localhost only |
None | None |
- Frontend: React 18, TypeScript, Vite, Tailwind CSS, Lucide React icons.
- Backend API: Python 3.12, FastAPI, Pydantic v2, SQLite 3.
- Document Extraction: PyMuPDF (
fitz). - Vector Search: FAISS (
faiss-cpu,IndexFlatIP). - Embeddings: SentenceTransformers (
all-MiniLM-L6-v2). - LLM Runtime Interface:
llama-cpp-python/ GGUF model interface. - OCR Interface: Abstract
OCRProvider(Local Tesseract / Qualcomm boundary).
- Windows 10/11 (or Linux/macOS)
- Python 3.10+ (tested on Python 3.12)
- Node.js v18+ & npm
The project root is:
C:\Users\ADMIN\engg\projects\qualc
cd C:\Users\ADMIN\engg\projects\qualc\backend
pip install -r requirements.txtVerify or copy the environment configuration:
cp .env.example .envcd C:\Users\ADMIN\engg\projects\qualc\frontend
npm installThe embedding model is stored locally on disk at:
backend/models/all-MiniLM-L6-v2/
The application loads weights locally from this path with HF_HUB_OFFLINE=1 and TRANSFORMERS_OFFLINE=1 set in the environment.
Note
GGUF Weights are NOT bundled with this repository to keep the repository size lightweight.
- When no GGUF file is present, the system truthfully reports:
- System Status:
LLM: NOT CONFIGURED - Privacy Status:
Generation: LOCAL / NOT CONFIGURED - RAG Answer:
"Local LLM is not configured. Supporting document evidence has been retrieved and cited below directly from the indexed document passages." - Full retrieval, source citations, document inspection, and unknown-question refusal remain 100% operational.
- System Status:
- To enable local generative synthesis:
- Download any compatible GGUF model (e.g.
Qwen2.5-1.5B-Instruct-Q4_K_M.gguforPhi-3-mini-4k-instruct-q4.gguf). - Place the file at
backend/models/model.gguf. - Restart the backend server.
- Download any compatible GGUF model (e.g.
Run the automated pytest test suite from the repository root:
cd C:\Users\ADMIN\engg\projects\qualc
python -m pytest -qExpected Real Result: 28 passed, 1 warning (includes comprehensive tests for documents, chunking, FAISS vector store, local embeddings, retrieval, citations, RAG queries, and on-device OCR engine).
cd C:\Users\ADMIN\engg\projects\qualc\backend
python -m uvicorn app.main:app --host 127.0.0.1 --port 8000Interactive OpenAPI documentation is available at http://127.0.0.1:8000/docs.
cd C:\Users\ADMIN\engg\projects\qualc\frontend
npm run devOpen http://127.0.0.1:5173 in your browser.
cd C:\Users\ADMIN\engg\projects\qualc
python scripts/verify_four_docs.py- Offline Execution: NOT INDEPENDENTLY VERIFIED
- Explanation: Local processing architecture is verified. Independent network-isolation/air-gap testing was not performed in this development environment.
- Local Processing Guarantees:
- All document processing, chunking, vector indexing, and retrieval execute locally.
- Cloud AI is not used (no OpenAI, Gemini, Anthropic, or external inference APIs).
- Application network communication is localhost-only (
127.0.0.1). - Zero external AI or cloud dependencies.
The provider abstractions allow Qualcomm-specific inference implementations to be integrated later. Snapdragon hardware execution has not been validated in this development environment.
The codebase provides clean provider abstractions ready for future Qualcomm Snapdragon target integration:
QualcommEmbeddingProvider(backend/app/services/embeddings.py): Interface for future Qualcomm AI Hub ONNX / QNN embedding integration.QualcommLLMProvider(backend/app/services/llm.py): Interface for future Snapdragon Genie / GenieX on-device GenAI runtime integration.QualcommOCRProvider(backend/app/services/ocr.py): Interface for future Snapdragon on-device OCR integration.
When integrating Qualcomm-specific runtimes in the future, only the provider implementations need to be supplied; all document ingestion, chunking, FAISS vector indexing, citation mapping, and React UI remain identical.
- Local LLM Weights: Generative text synthesis requires placing a compatible
.gguffile atbackend/models/model.gguf. Without it, the system delivers retrieved source passages and exact citations without generative paraphrasing. - OCR Availability: Local OCR uses on-device Tesseract for scanned/image-based PDFs. It dynamically discovers the binary via:
TESSERACT_CMDenvironment variablesettings.TESSERACT_CMDin.env(e.g.TESSERACT_CMD=C:\Program Files\Tesseract-OCR\tesseract.exe)- System PATH lookup (
tesseract.exe) - Standard Windows directories (
C:\Program Files\Tesseract-OCR\tesseract.exe,%LOCALAPPDATA%\Programs\Tesseract-OCR\tesseract.exe) When absent from the host, the system truthfully reportsOCR: NOT CONFIGUREDand safely marks scanned PDFs asNeeds OCRwithout failing. Text-based PDFs process with full fidelity via PyMuPDF.
- Hardware Acceleration: Currently executes using PyTorch CPU and FAISS CPU on Windows x86_64.
- Package quantized ONNX models for Qualcomm QNN Execution Provider.
- Integrate Qualcomm Snapdragon Genie SDK for on-device LLM inference.
- Add local vision model integration for scanned document analysis.
- Provide zero-install single-executable desktop packaging using Tauri or Electron.