pdf-chatbot-browser / README.md
ghostofpk20's picture
Upload README.md
ac09258 verified
|
Raw
History Blame Contribute Delete
2.7 kB
# πŸ“„ 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