CoolFace
Apppublic

KimsunLy/Smart-Document-Q-A-and-Workflow-Assistant

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
App README

Smart Document Q&A and Workflow Assistant

An AI-powered assistant that enables natural language queries over document repositories. The system uses TF-IDF, embeddings, and Retrieval-Augmented Generation (RAG) to provide accurate answers, summaries, and references.


๐Ÿš€ Features

  • โ€”๐Ÿ“„ Multi-format input: PDF, Word, and plain text documents
  • โ€”๐Ÿ”Ž Semantic search: TF-IDF baseline + Embedding-based retrieval
  • โ€”๐Ÿ’ฌ Natural language Q&A: Ask questions, get direct answers with supporting references
  • โ€”๐Ÿ“‘ Document summaries: Generate concise overviews of documents
  • โ€”๐ŸŒ Web interface: Upload documents and interact via a simple UI
  • โ€”๐Ÿงช Evaluation: Accuracy, precision, recall, F1-score, and usability metrics
  • โ€”[NEW] ๐Ÿ“Š Structured Data Export: Convert documents to JSON, CSV, Excel, Searchable PDF

๐Ÿ”ฎ Future Plan (Phase 2)

  • โ€”Cloud storage integration (Google Drive, Dropbox)
  • โ€”Workflow automation (Slack, Zapier, n8n)
  • โ€”Multi-hop reasoning for complex queries
  • โ€”Visual explainability (highlighting evidence in the document)
  • โ€”Enhanced data extraction with ML models

๐Ÿ“Š Structured Data Export (IMPROVED)

Transform unstructured documents into machine-readable formats. Perfect for integrating with databases, spreadsheets, and business systems.

LATEST IMPROVEMENTS:

  • โ€”โœจ Better table detection: Now handles OCR-extracted tables with space-separated columns
  • โ€”โœจ Smart field mapping: Automatically recognizes common field names (Name, Email, Phone, etc.)
  • โ€”โœจ Professional Excel output: Multi-sheet workbooks with Summary, Records, and Metadata
  • โ€”โœจ Auto-formatted records: Student lists, employee directories, and forms are properly extracted

Supported Formats:

  • โ€”JSON: For APIs and data processing
  • โ€”CSV: For Excel, Google Sheets, database import
  • โ€”Excel: Professional workbooks with multiple sheets
  • โ€”Searchable PDF: OCR text layer + original image

Example Use Cases:

  • โ€”Student enrollment list โ†’ CSV โ†’ database import
  • โ€”Receipt/invoice scan โ†’ JSON โ†’ accounting API
  • โ€”Form PDF โ†’ key-value pairs โ†’ CRM
  • โ€”Legacy documents โ†’ searchable PDFs

๐Ÿ‘‰ [See detailed documentation โ†’](STRUCTURED_DATA_EXPORT_IMPROVEMENTS.md) for improvements, usage guide, and examples

๐Ÿ‘‰ [See original documentation โ†’](STRUCTURED_DATA_EXPORT.md)

Try it:

bash
# Demo with student list example
python demo_structured_export.py

This generates:

  • โ€”demo_export_students.json - Structured data
  • โ€”demo_export_students.csv - Spreadsheet format
  • โ€”demo_export_students.xlsx - Professional workbook

Smart-Doc-QA/
โ”‚โ”€โ”€ data/               # Sample datasets / documents
โ”‚โ”€โ”€ notebooks/          # Prototyping & experiments
โ”‚โ”€โ”€ src/                # Source code
โ”‚   โ”œโ”€โ”€ preprocessing/  # Text extraction, OCR, chunking
โ”‚   โ”œโ”€โ”€ retrieval/      # TF-IDF, embeddings, vector search
โ”‚   โ”œโ”€โ”€ rag/            # Retrieval-Augmented Generation pipeline
โ”‚   โ”œโ”€โ”€ webapp/         # Streamlit/Flask web interface
โ”‚   โ””โ”€โ”€ utils/          # Helper functions
โ”‚โ”€โ”€ tests/              # Unit tests
โ”‚โ”€โ”€ requirements.txt    # Dependencies
โ”‚โ”€โ”€ README.md           # Project overview
โ”‚โ”€โ”€ demo.mp4            # Demo video (optional)

โš™๏ธ Installation

Clone the repository:

bash
git clone https://github.com/your-username/smart-doc-qa.git
cd smart-doc-qa

Create a virtual environment and install requirements:

bash
python -m venv venv
# Linux/Mac
source venv/bin/activate
# Windows
venv\Scripts\activate
pip install -r requirements.txt

Set up API keys (for OpenAI / Hugging Face):

bash
export OPENAI_API_KEY=your_api_key
# Windows PowerShell
$env:OPENAI_API_KEY="your_api_key"

โ–ถ๏ธ Usage

Start the web interface:

bash
venv\Scripts\python -m streamlit run src/app.py

Optional OCR system dependencies (needed for best PDF/image OCR features):

  • โ€”Install Tesseract OCR and ensure tesseract is in PATH
  • โ€”Install Poppler and ensure pdftoppm is in PATH (used by pdf2image)
  1. 1.Upload documents (PDF, Word, or TXT)
  2. 2.Ask questions in natural language
  3. 3.Get:
  4. 4.Direct answers
  5. 5.Supporting references
  6. 6.Optional summaries

๐Ÿงฐ Tech Stack

  • โ€”Languages: Python, JavaScript (optional for frontend)
  • โ€”NLP/ML: scikit-learn, spaCy, Hugging Face Transformers
  • โ€”AI Integration: LangChain, LlamaIndex, OpenAI API
  • โ€”Web: Streamlit / Flask / FastAPI
  • โ€”Deployment: Heroku / Render / GitHub Pages
  • โ€”Future (Phase 2): Zapier, n8n, Google Drive, Slack integration

๐Ÿ“Š Evaluation Metrics

  • โ€”Model Performance: Accuracy, Precision, Recall, F1-score
  • โ€”System Usability: User satisfaction, interface intuitiveness
  • โ€”Efficiency: Response time, indexing speed, resource use

๐Ÿ“… Timeline (Phase 1 โ€“ MVP)

  • โ€”Week 1โ€“2: Requirement Analysis
  • โ€”Week 3โ€“6: Model Development (TF-IDF โ†’ Embeddings โ†’ RAG)
  • โ€”Week 7โ€“9: Web UI + Integration
  • โ€”Week 12โ€“13: Testing & Evaluation
  • โ€”Week 14โ€“16: Documentation + Final Report

(Phase 2 โ€“ Future: Workflow automation, cloud integration, advanced reasoning)


๐Ÿ™Œ Contributors

  • โ€”Advisor: Mr. Toem Theara
  • โ€”Ly Kimsun (ITE, RUPP, Year 3)
  • โ€”Ly MengHong (ITE, RUPP, Year 3)

๐Ÿ“œ License

MIT License