nkeer1 commited on
Commit
df0b973
·
verified ·
1 Parent(s): 47372da

Update hackathon submission links and categories

Browse files
Files changed (1) hide show
  1. README.md +233 -212
README.md CHANGED
@@ -1,218 +1,239 @@
1
- ---
2
- title: InsureChat
3
- emoji: "\U0001F6E1\uFE0F"
4
- colorFrom: blue
5
- colorTo: green
6
- sdk: gradio
7
- app_file: run_insurechat.py
8
- pinned: false
9
- tags:
10
- - healthcare
11
- - local-ai
12
- - rag
13
- - privacy
14
- - multilingual
15
- - track-local-ai
16
- - track-healthcare
17
  - badge-open-source
18
  - badge-multilingual
19
  - badge-privacy-first
20
- short_description: 'A chatbot to ask anything or upload medical bills'
21
- hf_oauth: true
22
- hf_oauth_scopes:
23
- - inference-api
24
- ---
25
-
26
- # InsureChat
27
-
28
- InsureChat is a local Gradio assistant for U.S. medical insurance definitions, medical bills, EOBs, and claims. It combines a local knowledge base, OCR, FAISS retrieval, and optional GGUF language models through `llama-cpp-python`.
29
-
30
- No OpenAI API or cloud inference service is used. After setup and model downloads, document processing and inference run locally.
31
-
 
 
 
 
 
 
 
 
32
  ## Hackathon Submission
33
 
