# 📄 PDF Chatbot — Runs in Your Browser A **zero-server, zero-API-key** chatbot that lets you ask questions about your PDFs using lightweight AI models running entirely in your browser. 🔗 **Live Demo**: https://huggingface.co/spaces/ghostofpk20/pdf-chatbot-browser --- ## 🚀 Try It Now (No Installation!) Just open the link above and start chatting with your PDFs. That's it. > **First use only**: The AI embedding model (~22MB) downloads from Hugging Face. After that, it works **completely offline**. --- ## 🧠 How It Works | Step | What Happens | |------|-------------| | 1. Upload PDF | PDF.js extracts text entirely in your browser | | 2. Chunk & Index | Text is split into chunks; each chunk gets an AI embedding vector | | 3. Ask Question | Your question is embedded; top-K matching chunks are retrieved | | 4. Get Answer | Best sentences from matching chunks are extracted and returned | All processing happens **locally** — your PDFs never leave your device. --- ## 🎯 Key Features - ✅ **Fully offline** after first download — no servers, no API keys - ✅ **Drag & drop** PDF upload - ✅ **Multiple PDFs** — chat with any uploaded document - ✅ **WebGPU acceleration** — 5-10x faster on Chrome/Edge with GPU - ✅ **WASM fallback** — works on any modern browser - ✅ **Keyword fallback** — still searches if AI model fails - ✅ **Sources shown** — every answer includes the document excerpts used - ✅ **No scanned PDFs** — text-based PDFs only (browser limitation) --- ## 📦 Chrome Extension (Bonus) Download `chrome-extension.zip` from the files tab and load it as an unpacked extension in `chrome://extensions/`. --- ## 🛠️ Models Used | Model | Size | Purpose | |-------|------|---------| | `Xenova/all-MiniLM-L6-v2` | ~22MB (q8) | Text embeddings for document retrieval | - **ONNX quantized** to 8-bit for minimal memory - **Runs via Transformers.js** + ONNX Runtime Web - **Answers are extractive** — no LLM hallucinations, just facts from your document --- ## 🔒 Privacy - **Zero network calls** after model download - **Your PDFs never leave your browser** - **No analytics, no tracking, no API keys** - Everything stays in browser memory only --- ## 📋 Browser Support | Browser | Status | |---------|--------| | Chrome 113+ | ✅ Full (WebGPU) | | Edge 113+ | ✅ Full (WebGPU) | | Firefox | ⚠️ WASM fallback | | Safari 17.4+ | ⚠️ WebGPU in preview | --- ## 🙏 Credits - [Transformers.js](https://huggingface.co/docs/transformers.js) — ML in the browser - [PDF.js](https://mozilla.github.io/pdf.js/) — PDF text extraction - [ONNX Runtime Web](https://onnxruntime.ai/) — Model inference