cristian-untaru commited on
Commit
fa32230
·
verified ·
1 Parent(s): 6f074c9

Update model card

Browse files
Files changed (1) hide show
  1. README.md +321 -55
README.md CHANGED
@@ -1,55 +1,321 @@
1
- ---
2
- library_name: transformers
3
- pipeline_tag: text-classification
4
- base_model: distilbert-base-uncased
5
- tags:
6
- - medical-triage
7
- - text-classification
8
- - peft
9
- - lora
10
- - sortmed
11
- ---
12
-
13
- # LoRA DistilBERT Medical Triage
14
-
15
- This model is a LoRA-adapted sequence classifier for three-class medical pre-triage classification.
16
-
17
- ## Base model
18
-
19
- `distilbert-base-uncased`
20
-
21
- ## Task
22
-
23
- The classifier predicts one of three triage labels:
24
-
25
- - `self_monitor`
26
- - `consult_gp`
27
- - `urgent`
28
-
29
- ## Training setup
30
-
31
- - Dataset: SymCAT-derived medical triage dataset
32
- - Adaptation method: Low-Rank Adaptation (LoRA)
33
- - LoRA rank: 16
34
- - LoRA alpha: 32
35
- - LoRA dropout: 0.10
36
- - Max sequence length: 128
37
- - Epochs: 8
38
- - Best checkpoint selected by validation macro F1
39
-
40
- ## Test metrics
41
-
42
- ```json
43
- {
44
- "eval_loss": 0.5353153944015503,
45
- "eval_accuracy": 0.8491,
46
- "eval_precision": 0.849,
47
- "eval_recall": 0.849,
48
- "eval_f1": 0.849,
49
- "eval_auc": 0.9197,
50
- "eval_specificity": 0.924,
51
- "eval_iou": 0.7408
52
- }
53
- ```
54
-
55
- This model is intended for academic experimentation and prototyping, not for standalone clinical decision-making.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ datasets:
6
+ - cristian-untaru/symcat-medical-triage-dataset
7
+ tags:
8
+ - medical-triage
9
+ - text-classification
10
+ - distilbert
11
+ - peft
12
+ - lora
13
+ - healthcare
14
+ - symptom-checker
15
+ - natural-language-processing
16
+ - academic-project
17
+ pipeline_tag: text-classification
18
+ library_name: transformers
19
+ base_model: distilbert-base-uncased
20
+ model-index:
21
+ - name: lora-distilbert-medical-triage
22
+ results:
23
+ - task:
24
+ type: text-classification
25
+ name: Medical pre-triage classification
26
+ dataset:
27
+ name: SymCAT Medical Triage Dataset
28
+ type: cristian-untaru/symcat-medical-triage-dataset
29
+ metrics:
30
+ - type: accuracy
31
+ value: 0.8491
32
+ name: Accuracy
33
+ - type: f1
34
+ value: 0.849
35
+ name: Macro F1
36
+ - type: precision
37
+ value: 0.849
38
+ name: Macro Precision
39
+ - type: recall
40
+ value: 0.849
41
+ name: Macro Recall
42
+ - type: roc_auc
43
+ value: 0.9197
44
+ name: Macro AUC OvR
45
+ ---
46
+
47
+ # LoRA DistilBERT Medical Triage Classifier
48
+
49
+ ## Model Description
50
+
51
+ This repository contains a merged LoRA-adapted DistilBERT sequence classification model. LoRA trains low-rank adapter matrices and the classification head, then exports the merged model for standard Transformers loading.
52
+
53
+ The model receives a short English symptom description and predicts one of the following triage-oriented labels:
54
+
55
+ - `self_monitor`
56
+ - `consult_gp`
57
+ - `urgent`
58
+
59
+ This model was developed as part of the **SortMed** academic project, a medical pre-triage assistant prototype built for a bachelor's thesis by **Cristian Untaru** at the **West University of Timișoara, Faculty of Informatics**.
60
+
61
+ The model is intended for research and educational use. It is not a diagnostic system and is not a certified medical device.
62
+
63
+ ## Intended Use
64
+
65
+ This model is intended to be used in an academic medical pre-triage prototype for:
66
+
67
+ - classifying English symptom descriptions into broad urgency categories;
68
+ - comparing transformer-based models for medical text classification;
69
+ - evaluating full fine-tuning against parameter-efficient fine-tuning methods;
70
+ - supporting experimental NLP research in symptom-based medical pre-triage.
71
+
72
+ Example input:
73
+
74
+ ```text
75
+ I have chest pain, shortness of breath, and I feel dizzy.
76
+ ```
77
+
78
+ Example output:
79
+
80
+ ```text
81
+ urgent
82
+ ```
83
+
84
+ ## Out-of-Scope Use
85
+
86
+ This model must not be used as:
87
+
88
+ - a replacement for professional medical advice;
89
+ - a diagnostic system;
90
+ - an emergency decision-making tool;
91
+ - a certified clinical triage system;
92
+ - a standalone healthcare product;
93
+ - a tool for non-English medical text without additional validation.
94
+
95
+ For severe, worsening, or emergency symptoms, users should contact emergency services or a qualified healthcare professional.
96
+
97
+ ## Labels
98
+
99
+ The model predicts one of three labels:
100
+
101
+ | Label | Meaning |
102
+ |---|---|
103
+ | `self_monitor` | Symptoms appear mild and may be monitored, assuming no worsening or additional warning signs. |
104
+ | `consult_gp` | A general practitioner or non-emergency medical professional should be consulted. |
105
+ | `urgent` | Symptoms may require urgent medical attention or emergency evaluation. |
106
+
107
+ The label mapping is included in [`label_map.json`](./label_map.json) and in the model configuration.
108
+
109
+ Expected mapping:
110
+
111
+ ```python
112
+ {
113
+ 0: "self_monitor",
114
+ 1: "consult_gp",
115
+ 2: "urgent",
116
+ }
117
+ ```
118
+
119
+ ## Training Data
120
+
121
+ The model was trained on the [`cristian-untaru/symcat-medical-triage-dataset`](https://huggingface.co/datasets/cristian-untaru/symcat-medical-triage-dataset), a SymCAT-derived dataset prepared for academic experiments in medical pre-triage classification.
122
+
123
+ The dataset contains English symptom-based text examples labeled into three triage classes:
124
+
125
+ - `self_monitor`
126
+ - `consult_gp`
127
+ - `urgent`
128
+
129
+ Dataset split used for training:
130
+
131
+ | Split | Examples |
132
+ |---|---:|
133
+ | Train | 490 |
134
+ | Validation | 105 |
135
+ | Test | 106 |
136
+ | Total | 701 |
137
+
138
+ The dataset labels were produced using rule-based triage logic for academic experimentation. They are not clinically validated annotations from medical professionals.
139
+
140
+ MedQuAD was not used to train this classifier. In the broader SortMed system, MedQuAD is used separately for retrieval of related medical information through the [`cristian-untaru/medquad-retrieval-pretriage`](https://huggingface.co/datasets/cristian-untaru/medquad-retrieval-pretriage) dataset.
141
+
142
+ ## Training Procedure
143
+
144
+ Base checkpoint:
145
+
146
+ ```text
147
+ distilbert-base-uncased
148
+ ```
149
+
150
+ | Parameter | Value |
151
+ |---|---:|
152
+ | Fine-tuning method | Low-Rank Adaptation (LoRA) |
153
+ | Maximum sequence length | 128 |
154
+ | Epochs | 8 |
155
+ | Train batch size | 16 |
156
+ | Evaluation batch size | 32 |
157
+ | Learning rate | 0.0002 |
158
+ | Weight decay | 0.01 |
159
+ | Warmup ratio | 0.1 |
160
+ | Mixed precision | FP16 |
161
+ | Early stopping patience | 3 |
162
+ | Best checkpoint metric | f1 |
163
+ | Random seed | 42 |
164
+ | LoRA rank | 16 |
165
+ | LoRA alpha | 32 |
166
+ | LoRA dropout | 0.1 |
167
+ | Target modules | q_lin, v_lin |
168
+ | Modules saved with adapter | pre_classifier, classifier |
169
+
170
+ Additional training metadata is available in [`training_config.json`](./training_config.json).
171
+
172
+ ## Evaluation Results
173
+
174
+ The model was evaluated on the held-out test split.
175
+
176
+ | Metric | Test Score |
177
+ |---|---:|
178
+ | Accuracy | 0.8491 |
179
+ | Macro Precision | 0.8490 |
180
+ | Macro Recall / Sensitivity | 0.8490 |
181
+ | Macro Specificity | 0.9240 |
182
+ | Macro F1 | 0.8490 |
183
+ | Macro AUC OvR | 0.9197 |
184
+ | Macro IoU / Jaccard | 0.7408 |
185
+ | Test Loss | 0.5353 |
186
+
187
+ ### Per-Class Results
188
+
189
+ Per-class metrics are not currently published as a separate artifact in this repository. The aggregate test metrics above are the available published evaluation results.
190
+
191
+ These results should be interpreted in the context of the small dataset size and the academic nature of the experiment.
192
+
193
+ ## How to Use
194
+
195
+ ```python
196
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
197
+ import torch
198
+
199
+ repo_id = "cristian-untaru/lora-distilbert-medical-triage"
200
+
201
+ tokenizer = AutoTokenizer.from_pretrained(repo_id)
202
+ model = AutoModelForSequenceClassification.from_pretrained(repo_id)
203
+
204
+ text = "I have chest pain, shortness of breath, and I feel dizzy."
205
+
206
+ inputs = tokenizer(
207
+ text,
208
+ return_tensors="pt",
209
+ truncation=True,
210
+ padding=True,
211
+ max_length=128
212
+ )
213
+
214
+ with torch.no_grad():
215
+ outputs = model(**inputs)
216
+ probabilities = torch.softmax(outputs.logits, dim=-1)
217
+ predicted_class_id = torch.argmax(probabilities, dim=-1).item()
218
+
219
+ predicted_label = model.config.id2label[predicted_class_id]
220
+ confidence = probabilities[0][predicted_class_id].item()
221
+
222
+ print("Predicted label:", predicted_label)
223
+ print("Confidence:", round(confidence, 4))
224
+ ```
225
+
226
+
227
+ This model loads with the standard Transformers API and does not require `trust_remote_code=True`.
228
+
229
+
230
+ To verify the label mapping:
231
+
232
+ ```python
233
+ print(model.config.id2label)
234
+ ```
235
+
236
+ Expected output:
237
+
238
+ ```python
239
+ {0: "self_monitor", 1: "consult_gp", 2: "urgent"}
240
+ ```
241
+
242
+ ## Repository Files
243
+
244
+ | File | Description |
245
+ |---|---|
246
+ | `config.json` | Model architecture, label mapping, and classification configuration. |
247
+ | `model.safetensors` | Model weights in SafeTensors format. |
248
+ | `tokenizer.json` | Tokenizer vocabulary and processing pipeline. |
249
+ | `tokenizer_config.json` | Tokenizer configuration. |
250
+ | `training_config.json` | Human-readable training configuration. |
251
+ | `label_map.json` | Mapping between numeric class IDs and triage labels. |
252
+ | `README.md` | Model card documentation. |
253
+ | `.gitattributes` | Git LFS configuration for large model files. |
254
+
255
+ ## Limitations
256
+
257
+ This model has several important limitations:
258
+
259
+ - It was trained on a small academic dataset.
260
+ - The labels are rule-based and not clinically validated by medical experts.
261
+ - It does not perform medical diagnosis.
262
+ - It does not consider patient age, sex, medical history, medication history, vital signs, comorbidities, pregnancy status, allergies, or physical examination findings.
263
+ - It may produce incorrect predictions for rare, ambiguous, incomplete, severe, or contradictory symptom descriptions.
264
+ - It was trained for English text only.
265
+ - It should not be used for emergency triage without medical supervision.
266
+ - Its predictions depend on the quality and completeness of the user-provided text.
267
+
268
+ ## Ethical and Safety Considerations
269
+
270
+ Medical pre-triage systems can influence user decisions in sensitive healthcare situations. This model should therefore be used only with clear disclaimers and with safeguards that encourage users to seek professional medical care when appropriate.
271
+
272
+ Any real-world deployment would require:
273
+
274
+ - clinical expert review;
275
+ - validation on larger and more representative medical datasets;
276
+ - safety testing;
277
+ - bias and fairness evaluation;
278
+ - monitoring for incorrect or unsafe predictions;
279
+ - clear user-facing warnings;
280
+ - escalation rules for emergency symptoms.
281
+
282
+ ## Medical Disclaimer
283
+
284
+ This model is intended only for academic, research, and prototype development purposes. It is not a substitute for professional medical advice, diagnosis, treatment, or emergency care.
285
+
286
+ If symptoms are severe, sudden, worsening, or potentially life-threatening, users should contact emergency services or a qualified healthcare professional immediately.
287
+
288
+ ## Related Datasets
289
+
290
+ - [`cristian-untaru/symcat-medical-triage-dataset`](https://huggingface.co/datasets/cristian-untaru/symcat-medical-triage-dataset)
291
+ - [`cristian-untaru/medquad-retrieval-pretriage`](https://huggingface.co/datasets/cristian-untaru/medquad-retrieval-pretriage)
292
+
293
+ ## Related Models
294
+
295
+ ### Full Fine-Tuned Models
296
+
297
+ - [`cristian-untaru/distilbert-medical-triage`](https://huggingface.co/cristian-untaru/distilbert-medical-triage)
298
+ - [`cristian-untaru/biobert-medical-triage`](https://huggingface.co/cristian-untaru/biobert-medical-triage)
299
+ - [`cristian-untaru/roberta-medical-triage`](https://huggingface.co/cristian-untaru/roberta-medical-triage)
300
+ - [`cristian-untaru/biomedbert-medical-triage`](https://huggingface.co/cristian-untaru/biomedbert-medical-triage)
301
+
302
+ ### LoRA Models
303
+
304
+ - [`cristian-untaru/lora-distilbert-medical-triage`](https://huggingface.co/cristian-untaru/lora-distilbert-medical-triage)
305
+ - [`cristian-untaru/lora-biobert-medical-triage`](https://huggingface.co/cristian-untaru/lora-biobert-medical-triage)
306
+ - [`cristian-untaru/lora-roberta-medical-triage`](https://huggingface.co/cristian-untaru/lora-roberta-medical-triage)
307
+ - [`cristian-untaru/lora-biomedbert-medical-triage`](https://huggingface.co/cristian-untaru/lora-biomedbert-medical-triage)
308
+
309
+ ### Bottleneck MLP Adapter Models
310
+
311
+ - [`cristian-untaru/bottleneck-mlp-distilbert-medical-triage`](https://huggingface.co/cristian-untaru/bottleneck-mlp-distilbert-medical-triage)
312
+ - [`cristian-untaru/bottleneck-mlp-biobert-medical-triage`](https://huggingface.co/cristian-untaru/bottleneck-mlp-biobert-medical-triage)
313
+ - [`cristian-untaru/bottleneck-mlp-roberta-medical-triage`](https://huggingface.co/cristian-untaru/bottleneck-mlp-roberta-medical-triage)
314
+ - [`cristian-untaru/bottleneck-mlp-biomedbert-medical-triage`](https://huggingface.co/cristian-untaru/bottleneck-mlp-biomedbert-medical-triage)
315
+
316
+ ### Frozen Encoder Models
317
+
318
+ - [`cristian-untaru/frozen-encoder-distilbert-medical-triage`](https://huggingface.co/cristian-untaru/frozen-encoder-distilbert-medical-triage)
319
+ - [`cristian-untaru/frozen-encoder-biobert-medical-triage`](https://huggingface.co/cristian-untaru/frozen-encoder-biobert-medical-triage)
320
+ - [`cristian-untaru/frozen-encoder-roberta-medical-triage`](https://huggingface.co/cristian-untaru/frozen-encoder-roberta-medical-triage)
321
+ - [`cristian-untaru/frozen-encoder-biomedbert-medical-triage`](https://huggingface.co/cristian-untaru/frozen-encoder-biomedbert-medical-triage)