34
- - **Social media post:** [Link will be added after publishing](SOCIAL_MEDIA_POST_URL)
35
- - **Demo video:** [Link will be added after recording](DEMO_VIDEO_URL)
36
-
37
- ### The Idea
38
-
39
- Medical bills and U.S. insurance terms can be difficult to understand, especially for newcomers and people who prefer another language. InsureChat is a privacy-first assistant that explains common insurance concepts before a document is uploaded, then switches to answers grounded in the user's active bill, EOB, claim, image, or text file after it is processed.
40
-
41
- ### How It Was Built
42
-
43
- The app uses Gradio for the interface and a local retrieval-augmented generation pipeline for question answering. It extracts text from PDFs and text files, applies Tesseract OCR to images and scanned PDFs, retrieves relevant context with FAISS or a lexical fallback, and parses important bill fields such as billed amount, discount, plan payment, service date, and patient responsibility. Uploaded documents remain session-specific so an earlier bill cannot influence a new session.
44
-
45
- ### Technology
46
-
47
- - Python and Gradio
48
- - `llama-cpp-python` with local GGUF models
49
- - Aya Expanse 8B for multilingual translation
50
- - Llama 3.1 8B for optional reasoning and structured extraction
51
- - FAISS and Sentence Transformers for retrieval
52
- - Tesseract, PyMuPDF, Pillow, and pypdf for OCR and document processing
53
- - Local Markdown and text files for trusted insurance definitions
54
-
55
- ## Features
56
-
57
- - Answers insurance definitions from local Markdown, text, and PDF knowledge files.
58
- - OCRs JPG, PNG, TIFF, and scanned PDF medical bills.
59
- - Extracts billed amount, discounts, patient balance, service date, and related fields.
60
- - Uses Aya Expanse 8B for local multilingual translation.
61
- - Uses Llama 3.1 8B for optional reasoning and structured extraction.
62
- - Keeps only one GGUF model loaded at a time to reduce peak RAM and VRAM use.
63
- - Continues with deterministic RAG and regex fallbacks when optional GGUF models are missing.
64
-
65
- ### Answer Routing
66
-
67
- - Definitions and general insurance questions use the fast local glossary/RAG path without loading Llama.
68
- - Misspelled or unknown terms receive a correction or close-term suggestion plus a trusted glossary link.
69
- - Direct uploaded-bill fields such as discount, amount due, service date, and plan payment use deterministic parsed values.
70
- - Llama is reserved for structured extraction and questions that require reasoning over the active PDF, image, or text upload.
71
- - Aya is loaded only when a non-English answer must be translated.
72
- - Question language and answer language are selected independently in the interface.
73
- - Hindi questions may be entered in Devanagari or as Romanized Hindi by selecting the matching question-language option.
74
-
75
- ## Requirements
76
-
77
- - Python 3.10 or newer
78
- - Approximately 6 GB of free space for Aya alone
79
- - Approximately 12-14 GB for all three Q4 GGUF models
80
- - Tesseract OCR for JPG, PNG, TIFF, and scanned PDF processing
81
- - Enough system RAM to load the selected model; models are loaded by role and are not all required for every request
82
-
83
- ### Install Tesseract
84
-
85
- Windows:
86
-
87
- 1. Install Tesseract from [UB Mannheim's Windows builds](https://github.com/UB-Mannheim/tesseract/wiki).
88
- 2. Enable the option to add Tesseract to `PATH`, or install it in `C:\Program Files\Tesseract-OCR`.
89
-
90
- macOS:
91
-
92
- ```bash
93
- brew install tesseract
94
- ```
95
-
96
- Ubuntu/Debian:
97
-
98
- ```bash
99
- sudo apt install tesseract-ocr
100
- ```
101
-
102
- ## Setup
103
-
104
- Create and activate a virtual environment:
105
-
106
- ```powershell
107
- python -m venv venv
108
- venv\Scripts\activate
109
- ```
110
-
111
- On macOS/Linux, activate it with:
112
-
113
- ```bash
114
- source venv/bin/activate
115
- ```
116
-
117
- Install the InsureChat dependencies:
118
-
119
- ```powershell
120
- python -m pip install --upgrade pip
121
- python -m pip install -r insurechat/requirements.txt
122
- ```
123
-
124
- The requirements install Python packages only. They do not install Tesseract or download multi-gigabyte GGUF model files.
125
-
126
- ## Download Models
127
-
128
- Models are intentionally excluded from Git and are not downloaded automatically. Each user must download the models needed on their own computer.
129
-
130
- Translation model:
131
-
132
- ```powershell
133
- python insurechat/download_models.py --model aya-8b
134
- ```
135
-
136
- Optional alternative reasoning model:
137
-
138
- ```powershell
139
- python insurechat/download_models.py --model nemotron-4b
140
- ```
141
-
142
- Recommended document extraction and reasoning model:
143
-
144
- ```powershell
145
- python insurechat/download_models.py --model llama3-8b
146
- ```
147
-
148
- The files are stored in `insurechat/models/`:
149
-
150
- | Model | Role | Approximate Q4 size |
151
- | --- | --- | --- |
152
- | Aya Expanse 8B | Translation | 4.7 GB |
153
- | Nemotron Mini 4B | Reasoning | 2-3 GB |
154
- | Llama 3.1 8B | Extraction/reasoning fallback | 4.5-5 GB |
155
-
156
- The app selects models by role and keeps only one GGUF loaded at a time with a 4,096-token context window. Switching between Llama reasoning and Aya translation unloads the current model before loading the next one. This lowers peak memory use, but the first request after a role switch can take longer while the next model loads.
157
-
158
- Performance depends heavily on hardware. On integrated graphics or CPU-only systems, an 8B response or model switch may take from several seconds to a few minutes. A discrete GPU with sufficient VRAM will generally respond faster.
159
-
160
- For the recommended setup, install Aya and Llama 3.1. Nemotron is an optional lighter English reasoning alternative and is not required when Llama is installed.
161
-
162
- Without the models, the application still starts:
163
-
164
- - Local glossary definitions continue to work.
165
- - OCR and regex medical-bill extraction continue to work.
166
- - Translation is unavailable without Aya.
167
- - LLM reasoning/extraction is unavailable without Nemotron or Llama.
168
-
169
- ## Model Verification
170
-
171
- The recommended Aya and Llama configuration was tested locally with the downloaded Q4 GGUF files:
172
-
173
- - Llama 3.1 8B generated a grounded explanation comparing deductible, copay, and coinsurance.
174
- - Llama 3.1 8B completed the structured document-extraction path and returned valid JSON fields.
175
- - Aya Expanse 8B translated an English insurance explanation into Spanish.
176
- - Switching from Llama to Aya closed the previous model before loading the next model.
177
- - Explicit cleanup released the active model after inference.
178
-
179
- The complete reasoning, extraction, translation, and cleanup test took about six minutes on the tested integrated AMD Vulkan graphics system. This is a hardware-specific measurement, not an expected time for every computer.
180
-
181
- ## Run
182
-
183
- From the repository root:
184
-
185
- ```powershell
186
- python insurechat/app.py
187
- ```
188
-
189
- Open the URL printed by Gradio, normally <http://127.0.0.1:7860>.
190
-
191
- ## Troubleshooting
192
-
193
- ### Translation unavailable
194
-
195
- Confirm that `insurechat/models/aya-expanse-8b-Q4_K_M.gguf` exists, then restart the app.
196
-
197
- ### No text extracted from an image
198
-
199
- Confirm both components are installed:
200
-
201
- ```powershell
202
- python -c "import pytesseract; print(pytesseract.get_tesseract_version())"
203
- ```
204
-
205
- If that fails, install `pytesseract` from the requirements and install the separate Tesseract application.
206
-
207
- ### Scanned PDF has no text
208
-
209
- Install `pymupdf` and `pytesseract`. InsureChat renders scanned PDF pages locally and sends the rendered images to Tesseract OCR.
210
-
211
- ### llama-cpp tries to compile on Windows
212
-
213
- `insurechat/requirements.txt` includes the official prebuilt CPU wheel index. A native compiler should not be required for supported Python versions.
214
-
215
- ## Privacy
216
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  Uploaded documents, OCR text, retrieval, and GGUF inference remain on the local computer. Internet access is only needed during dependency and model installation, or when the app displays an external reference link for a definition not found locally.
218
- >>>>>>> local-pdf-RAG-updated-with-medical-models-final
 
1
+ ---
2
+ title: InsureChat
3
+ emoji: "\U0001F6E1\uFE0F"
4
+ colorFrom: blue
5
+ colorTo: green
6
+ sdk: gradio
7
+ app_file: run_insurechat.py
8
+ pinned: false
9
+ tags:
10
+ - healthcare
11
+ - local-ai
12
+ - rag
13
+ - privacy
14
+ - multilingual
15
+ - track-local-ai
16
+ - track-healthcare
17
  - badge-open-source
18
  - badge-multilingual
19
  - badge-privacy-first
20
+ - badge-off-the-grid
21
+ - badge-off-brand
22
+ - badge-llama-champion
23
+ - badge-sharing-is-caring
24
+ - badge-field-notes
25
+ - award-best-agent
26
+ - award-best-demo
27
+ - award-bonus-quest-champion
28
+ short_description: 'A chatbot to ask anything or upload medical bills'
29
+ hf_oauth: true
30
+ hf_oauth_scopes:
31
+ - inference-api
32
+ ---
33
+
34
+ # InsureChat
35
+
36
+ InsureChat is a local Gradio assistant for U.S. medical insurance definitions, medical bills, EOBs, and claims. It combines a local knowledge base, OCR, FAISS retrieval, and optional GGUF language models through `llama-cpp-python`.
37
+
38
+ No OpenAI API or cloud inference service is used. After setup and model downloads, document processing and inference run locally.
39
+
40
  ## Hackathon Submission
41
 
42
+ - **GitHub repository:** [hackathon-updated](https://github.com/saiteja-keerty/hackathon-updated/tree/local-pdf-RAG-updated-with-medical-models-final)
43
+ - **Demo video:** [YouTube](https://youtu.be/aWqNqzC-JFg)
44
+ - **LinkedIn post:** [Build Small Hackathon submission](https://www.linkedin.com/posts/saiteja-keerty669073190_buildsmallhackathon-healthcareai-rag-ugcPost-7472349793449586688-6r01/?utm_source=share&utm_medium=member_desktop&rcm=ACoAACzcDvEB1lYuVJwqW2EbkwuM4f6LspYSVzE)
45
+ - **Hugging Face Space:** [build-small-hackathon/InsureChat](https://huggingface.co/spaces/build-small-hackathon/InsureChat)
46
+ - **Demo media:** [Google Photos](https://photos.app.goo.gl/dYVpjTGn3YLCM5386)
47
+
48
+ ### Badges and Award Categories
49
+
50
+ - Off the Grid
51
+ - Off-Brand
52
+ - Llama Champion
53
+ - Sharing is Caring
54
+ - Field Notes
55
+ - Best Agent
56
+ - Best Demo
57
+ - Bonus Quest Champion
58
+
59
+ ### The Idea
60
+
61
+ Medical bills and U.S. insurance terms can be difficult to understand, especially for newcomers and people who prefer another language. InsureChat is a privacy-first assistant that explains common insurance concepts before a document is uploaded, then switches to answers grounded in the user's active bill, EOB, claim, image, or text file after it is processed.
62
+
63
+ ### How It Was Built
64
+
65
+ The app uses Gradio for the interface and a local retrieval-augmented generation pipeline for question answering. It extracts text from PDFs and text files, applies Tesseract OCR to images and scanned PDFs, retrieves relevant context with FAISS or a lexical fallback, and parses important bill fields such as billed amount, discount, plan payment, service date, and patient responsibility. Uploaded documents remain session-specific so an earlier bill cannot influence a new session.
66
+
67
+ ### Technology
68
+
69
+ - Python and Gradio
70
+ - `llama-cpp-python` with local GGUF models
71
+ - Aya Expanse 8B for multilingual translation
72
+ - Llama 3.1 8B for optional reasoning and structured extraction
73
+ - FAISS and Sentence Transformers for retrieval
74
+ - Tesseract, PyMuPDF, Pillow, and pypdf for OCR and document processing
75
+ - Local Markdown and text files for trusted insurance definitions
76
+
77
+ ## Features
78
+
79
+ - Answers insurance definitions from local Markdown, text, and PDF knowledge files.
80
+ - OCRs JPG, PNG, TIFF, and scanned PDF medical bills.
81
+ - Extracts billed amount, discounts, patient balance, service date, and related fields.
82
+ - Uses Aya Expanse 8B for local multilingual translation.
83
+ - Uses Llama 3.1 8B for optional reasoning and structured extraction.
84
+ - Keeps only one GGUF model loaded at a time to reduce peak RAM and VRAM use.
85
+ - Continues with deterministic RAG and regex fallbacks when optional GGUF models are missing.
86
+
87
+ ### Answer Routing
88
+
89
+ - Definitions and general insurance questions use the fast local glossary/RAG path without loading Llama.
90
+ - Misspelled or unknown terms receive a correction or close-term suggestion plus a trusted glossary link.
91
+ - Direct uploaded-bill fields such as discount, amount due, service date, and plan payment use deterministic parsed values.
92
+ - Llama is reserved for structured extraction and questions that require reasoning over the active PDF, image, or text upload.
93
+ - Aya is loaded only when a non-English answer must be translated.
94
+ - Question language and answer language are selected independently in the interface.
95
+ - Hindi questions may be entered in Devanagari or as Romanized Hindi by selecting the matching question-language option.
96
+
97
+ ## Requirements
98
+
99
+ - Python 3.10 or newer
100
+ - Approximately 6 GB of free space for Aya alone
101
+ - Approximately 12-14 GB for all three Q4 GGUF models
102
+ - Tesseract OCR for JPG, PNG, TIFF, and scanned PDF processing
103
+ - Enough system RAM to load the selected model; models are loaded by role and are not all required for every request
104
+
105
+ ### Install Tesseract
106
+
107
+ Windows:
108
+
109
+ 1. Install Tesseract from [UB Mannheim's Windows builds](https://github.com/UB-Mannheim/tesseract/wiki).
110
+ 2. Enable the option to add Tesseract to `PATH`, or install it in `C:\Program Files\Tesseract-OCR`.
111
+
112
+ macOS:
113
+
114
+ ```bash
115
+ brew install tesseract
116
+ ```
117
+
118
+ Ubuntu/Debian:
119
+
120
+ ```bash
121
+ sudo apt install tesseract-ocr
122
+ ```
123
+
124
+ ## Setup
125
+
126
+ Create and activate a virtual environment:
127
+
128
+ ```powershell
129
+ python -m venv venv
130
+ venv\Scripts\activate
131
+ ```
132
+
133
+ On macOS/Linux, activate it with:
134
+
135
+ ```bash
136
+ source venv/bin/activate
137
+ ```
138
+
139
+ Install the InsureChat dependencies:
140
+
141
+ ```powershell
142
+ python -m pip install --upgrade pip
143
+ python -m pip install -r insurechat/requirements.txt
144
+ ```
145
+
146
+ The requirements install Python packages only. They do not install Tesseract or download multi-gigabyte GGUF model files.
147
+
148
+ ## Download Models
149
+
150
+ Models are intentionally excluded from Git and are not downloaded automatically. Each user must download the models needed on their own computer.
151
+
152
+ Translation model:
153
+
154
+ ```powershell
155
+ python insurechat/download_models.py --model aya-8b
156
+ ```
157
+
158
+ Optional alternative reasoning model:
159
+
160
+ ```powershell
161
+ python insurechat/download_models.py --model nemotron-4b
162
+ ```
163
+
164
+ Recommended document extraction and reasoning model:
165
+
166
+ ```powershell
167
+ python insurechat/download_models.py --model llama3-8b
168
+ ```
169
+
170
+ The files are stored in `insurechat/models/`:
171
+
172
+ | Model | Role | Approximate Q4 size |
173
+ | --- | --- | --- |
174
+ | Aya Expanse 8B | Translation | 4.7 GB |
175
+ | Nemotron Mini 4B | Reasoning | 2-3 GB |
176
+ | Llama 3.1 8B | Extraction/reasoning fallback | 4.5-5 GB |
177
+
178
+ The app selects models by role and keeps only one GGUF loaded at a time with a 4,096-token context window. Switching between Llama reasoning and Aya translation unloads the current model before loading the next one. This lowers peak memory use, but the first request after a role switch can take longer while the next model loads.
179
+
180
+ Performance depends heavily on hardware. On integrated graphics or CPU-only systems, an 8B response or model switch may take from several seconds to a few minutes. A discrete GPU with sufficient VRAM will generally respond faster.
181
+
182
+ For the recommended setup, install Aya and Llama 3.1. Nemotron is an optional lighter English reasoning alternative and is not required when Llama is installed.
183
+
184
+ Without the models, the application still starts:
185
+
186
+ - Local glossary definitions continue to work.
187
+ - OCR and regex medical-bill extraction continue to work.
188
+ - Translation is unavailable without Aya.
189
+ - LLM reasoning/extraction is unavailable without Nemotron or Llama.
190
+
191
+ ## Model Verification
192
+
193
+ The recommended Aya and Llama configuration was tested locally with the downloaded Q4 GGUF files:
194
+
195
+ - Llama 3.1 8B generated a grounded explanation comparing deductible, copay, and coinsurance.
196
+ - Llama 3.1 8B completed the structured document-extraction path and returned valid JSON fields.
197
+ - Aya Expanse 8B translated an English insurance explanation into Spanish.
198
+ - Switching from Llama to Aya closed the previous model before loading the next model.
199
+ - Explicit cleanup released the active model after inference.
200
+
201
+ The complete reasoning, extraction, translation, and cleanup test took about six minutes on the tested integrated AMD Vulkan graphics system. This is a hardware-specific measurement, not an expected time for every computer.
202
+
203
+ ## Run
204
+
205
+ From the repository root:
206
+
207
+ ```powershell
208
+ python insurechat/app.py
209
+ ```
210
+
211
+ Open the URL printed by Gradio, normally <http://127.0.0.1:7860>.
212
+
213
+ ## Troubleshooting
214
+
215
+ ### Translation unavailable
216
+
217
+ Confirm that `insurechat/models/aya-expanse-8b-Q4_K_M.gguf` exists, then restart the app.
218
+
219
+ ### No text extracted from an image
220
+
221
+ Confirm both components are installed:
222
+
223
+ ```powershell
224
+ python -c "import pytesseract; print(pytesseract.get_tesseract_version())"
225
+ ```
226
+
227
+ If that fails, install `pytesseract` from the requirements and install the separate Tesseract application.
228
+
229
+ ### Scanned PDF has no text
230
+
231
+ Install `pymupdf` and `pytesseract`. InsureChat renders scanned PDF pages locally and sends the rendered images to Tesseract OCR.
232
+
233
+ ### llama-cpp tries to compile on Windows
234
+
235
+ `insurechat/requirements.txt` includes the official prebuilt CPU wheel index. A native compiler should not be required for supported Python versions.
236
+
237
+ ## Privacy
238
+
239
  Uploaded documents, OCR text, retrieval, and GGUF inference remain on the local computer. Internet access is only needed during dependency and model installation, or when the app displays an external reference link for a definition not found locally.