samwell commited on
Commit
a8c21c2
·
verified ·
1 Parent(s): 75d9f23

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +200 -13
README.md CHANGED
@@ -1,22 +1,209 @@
1
  ---
 
2
  base_model: google/gemma-4-E4B-it
3
  tags:
4
- - text-generation-inference
5
- - transformers
6
- - unsloth
7
- - gemma4
8
- - trl
9
- license: apache-2.0
 
 
 
 
 
10
  language:
11
- - en
 
 
12
  ---
13
 
14
- # Uploaded model
15
 
16
- - **Developed by:** samwell
17
- - **License:** apache-2.0
18
- - **Finetuned from model :** google/gemma-4-E4B-it
19
 
20
- This gemma4 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth)
21
 
22
- [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: gemma
3
  base_model: google/gemma-4-E4B-it
4
  tags:
5
+ - healthcare
6
+ - clinical-decision-support
7
+ - ncd
8
+ - diabetes
9
+ - hypertension
10
+ - medical
11
+ - unsloth
12
+ - lora
13
+ - gguf
14
+ datasets:
15
+ - samwell/synthea-ncd-instructions
16
  language:
17
+ - en
18
+ pipeline_tag: text-generation
19
+ library_name: transformers
20
  ---
21
 
22
+ # NCD Risk Assessment Model (Gemma 4 E4B Fine-tuned)
23
 
24
+ A fine-tuned Gemma 4 E4B model for predicting **Non-Communicable Disease (NCD) risk** - specifically Type 2 Diabetes and Hypertension - from patient clinical data.
 
 
25
 
26
+ ## Model Description
27
 
28
+ This model was fine-tuned on 49,214 synthetic patient records to provide clinical decision support for NCD screening in resource-limited settings, particularly designed for deployment in Ghana and similar healthcare contexts.
29
+
30
+ | Attribute | Value |
31
+ |-----------|-------|
32
+ | Base Model | `google/gemma-4-E4B-it` |
33
+ | Fine-tuning Method | QLoRA (4-bit) with Unsloth |
34
+ | LoRA Rank | 32 |
35
+ | Training Data | 39,371 examples |
36
+ | Final Loss | 0.1842 |
37
+ | Training Time | 100 minutes (H200 GPU) |
38
+
39
+ ## Intended Use
40
+
41
+ **Primary Use Case:** Clinical Decision Support (CDS) for NCD risk screening
42
+
43
+ **Target Users:**
44
+ - Healthcare workers in primary care settings
45
+ - Community health workers conducting NCD screenings
46
+ - EHR systems (e.g., OpenMRS/HopeOS) for automated risk assessment
47
+
48
+ **Input:** Patient demographics, vitals, and lab values
49
+ **Output:** Structured risk assessment with clinical reasoning
50
+
51
+ ## Model Files
52
+
53
+ | File | Format | Size | Use Case |
54
+ |------|--------|------|----------|
55
+ | `adapter_model.safetensors` | LoRA | ~340MB | Fine-tuning, merging |
56
+ | `ncd-gemma4-q4_k_m.gguf` | GGUF | ~2.5GB | Local inference (llama.cpp, Ollama) |
57
+
58
+ ## How to Use
59
+
60
+ ### With Transformers + PEFT (LoRA)
61
+
62
+ ```python
63
+ from transformers import AutoModelForCausalLM, AutoTokenizer
64
+ from peft import PeftModel
65
+
66
+ # Load base model
67
+ base_model = AutoModelForCausalLM.from_pretrained("google/gemma-4-E4B-it")
68
+ tokenizer = AutoTokenizer.from_pretrained("google/gemma-4-E4B-it")
69
+
70
+ # Load LoRA adapter
71
+ model = PeftModel.from_pretrained(base_model, "samwell/ncd-gemma4-e4b-lora")
72
+
73
+ # Inference
74
+ prompt = """Based on the following patient record, assess the risk of Type 2 diabetes and hypertension.
75
+
76
+ Patient: 55yo Male
77
+ Vitals: BP 152/94 mmHg, BMI 31.2
78
+ Labs: Glucose 126 mg/dL, HbA1c 6.4%
79
+ Active conditions: Prediabetes"""
80
+
81
+ inputs = tokenizer(prompt, return_tensors="pt")
82
+ outputs = model.generate(**inputs, max_new_tokens=512)
83
+ print(tokenizer.decode(outputs[0]))
84
+ ```
85
+
86
+ ### With llama.cpp (GGUF)
87
+
88
+ ```bash
89
+ # Download GGUF
90
+ huggingface-cli download samwell/ncd-gemma4-e4b-lora ncd-gemma4-q4_k_m.gguf
91
+
92
+ # Run inference
93
+ ./llama-cli -m ncd-gemma4-q4_k_m.gguf -p "Patient: 45yo Female, BP 140/90..."
94
+ ```
95
+
96
+ ### With Ollama
97
+
98
+ ```bash
99
+ # Create model
100
+ echo 'FROM ./ncd-gemma4-q4_k_m.gguf' > Modelfile
101
+ ollama create ncd-cds -f Modelfile
102
+
103
+ # Run
104
+ ollama run ncd-cds "Patient: 45yo Female, BP 140/90..."
105
+ ```
106
+
107
+ ## Example Output
108
+
109
+ **Input:**
110
+ ```
111
+ Patient: 55yo Male
112
+ Vitals: BP 152/94 mmHg, BMI 31.2
113
+ Labs: Glucose 126 mg/dL, HbA1c 6.4%
114
+ Active conditions: Prediabetes
115
+ ```
116
+
117
+ **Output:**
118
+ ```
119
+ ## Risk Assessment
120
+
121
+ **Type 2 Diabetes: MODERATE**
122
+ - HbA1c 6.4% (prediabetes range 5.7-6.4%)
123
+ - BMI 31.2 (obese)
124
+ - Age 55 years (≥45 increases risk)
125
+
126
+ **Hypertension: HIGH**
127
+ - BP 152/94 mmHg (Stage 2 Hypertension)
128
+ - Systolic ≥140 or Diastolic ≥90 confirms diagnosis
129
+
130
+ ## Recommendations
131
+
132
+ 1. **Lifestyle modifications**: Weight loss, DASH diet, sodium reduction
133
+ 2. **Blood pressure monitoring**: Home BP monitoring recommended
134
+ 3. **Lab follow-up**: Repeat HbA1c in 3 months
135
+ 4. **Consider referral**: If BP remains elevated, initiate antihypertensive therapy
136
+ ```
137
+
138
+ ## Training Details
139
+
140
+ ### Dataset
141
+
142
+ - **Source:** Synthea synthetic patient generator
143
+ - **Size:** 49,214 examples (39,371 train / 4,921 val / 4,922 test)
144
+ - **Format:** Instruction-tuning (instruction/input/output)
145
+ - **Dataset:** [`samwell/synthea-ncd-instructions`](https://huggingface.co/datasets/samwell/synthea-ncd-instructions)
146
+
147
+ ### Training Configuration
148
+
149
+ ```python
150
+ # Model
151
+ MODEL_NAME = "google/gemma-4-E4B-it"
152
+ MAX_SEQ_LENGTH = 2048
153
+ LOAD_IN_4BIT = True # QLoRA
154
+
155
+ # LoRA
156
+ LORA_R = 32
157
+ LORA_ALPHA = 32
158
+ TARGET_MODULES = ["q_proj", "k_proj", "v_proj", "o_proj",
159
+ "gate_proj", "up_proj", "down_proj"]
160
+
161
+ # Training
162
+ BATCH_SIZE = 8
163
+ GRADIENT_ACCUMULATION = 2 # Effective batch = 16
164
+ LEARNING_RATE = 2e-4
165
+ NUM_EPOCHS = 3
166
+ ```
167
+
168
+ ### Training Curve
169
+
170
+ - Initial loss: 1.71
171
+ - Final loss: 0.1842
172
+ - Training time: 100 minutes on NVIDIA H200 (80GB)
173
+
174
+ ## Limitations
175
+
176
+ 1. **Synthetic data only:** Trained on Synthea-generated data, not real patient records
177
+ 2. **US demographics:** Synthea defaults to US population demographics
178
+ 3. **Limited NCDs:** Currently only assesses diabetes and hypertension
179
+ 4. **Not a diagnostic tool:** Intended for screening support, not clinical diagnosis
180
+ 5. **Requires clinical validation:** Must be validated by healthcare professionals before clinical use
181
+
182
+ ## Ethical Considerations
183
+
184
+ - **Not FDA/CE approved** for clinical diagnosis
185
+ - Should be used as **decision support**, not replacement for clinical judgment
186
+ - Predictions should be **reviewed by qualified healthcare providers**
187
+ - Model may reflect biases in training data
188
+
189
+ ## Citation
190
+
191
+ ```bibtex
192
+ @misc{ncd-gemma4-2026,
193
+ author = {HopeOS Team},
194
+ title = {NCD Risk Assessment Model: Fine-tuned Gemma 4 for Diabetes and Hypertension Prediction},
195
+ year = {2026},
196
+ publisher = {HuggingFace},
197
+ url = {https://huggingface.co/samwell/ncd-gemma4-e4b-lora}
198
+ }
199
+ ```
200
+
201
+ ## Related Resources
202
+
203
+ - **Dataset:** [samwell/synthea-ncd-instructions](https://huggingface.co/datasets/samwell/synthea-ncd-instructions)
204
+ - **Base Model:** [google/gemma-4-E4B-it](https://huggingface.co/google/gemma-4-E4B-it)
205
+ - **Training Library:** [Unsloth](https://github.com/unslothai/unsloth)
206
+
207
+ ## License
208
+
209
+ This model is released under the [Gemma license](https://ai.google.dev/gemma/terms).