KimsunLy/Smart-Document-Q-A-and-Workflow-Assistant
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:
# Demo with student list example
python demo_structured_export.pyThis generates:
demo_export_students.json- Structured datademo_export_students.csv- Spreadsheet formatdemo_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:
git clone https://github.com/your-username/smart-doc-qa.git
cd smart-doc-qaCreate a virtual environment and install requirements:
python -m venv venv
# Linux/Mac
source venv/bin/activate
# Windows
venv\Scripts\activate
pip install -r requirements.txtSet up API keys (for OpenAI / Hugging Face):
export OPENAI_API_KEY=your_api_key
# Windows PowerShell
$env:OPENAI_API_KEY="your_api_key"โถ๏ธ Usage
Start the web interface:
venv\Scripts\python -m streamlit run src/app.pyOptional OCR system dependencies (needed for best PDF/image OCR features):
- Install Tesseract OCR and ensure
tesseractis in PATH - Install Poppler and ensure
pdftoppmis in PATH (used bypdf2image)
- Upload documents (PDF, Word, or TXT)
- Ask questions in natural language
- Get:
- Direct answers
- Supporting references
- 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
