Spaces:
Sleeping
Sleeping
improvements
Browse files
README.md
DELETED
|
@@ -1,161 +0,0 @@
|
|
| 1 |
-
# SmartDoc AI
|
| 2 |
-
|
| 3 |
-
SmartDoc AI is an advanced document analysis and question answering system, designed for source-grounded Q&A over complex business and scientific reports�especially where key evidence lives in tables and charts.
|
| 4 |
-
|
| 5 |
-
---
|
| 6 |
-
|
| 7 |
-
## ?? Personal Research Update
|
| 8 |
-
|
| 9 |
-
**SmartDoc AI � Document Q&A + Selective Chart Understanding**
|
| 10 |
-
|
| 11 |
-
I�ve been developing SmartDoc AI as a technical experiment to improve question answering over complex business/scientific reports�especially where key evidence lives in tables and charts.
|
| 12 |
-
|
| 13 |
-
### Technical highlights:
|
| 14 |
-
|
| 15 |
-
- **Multi-format ingestion:** PDF, DOCX, TXT, Markdown
|
| 16 |
-
- **LLM-assisted query decomposition:** breaks complex prompts into clearer sub-questions for retrieval + answering
|
| 17 |
-
- **Selective chart pipeline (cost-aware):**
|
| 18 |
-
- Local OpenCV heuristics flag pages that likely contain charts
|
| 19 |
-
- Gemini Vision is invoked only for chart pages to generate structured chart analysis (reduces unnecessary vision calls)
|
| 20 |
-
- **Table extraction + robust PDF parsing:** pdfplumber strategies for bordered and borderless tables
|
| 21 |
-
- **Parallelized processing:** concurrent PDF parsing + chart detection; batch chart analysis where enabled
|
| 22 |
-
- **Hybrid retrieval:** BM25 + vector search combined via an ensemble retriever
|
| 23 |
-
- **Multi-agent answering:** answer drafting + verification pass, with retrieved context available for inspection (page/source metadata)
|
| 24 |
-
|
| 25 |
-
**Runtime note:** Large PDFs (many pages/charts) can take minutes depending on DPI, chart volume, and available memory/CPU (HF Spaces limits can be a factor).
|
| 26 |
-
|
| 27 |
-
---
|
| 28 |
-
|
| 29 |
-
## ?? Demo Videos
|
| 30 |
-
|
| 31 |
-
- [SmartDoc AI technical demo #1](https://youtu.be/uVU_sLiJU4w)
|
| 32 |
-
- [SmartDoc AI technical demo #2](https://youtu.be/c8CF7-OaKmQ)
|
| 33 |
-
- [SmartDoc AI technical demo #3](https://youtu.be/P17SZSQJ6Wc)
|
| 34 |
-
|
| 35 |
-
---
|
| 36 |
-
|
| 37 |
-
## Repository
|
| 38 |
-
?? https://github.com/TilanTAB/Intelligent-Document-Analysis-SmartDoc-AI
|
| 39 |
-
|
| 40 |
-
---
|
| 41 |
-
|
| 42 |
-
## Use Cases
|
| 43 |
-
|
| 44 |
-
- Source-grounded Q&A for business/research documents
|
| 45 |
-
- Automated extraction and summarization from tables/charts
|
| 46 |
-
|
| 47 |
-
If you�re interested in architecture tradeoffs (cost, latency, memory limits, retrieval quality), feel free to connect.
|
| 48 |
-
|
| 49 |
-
---
|
| 50 |
-
|
| 51 |
-
## Features
|
| 52 |
-
|
| 53 |
-
- **Multi-format Document Support**: PDF, DOCX, TXT, and Markdown
|
| 54 |
-
- **Smart Chunking**: Configurable chunk size and overlap for optimal retrieval
|
| 55 |
-
- **Intelligent Caching**: Speeds up repeated queries
|
| 56 |
-
- **Chart Extraction**: Detects and analyzes charts using OpenCV and Gemini Vision
|
| 57 |
-
- **Hybrid Search**: Combines keyword and vector search for best results
|
| 58 |
-
- **Multi-Agent Workflow**: Relevance checking, research, and answer verification
|
| 59 |
-
- **Production Ready**: Structured logging, environment-based config, and test suite
|
| 60 |
-
- **Efficient**: Local chart detection saves up to 95% on API costs
|
| 61 |
-
|
| 62 |
-
---
|
| 63 |
-
|
| 64 |
-
## Quick Start
|
| 65 |
-
|
| 66 |
-
### Prerequisites
|
| 67 |
-
- Python 3.11 or higher
|
| 68 |
-
- Google API Key for Gemini models ([Get one here](https://ai.google.dev/))
|
| 69 |
-
|
| 70 |
-
### Installation
|
| 71 |
-
|
| 72 |
-
1. Clone the repository:
|
| 73 |
-
```bash
|
| 74 |
-
git clone https://github.com/TilanTAB/Intelligent-Document-Analysis-SmartDoc-AI.git
|
| 75 |
-
cd Intelligent-Document-Analysis-SmartDoc-AI
|
| 76 |
-
```
|
| 77 |
-
|
| 78 |
-
2. Activate the virtual environment:
|
| 79 |
-
```bash
|
| 80 |
-
# Windows PowerShell
|
| 81 |
-
.\activate_venv.ps1
|
| 82 |
-
# Windows Command Prompt
|
| 83 |
-
activate_venv.bat
|
| 84 |
-
# Or manually:
|
| 85 |
-
.\venv\Scripts\Activate.ps1
|
| 86 |
-
```
|
| 87 |
-
|
| 88 |
-
3. Install dependencies (if needed):
|
| 89 |
-
```bash
|
| 90 |
-
pip install -r requirements.txt
|
| 91 |
-
```
|
| 92 |
-
|
| 93 |
-
4. Configure environment variables:
|
| 94 |
-
```bash
|
| 95 |
-
cp .env.template .env
|
| 96 |
-
# Edit .env and set your API key
|
| 97 |
-
GOOGLE_API_KEY=your_api_key_here
|
| 98 |
-
```
|
| 99 |
-
|
| 100 |
-
5. (Optional) Verify installation:
|
| 101 |
-
```bash
|
| 102 |
-
python verify_environment.py
|
| 103 |
-
```
|
| 104 |
-
|
| 105 |
-
6. Run the application:
|
| 106 |
-
```bash
|
| 107 |
-
python main.py
|
| 108 |
-
```
|
| 109 |
-
|
| 110 |
-
7. Open your browser to [http://localhost:7860](http://localhost:7860)
|
| 111 |
-
|
| 112 |
-
---
|
| 113 |
-
|
| 114 |
-
## Configuration
|
| 115 |
-
|
| 116 |
-
All settings can be configured via environment variables or the `.env` file. Key options include:
|
| 117 |
-
- `GOOGLE_API_KEY`: Your Gemini API key (required)
|
| 118 |
-
- `CHUNK_SIZE`, `CHUNK_OVERLAP`: Document chunking
|
| 119 |
-
- `ENABLE_CHART_EXTRACTION`: Enable/disable chart detection
|
| 120 |
-
- `CHART_USE_LOCAL_DETECTION`: Use OpenCV for free chart detection
|
| 121 |
-
- `CHART_ENABLE_BATCH_ANALYSIS`: Batch process charts for speed
|
| 122 |
-
- `CHART_GEMINI_BATCH_SIZE`: Number of charts per Gemini API call
|
| 123 |
-
- `LOG_LEVEL`: Logging verbosity
|
| 124 |
-
- `GRADIO_SERVER_PORT`: Web interface port
|
| 125 |
-
|
| 126 |
-
---
|
| 127 |
-
|
| 128 |
-
## Project Structure
|
| 129 |
-
|
| 130 |
-
- `intelligence/` - Multi-agent system (relevance, research, verification)
|
| 131 |
-
- `configuration/` - App settings and logging
|
| 132 |
-
- `content_analyzer/` - Document and chart processing
|
| 133 |
-
- `search_engine/` - Hybrid retriever logic
|
| 134 |
-
- `core/` - Utilities and diagnostics
|
| 135 |
-
- `tests/` - Test suite
|
| 136 |
-
- `main.py` - Application entry point
|
| 137 |
-
|
| 138 |
-
---
|
| 139 |
-
|
| 140 |
-
## Troubleshooting
|
| 141 |
-
|
| 142 |
-
- **API Key Not Found**: Set `GOOGLE_API_KEY` in your `.env` file.
|
| 143 |
-
- **Python 3.13 Issues**: Use Python 3.11 or 3.12 for best compatibility.
|
| 144 |
-
- **Chart Detection Slow**: Lower `CHART_DPI` or `CHART_MAX_IMAGE_SIZE` in `.env`.
|
| 145 |
-
- **ChromaDB Lock Issues**: Stop all instances and remove lock files in `vector_store/`.
|
| 146 |
-
|
| 147 |
-
---
|
| 148 |
-
|
| 149 |
-
## Contributing
|
| 150 |
-
|
| 151 |
-
Contributions are welcome! Please fork the repository, create a feature branch, and submit a pull request with a clear description.
|
| 152 |
-
|
| 153 |
-
---
|
| 154 |
-
|
| 155 |
-
## License
|
| 156 |
-
|
| 157 |
-
This project is licensed under the MIT License.
|
| 158 |
-
|
| 159 |
-
---
|
| 160 |
-
|
| 161 |
-
SmartDoc AI is actively maintained and designed for real-world document analysis and Q&A. For updates and support, visit the [GitHub repository](https://github.com/TilanTAB/Intelligent-Document-Analysis-SmartDoc-AI).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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