DocuChat_AI / README.md
dineshb's picture
Upload 3 files
fd9e620 verified
|
Raw
History Blame Contribute Delete
12.5 kB
metadata
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

Typing SVG

Live Demo GitHub Repository MIT License

DocuChat_AI is a high-end AI document chatbot that lets users upload documents, generate summaries, extract insights, and ask grounded questions with source citations.


πŸš€ Live Application

Try the app here:

πŸ‘‰ Launch DocuChat_AI on Hugging Face

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

DocuChat_AI home workspace

2. Document Processing and Indexing

Document upload and processing workflow

3. Chat with Source Citations

Document question answering with citations

4. Summary and Analysis Tools

Summary and analysis tabs

πŸ“Œ 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

DocuChat AI RAG architecture diagram

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

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

git clone https://github.com/dineshbarri/DocuChat_AI.git
cd DocuChat_AI

2. Create a Virtual Environment

python -m venv .venv

Activate it:

# Windows
.venv\Scripts\activate

# macOS / Linux
source .venv/bin/activate

3. Install Dependencies

pip install -r requirements.txt

4. Add Your Groq API Key

Create a .env file:

GROQ_API_KEY=your_groq_api_key_here

You can create a Groq API key from:

πŸ‘‰ https://console.groq.com/

5. Run the App

streamlit run app.py

Open the local URL shown in your terminal.


πŸ”‘ How to Get a Groq API Key

  1. Go to Groq Console
  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:

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 for the full deployment guide.


πŸ’‘ Example Questions

Try these after uploading and processing a document:

Summarize this document in 6 crisp bullet points.
What are the key risks, warnings, or limitations?
Extract all names, dates, numbers, and important terms.
Create an action-item checklist from this document.
Explain this document like I am new to the topic.
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

Built by Dinesh Barri

Data Analyst | AI Automation Engineer | Founder @ Plemdo AI


⭐ 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.