Edifon commited on
Commit
fe6588d
·
verified ·
1 Parent(s): 9f5d645

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +184 -5
README.md CHANGED
@@ -5,17 +5,196 @@ tags:
5
  - transformers
6
  - unsloth
7
  - gemma3
 
 
 
8
  license: apache-2.0
9
  language:
10
  - en
11
  ---
12
 
13
- # Uploaded finetuned model
14
 
15
- - **Developed by:** Edifon
16
- - **License:** apache-2.0
17
- - **Finetuned from model :** unsloth/gemma-3-4b-it-unsloth-bnb-4bit
18
 
19
- This gemma3 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
20
 
21
  [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  - transformers
6
  - unsloth
7
  - gemma3
8
+ - medical
9
+ - clinical-nlp
10
+ - soap-notes
11
  license: apache-2.0
12
  language:
13
  - en
14
  ---
15
 
16
+ # SOAP_SFT_V1 — Medical SOAP Note Generator
17
 
18
+ **SOAP_SFT_V1** is a fine-tuned version of [Gemma 3 4B Instruct](https://huggingface.co/unsloth/gemma-3-4b-it-unsloth-bnb-4bit), trained to generate structured clinical **SOAP notes** (Subjective, Objective, Assessment, Plan) from doctor–patient dialogues.
 
 
19
 
20
+ Trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Hugging Face's TRL library on an H100 GPU.
21
 
22
  [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
23
+
24
+ ---
25
+
26
+ ## Model Details
27
+
28
+ | Property | Value |
29
+ |---|---|
30
+ | **Developed by** | Edifon |
31
+ | **Base model** | `unsloth/gemma-3-4b-it-unsloth-bnb-4bit` |
32
+ | **Model type** | Causal Language Model (fine-tuned) |
33
+ | **Language** | English |
34
+ | **License** | Apache 2.0 |
35
+ | **Fine-tuning method** | Supervised Fine-Tuning (SFT) with LoRA |
36
+ | **Training hardware** | Google Colab H100 |
37
+
38
+ ---
39
+
40
+ ## Intended Use
41
+
42
+ This model is designed to assist healthcare professionals and clinical NLP researchers by automatically converting clinical consultation transcripts into structured SOAP notes.
43
+
44
+ **SOAP format:**
45
+ - **S (Subjective):** Patient-reported symptoms, history, and complaints
46
+ - **O (Objective):** Observable/measurable clinical findings and planned investigations
47
+ - **A (Assessment):** Differential diagnosis and clinical reasoning
48
+ - **P (Plan):** Treatment plan, referrals, and follow-up instructions
49
+
50
+ > ⚠️ **Disclaimer:** This model is intended as a research and assistive tool only. It is **not** a substitute for professional medical judgment or a licensed clinician's evaluation.
51
+
52
+ ---
53
+
54
+ ## Training Details
55
+
56
+ ### Dataset
57
+ - **Dataset:** [`syafiqassegaf/soap-dataset`](https://www.kaggle.com/datasets/syafiqassegaf/soap-dataset) (Kaggle)
58
+ - **Total examples:** 9,250
59
+ - **Train / Eval split:** 90% / 10% → 8,325 train | 925 eval
60
+ - **Features:** `dialogue`, `soap`, `prompt`, `messages`
61
+
62
+ ### LoRA Configuration
63
+
64
+ | Parameter | Value |
65
+ |---|---|
66
+ | Rank (`r`) | 8 |
67
+ | Alpha (`lora_alpha`) | 8 |
68
+ | Dropout | 0 |
69
+ | Bias | none |
70
+ | Target modules | `q_proj`, `k_proj`, `v_proj`, `o_proj`, `gate_proj`, `up_proj`, `down_proj` |
71
+ | Trainable parameters | 16,394,240 / 4,316,473,712 (**0.38%**) |
72
+ | Vision layers finetuned | No |
73
+ | Language layers finetuned | Yes |
74
+
75
+ ### Training Hyperparameters
76
+
77
+ | Parameter | Value |
78
+ |---|---|
79
+ | Epochs | 5 |
80
+ | Per-device batch size | 2 |
81
+ | Gradient accumulation steps | 4 (effective batch size = 8) |
82
+ | Learning rate | 2e-5 |
83
+ | LR scheduler | Linear |
84
+ | Optimizer | AdamW 8-bit |
85
+ | Weight decay | 0.001 |
86
+ | Warmup steps | 5 |
87
+ | Max sequence length | 2048 |
88
+ | Seed | 3407 |
89
+ | Total steps | 5,205 |
90
+
91
+ Training used `train_on_responses_only` — only model responses were used in the loss computation, not the user instructions.
92
+
93
+ ---
94
+
95
+ ## How to Use
96
+
97
+ ### With `transformers` (Standard)
98
+
99
+ ```python
100
+ from transformers import AutoProcessor, AutoModelForImageTextToText
101
+
102
+ processor = AutoProcessor.from_pretrained("Edifon/SOAP_SFT_V1")
103
+ model = AutoModelForImageTextToText.from_pretrained("Edifon/SOAP_SFT_V1", device_map="auto")
104
+
105
+ messages = [
106
+ {
107
+ "role": "system",
108
+ "content": [{"type": "text", "text": (
109
+ "You are an expert medical professor assisting in the creation of medically accurate SOAP summaries. "
110
+ "Please ensure the response follows the structured format: S:, O:, A:, P: without using markdown or special formatting."
111
+ )}],
112
+ },
113
+ {
114
+ "role": "user",
115
+ "content": [{"type": "text", "text": """Create a medical SOAP summary of this dialogue.
116
+
117
+ ### Dialogue:
118
+ Doctor: Hello, what brings you in today?
119
+ Patient: I've been having severe headaches for the past few weeks...
120
+ [rest of dialogue]
121
+ """}],
122
+ },
123
+ ]
124
+
125
+ inputs = processor.apply_chat_template(
126
+ messages,
127
+ add_generation_prompt=True,
128
+ tokenize=True,
129
+ return_dict=True,
130
+ return_tensors="pt",
131
+ ).to(model.device)
132
+
133
+ from transformers import TextStreamer
134
+ _ = model.generate(
135
+ **inputs,
136
+ max_new_tokens=2048,
137
+ streamer=TextStreamer(processor, skip_prompt=True),
138
+ )
139
+ ```
140
+
141
+ ### With Unsloth (Faster Inference)
142
+
143
+ ```python
144
+ from unsloth import FastModel
145
+
146
+ model, tokenizer = FastModel.from_pretrained(
147
+ model_name="Edifon/SOAP_SFT_V1",
148
+ max_seq_length=2048,
149
+ load_in_4bit=True,
150
+ )
151
+ FastModel.for_inference(model)
152
+ ```
153
+
154
+ ---
155
+
156
+ ## Example Output
157
+
158
+ **Input dialogue (excerpt):**
159
+ > Patient reports photopsia in the left eye for ten days, including flashes of light and a dark spot on the nasal side. Had influenza-like symptoms two weeks prior. No history of eye disease.
160
+
161
+ **Model output:**
162
+ ```
163
+ S: Patient reports experiencing photopsia in the left eye for ten days, describing flashes of light
164
+ and a dark spot on the nasal side. History of influenza-like symptoms two weeks prior.
165
+ No prior eye disease, operations, or treatments.
166
+
167
+ O: Patient presented with photopsia and a dark spot in the left eye. Comprehensive eye examination
168
+ planned (visual acuity, slit-lamp, fundus examination).
169
+
170
+ A: Differential includes post-infectious transient optic neuropathy or acute ocular involvement
171
+ secondary to influenza. Absence of prior eye disease supports opportunistic onset.
172
+
173
+ P: Order comprehensive eye examination. Schedule follow-up to review results and determine
174
+ treatment or referral plan. Encourage prompt completion of planned examination.
175
+ ```
176
+
177
+ ---
178
+
179
+ ## Limitations
180
+
181
+ - Trained exclusively on English-language dialogues
182
+ - Performance may degrade on highly specialized subspecialty consultations underrepresented in the training data
183
+ - Should not be used for clinical decision-making without expert oversight
184
+ - Outputs may occasionally include disclaimers or formatting inconsistencies
185
+
186
+ ---
187
+
188
+ ## Citation
189
+
190
+ If you use this model in your research, please cite the base model and dataset:
191
+
192
+ ```bibtex
193
+ @misc{soap_sft_v1,
194
+ author = {Edifon},
195
+ title = {SOAP\_SFT\_V1: Medical SOAP Note Generator},
196
+ year = {2025},
197
+ publisher = {Hugging Face},
198
+ url = {https://huggingface.co/Edifon/SOAP_SFT_V1}
199
+ }
200
+ ```