Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
tags:
|
| 4 |
+
- medical
|
| 5 |
+
- clinical-notes
|
| 6 |
+
- patient-communication
|
| 7 |
+
- lora
|
| 8 |
+
- peft
|
| 9 |
+
- medgemma
|
| 10 |
+
language:
|
| 11 |
+
- en
|
| 12 |
+
library_name: peft
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# NoteExplain Models
|
| 16 |
+
|
| 17 |
+
Trained models for clinical note simplification - translating medical documents into patient-friendly language.
|
| 18 |
+
|
| 19 |
+
## Models
|
| 20 |
+
|
| 21 |
+
| Model | Base | Description | Overall | Accuracy | Patient-Centered |
|
| 22 |
+
|-------|------|-------------|---------|----------|------------------|
|
| 23 |
+
| **gemma-2b-distilled** | gemma-2-2b-it | Final mobile model | 70% | 73% | **76%** |
|
| 24 |
+
| **gemma-2b-dpo** | gemma-2-2b-it | DPO comparison | **73%** | **82%** | 61% |
|
| 25 |
+
| **gemma-9b-dpo** | gemma-2-9b-it | Teacher model | 79% | 91% | 70% |
|
| 26 |
+
|
| 27 |
+
## Usage
|
| 28 |
+
|
| 29 |
+
```python
|
| 30 |
+
from peft import PeftModel
|
| 31 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 32 |
+
|
| 33 |
+
# Load the distilled model (recommended for deployment)
|
| 34 |
+
base_model = AutoModelForCausalLM.from_pretrained("google/gemma-2-2b-it")
|
| 35 |
+
tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-2b-it")
|
| 36 |
+
model = PeftModel.from_pretrained(base_model, "dejori/note-explain", subfolder="gemma-2b-distilled")
|
| 37 |
+
|
| 38 |
+
# Or load the DPO model (higher accuracy)
|
| 39 |
+
model = PeftModel.from_pretrained(base_model, "dejori/note-explain", subfolder="gemma-2b-dpo")
|
| 40 |
+
|
| 41 |
+
# Generate
|
| 42 |
+
prompt = "Simplify this clinical note for a patient:\n\n[clinical note]\n\nSimplified version:"
|
| 43 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
| 44 |
+
outputs = model.generate(**inputs, max_new_tokens=512)
|
| 45 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
## Training
|
| 49 |
+
|
| 50 |
+
- **DPO Training**: MedGemma-27B scored 5 candidate outputs per clinical note, creating preference pairs
|
| 51 |
+
- **Distillation**: 9B-DPO model generated high-quality outputs to train the 2B model via SFT
|
| 52 |
+
|
| 53 |
+
## Dataset
|
| 54 |
+
|
| 55 |
+
Training data: [dejori/note-explain-clinical](https://huggingface.co/datasets/dejori/note-explain-clinical)
|
| 56 |
+
|
| 57 |
+
## Citation
|
| 58 |
+
|
| 59 |
+
```bibtex
|
| 60 |
+
@misc{noteexplain2026,
|
| 61 |
+
title={NoteExplain: Privacy-First Clinical Note Simplification},
|
| 62 |
+
author={Dejori, Mathaeus},
|
| 63 |
+
year={2026},
|
| 64 |
+
publisher={HuggingFace}
|
| 65 |
+
}
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
## License
|
| 69 |
+
|
| 70 |
+
Apache 2.0
|