---
title: DocuChat_AI
emoji: ๐
colorFrom: blue
colorTo: indigo
sdk: streamlit
sdk_version: 1.58.0
app_file: app.py
python_version: '3.10'
pinned: false
license: mit
---
---
## ๐ Live Application
Try the app here:
### ๐ [Launch DocuChat_AI on Hugging Face](https://huggingface.co/spaces/dineshb/DocuChat_AI)
DocuChat_AI is designed for students, analysts, recruiters, researchers, founders, and professionals who need to understand long documents quickly without manually reading every page.
---
## ๐ผ๏ธ Application Screenshots
> Add your screenshots inside the `assets/` folder using the exact filenames below. GitHub will automatically render them in this README.
### 1. Premium Home Workspace

### 2. Document Processing and Indexing

### 3. Chat with Source Citations

### 4. Summary and Analysis Tools
---
## ๐ Project Overview
Most professionals deal with long PDFs, reports, resumes, policy documents, contracts, research papers, business notes, and technical files. Reading everything manually takes time, and generic chatbots can hallucinate when they are not grounded in the source document.
**DocuChat_AI solves this using Retrieval-Augmented Generation (RAG).**
The app extracts text from uploaded documents, splits it into searchable chunks, converts those chunks into embeddings, stores them in a FAISS vector index, retrieves the most relevant context for each question, and generates answers using an LLM while keeping responses grounded in the uploaded content.
---
## โจ Key Features
| Feature | Description |
| --- | --- |
| ๐ Multi-document upload | Supports PDF, DOCX, and TXT files |
| ๐ง RAG-based Q&A | Ask natural-language questions about uploaded documents |
| ๐ Smart summaries | Generate executive summaries, study notes, email briefs, and key takeaways |
| ๐ Source citations | View retrieved document chunks used to answer each question |
| ๐งฉ Workflow tabs | Chat, Summaries, Extract, Analyze, and Deliverables |
| โก Quick action buttons | One-click prompts for risks, decisions, action items, FAQs, and presentation outlines |
| ๐ Index stats | Track processed files, pages, chunks, and processing time |
| ๐งพ Document classification | LLM-based classification into Research Paper, Contract, CV, Invoice, Policy, Report, or Other |
| ๐งฌ Entity extraction | Extract people, organizations, dates, money values, and locations |
| โ ๏ธ Risk detection | Surface legal risks, missing information, deadlines, and action items |
| ๐ RAG quality metrics | Show retrieved chunks, confidence score, citation coverage, and context usage |
| ๐งช Evaluation dashboard | Upload labeled test questions and score correctness, faithfulness, and citation coverage |
| ๐ OCR-ready processing | Optional scanned PDF OCR support for Docker deployments |
| ๐ Optional authentication | Protect demos with an `APP_PASSWORD` environment secret |
| ๐ฌ Chat history | Maintains conversation context during the active session |
| โฌ๏ธ Export support | Export chat history as Markdown |
| ๐ Secure key input | Uses Hugging Face Secrets, environment variables, or password input |
---
## ๐ง What Users Can Do
- Upload a long PDF and ask: **"What are the main risks in this document?"**
- Turn a document into an **executive summary**
- Extract **names, dates, metrics, definitions, and action items**
- Generate **meeting notes, FAQs, email briefs, and presentation outlines**
- Ask follow-up questions using conversation history
- Inspect citations to understand where the answer came from
---
## ๐๏ธ RAG Architecture
### Pipeline Flow
1. **Document Upload** - User uploads PDF, DOCX, or TXT files.
2. **Text Extraction** - The app extracts readable text using document loaders.
3. **Chunking** - Text is split into manageable chunks with overlap.
4. **Embedding Generation** - Chunks are converted into vector embeddings.
5. **Vector Search** - FAISS retrieves the most relevant chunks for each query.
6. **LLM Generation** - Groq-powered models generate answers using retrieved context.
7. **Citation Display** - The app shows source previews used for the answer.
---
## ๐ ๏ธ Tech Stack
| Layer | Tools |
| --- | --- |
| Frontend | Streamlit |
| LLM | Groq API |
| RAG Framework | LangChain |
| Vector Database | FAISS |
| Embeddings | Hugging Face Sentence Transformers |
| Document Loading | PyPDF, DOCX2TXT, LangChain loaders |
| Text Splitting | LangChain text splitters + tiktoken |
| Deployment | Hugging Face Spaces |
| Language | Python |
---
## ๐ Repository Structure
```text
DocuChat_AI/
โ
โโโ app.py # Main Streamlit application
โโโ README.md # Project documentation
โโโ requirements.txt # Python dependencies
โโโ runtime.txt # Python runtime version for Hugging Face
โโโ Dockerfile # Optional container deployment file
โโโ DEPLOYMENT.md # Deployment, auth, OCR, and evaluation guide
โโโ eval_sample.csv # Sample labeled evaluation file
โโโ LICENSE # MIT License
โโโ .gitignore # Local files and secrets ignored by Git
โโโ .gitattributes # Hugging Face / Git file handling
โ
โโโ assets/
โโโ app_home.png # Home UI screenshot
โโโ document_processing.png # Upload and processing screenshot
โโโ chat_with_sources.png # Chat answer and citations screenshot
โโโ summary_tools.png # Summary / analysis tools screenshot
```
---
## โ๏ธ Local Setup
### 1. Clone the Repository
```bash
git clone https://github.com/dineshbarri/DocuChat_AI.git
cd DocuChat_AI
```
### 2. Create a Virtual Environment
```bash
python -m venv .venv
```
Activate it:
```bash
# Windows
.venv\Scripts\activate
# macOS / Linux
source .venv/bin/activate
```
### 3. Install Dependencies
```bash
pip install -r requirements.txt
```
### 4. Add Your Groq API Key
Create a `.env` file:
```env
GROQ_API_KEY=your_groq_api_key_here
```
You can create a Groq API key from:
๐ [https://console.groq.com/](https://console.groq.com/)
### 5. Run the App
```bash
streamlit run app.py
```
Open the local URL shown in your terminal.
---
## ๐ How to Get a Groq API Key
1. Go to [Groq Console](https://console.groq.com/)
2. Sign in or create an account
3. Open **API Keys**
4. Create a new API key
5. Copy the key
6. Paste it into the app sidebar or save it in `.env`
For Hugging Face Spaces, add it as a secret:
```text
GROQ_API_KEY = your_key_here
```
---
## ๐ข Hugging Face Deployment
1. Create a new Hugging Face Space.
2. Choose **Streamlit** as the SDK.
3. Upload:
- `app.py`
- `README.md`
- `requirements.txt`
- `runtime.txt`
- `.gitattributes`
- `assets/`
4. Add `GROQ_API_KEY` in **Settings -> Secrets**.
5. Optional: add `APP_PASSWORD` in **Settings -> Secrets** to protect the app.
6. Restart the Space after dependency changes.
For scanned PDF OCR, use the included Dockerfile because OCR needs the Tesseract system binary. Normal Streamlit SDK Spaces may not include it.
See [DEPLOYMENT.md](DEPLOYMENT.md) for the full deployment guide.
---
## ๐ก Example Questions
Try these after uploading and processing a document:
```text
Summarize this document in 6 crisp bullet points.
```
```text
What are the key risks, warnings, or limitations?
```
```text
Extract all names, dates, numbers, and important terms.
```
```text
Create an action-item checklist from this document.
```
```text
Explain this document like I am new to the topic.
```
```text
Create a presentation outline from this document.
```
---
## ๐ Privacy and Security
- Uploaded files are processed through temporary files.
- The app does not intentionally store user documents.
- The FAISS index and chat history live inside the active Streamlit session.
- API keys should be stored in environment variables or Hugging Face Secrets.
- Avoid uploading highly confidential documents to public demo environments.
---
## โ ๏ธ Limitations
- Scanned PDF OCR requires optional OCR dependencies and works best in Docker mode.
- Very large documents may be limited by CPU and memory on free hosting.
- Complex tables may not extract perfectly from PDFs.
- LLM answers should be reviewed for critical legal, medical, financial, or compliance use cases.
- Citation quality depends on document extraction and retrieval quality.
---
## ๐ Future Improvements
- Multi-document comparison mode
- Persistent user workspaces
- Better page-level citation highlighting
- CSV, Excel, PPTX, and web page support
- Reranking for improved retrieval accuracy
- Authentication and private document libraries
- Downloadable summary reports
- Evaluation dashboard for retrieval quality
---
## ๐งโ๐ป Author
---
## โญ Support
If you found this project useful, consider giving it a star on GitHub. It helps the project reach more developers, recruiters, and AI builders.