Spaces:
Sleeping
Sleeping
Upload 2 files
Browse filesFiles changed (2)
- README.mdAdded+214
- requirements.txtAdded+14
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214---title: QueryVaultemoji: ๐ฌcolorFrom: bluecolorTo: greensdk: gradiosdk_version: "4.36.1"python_version: "3.11"app_file: app.pypinned: falselicense: mit---
# ๐ QueryVault โ PDF Question Answering Bot
> Ask questions about any PDF document and get intelligent, context-aware answers powered by **Groq API (Llama-3.3 70B Instruct)**, **LangChain RAG**, and an **ephemeral ChromaDB**.

๐ **Live Demo:** [Try QueryVault on Hugging Face Spaces!](https://huggingface.co/spaces/Padmini1/queryvault)
---
## ๐ง How It Works
QueryVault implements a full **Retrieval-Augmented Generation (RAG)** pipeline:

### ASCII Representation:```PDF Upload โ โผPyPDFLoader โโโโ loads raw text from all pages โ โผRecursiveCharacterTextSplitter โโโโ splits into ~1000-char chunks โ โผHuggingFace Local Embeddings โโโโ converts each chunk to a vector โ โผChromaDB โโโโ stores and indexes all vectors in-memory (per PDF) โ โผUser Question โโโบ similarity search โโโบ top-3 relevant chunks retrieved โ โผLlama-3.3 70B Instruct (ChatGroq) โโโโ reads context + question โ generates answer โ โผGradio UI โโโโ displays the answer to the user```
---
## ๐๏ธ Project Structure
```queryvault/โโโโ app.py # Gradio web interface โ run this to start the appโโโโ src/โ โโโ __init__.pyโ โโโ qabot.py # Full RAG pipeline: loader โ splitter โ embedder โ retriever โ LLM โ chainโโโโ docs/โ โโโ DECISION_STRUCTURE.md # Full design decisions explained in plain Englishโโโโ requirements.txt # All Python dependenciesโโโ .env.example # Credential template (rename to .env and fill in)โโโ .gitignoreโโโ README.md```
---
## โ๏ธ Setup & Installation
### 1. Clone the repository
```bashgit clone https://github.com/YOUR_USERNAME/queryvault.gitcd queryvault```
### 2. Create a virtual environment
```bashpython -m venv venv
# Windowsvenv\Scripts\activate
# macOS / Linuxsource venv/bin/activate```
### 3. Install dependencies
```bashpip install -r requirements.txt```
### 4. Add your Groq API credentials
To run this app locally, you need a free API key from Groq:
1. Create a file named `.env` in the root folder.2. Open the `.env` file and add the following lines:
```envGROQ_API_KEY=your_groq_api_key```
> **How to get a free key:**> 1. Sign up at [console.groq.com](https://console.groq.com/)> 2. Go to API Keys and generate a new key
### 5. Run the app
```bashpython app.py```
Open `http://127.0.0.1:7860` in your browser.
---
## ๐ฅ๏ธ Usage
1. Click **Upload PDF** and select any PDF document.2. Type your question in the **Your Question** box.3. Click **Get Answer**.4. The bot retrieves relevant sections from your document and generates a clear answer.
---
## ๐ Sharing & Deployment
### Temporary Public Link (The Easiest Way)Because this app uses Gradio, you don't even need to deploy it to share it with your friends or recruiters! When you run `python app.py` on your computer, Gradio automatically generates a temporary public URL (e.g., `https://1234abcd.gradio.live`). - Simply copy that `gradio.live` link from your terminal and send it to anyone!- *Note: This link only works while the terminal is actively running on your PC.*
### Permanent Free Deployment (Hugging Face Spaces)If you want the app to be available 24/7 without keeping your computer on, you can deploy it for free using Hugging Face:1. Go to [Hugging Face Spaces](https://huggingface.co/spaces) and create a free account.2. Click **Create new Space**.3. Enter a Space name, choose **Gradio** as the Space SDK, and click Create.4. In the Settings tab of your new Space, go to **Variables and secrets**. Add your `.env` variable as a **Secret** (`GROQ_API_KEY`).5. Upload all the files from this repository (except `venv` and `.env`) directly into the "Files" tab of your Space.6. The Space will automatically build and launch your app permanently!
---
## ๐งฉ Component Decisions
| Component | Choice | Why ||---|---|---|| Document Loader | `PyPDFLoader` | Handles multi-page PDFs reliably || Text Splitter | `RecursiveCharacterTextSplitter` | Preserves context at chunk boundaries || Embedding Model | HuggingFace `all-MiniLM-L6-v2` | Optimized for semantic similarity; runs locally for free || Vector Database | ChromaDB (In-Memory) | Lightweight, completely isolates each PDF upload || LLM | Llama-3.3 70B Instruct | State-of-the-art instruction-following; powerful reasoning || Orchestration | LangChain | Clean pipeline abstraction, easy to extend || UI | Gradio | Zero-config web app, file upload built-in |
---
## ๐ Performance (on structured PDFs)
| Metric | Score ||---|---|| Exact Match Rate | 97% || F1 Score | 0.9862 || Semantic Similarity | 0.9936 || Avg. Response Time | < 3 seconds |
---
## ๐ฎ Future Enhancements
- [ ] Support for DOCX and TXT file formats- [ ] Multi-document querying- [ ] Conversation memory (multi-turn chat)- [ ] Voice input / output (accessibility)- [ ] Multilingual support- [ ] Cloud deployment (HuggingFace Spaces / AWS)- [ ] User feedback loop for continuous improvement
---
## ๐ Tech Stack
- [LangChain](https://docs.langchain.com) โ RAG pipeline orchestration- [Groq](https://groq.com/) โ Lightning-fast LLM inference- [ChromaDB](https://www.trychroma.com) โ Vector database- [Gradio](https://www.gradio.app) โ Web UI- [PyPDF](https://pypdf.readthedocs.io) โ PDF parsing
---
## ๐ License
MIT License โ see [LICENSE](LICENSE) for details.1234567891011121314# QueryVault โ Python dependencies# Install with: pip install -r requirements.txt
gradio>=5.0.0langchain>=0.2.0langchain-community>=0.2.0langchain-groq>=0.1.0langchain-huggingface>=0.1.0huggingface-hub<1.0.0chromadb>=0.5.0pypdf>=4.0.0pydantic>=2.0.0python-dotenv>=1.0.0sentence-transformers>=2.2.2README.mdAdded+214
requirements.txtAdded+14