cristian-untaru commited on
Commit
ed1002b
·
verified ·
1 Parent(s): abc6398

Update model card

Browse files
Files changed (1) hide show
  1. README.md +317 -67
README.md CHANGED
@@ -1,67 +1,317 @@
1
- ---
2
- library_name: transformers
3
- pipeline_tag: text-classification
4
- base_model: microsoft/BiomedNLP-BiomedBERT-base-uncased-abstract-fulltext
5
- tags:
6
- - medical-triage
7
- - text-classification
8
- - peft
9
- - frozen-encoder
10
- - linear-probe
11
- - sortmed
12
- ---
13
-
14
- # Frozen Encoder BioMedBERT Medical Triage
15
-
16
- This model is a frozen-encoder sequence classifier for three-class medical
17
- pre-triage classification. The pretrained encoder/backbone is kept frozen and
18
- only the classification head is trained.
19
-
20
- ## Base model
21
-
22
- `microsoft/BiomedNLP-BiomedBERT-base-uncased-abstract-fulltext`
23
-
24
- ## Task
25
-
26
- The classifier predicts one of three triage labels:
27
-
28
- - `self_monitor`
29
- - `consult_gp`
30
- - `urgent`
31
-
32
- ## Adaptation method
33
-
34
- - Method: Frozen Encoder + Trainable Classification Head
35
- - Base encoder: frozen
36
- - Trainable: classification head (+ pooler for BERT-style models)
37
- - Max sequence length: 128
38
- - Epochs: 8 (early stopping patience 3), best checkpoint by validation macro F1
39
-
40
- ## Loading
41
-
42
- This is a standard Transformers model and loads with the plain API
43
- (no `trust_remote_code` required):
44
-
45
- ```python
46
- from transformers import AutoModelForSequenceClassification, AutoTokenizer
47
- tok = AutoTokenizer.from_pretrained("cristian-untaru/frozen-encoder-biomedbert-medical-triage")
48
- model = AutoModelForSequenceClassification.from_pretrained("cristian-untaru/frozen-encoder-biomedbert-medical-triage")
49
- ```
50
-
51
- ## Test metrics
52
-
53
- ```json
54
- {
55
- "eval_loss": 0.8381163477897644,
56
- "eval_accuracy": 0.6038,
57
- "eval_precision": 0.6201,
58
- "eval_recall": 0.6058,
59
- "eval_f1": 0.6107,
60
- "eval_auc": 0.8076,
61
- "eval_specificity": 0.7995,
62
- "eval_iou": 0.4444
63
- }
64
- ```
65
-
66
- This model is intended for academic experimentation and prototyping, not for
67
- 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
+ - biomedbert
11
+ - peft
12
+ - frozen-encoder
13
+ - healthcare
14
+ - symptom-checker
15
+ - natural-language-processing
16
+ - academic-project
17
+ pipeline_tag: text-classification
18
+ library_name: transformers
19
+ base_model: microsoft/BiomedNLP-BiomedBERT-base-uncased-abstract-fulltext
20
+ model-index:
21
+ - name: frozen-encoder-biomedbert-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.6038
32
+ name: Accuracy
33
+ - type: f1
34
+ value: 0.6107
35
+ name: Macro F1
36
+ - type: precision
37
+ value: 0.6201
38
+ name: Macro Precision
39
+ - type: recall
40
+ value: 0.6058
41
+ name: Macro Recall
42
+ - type: roc_auc
43
+ value: 0.8076
44
+ name: Macro AUC OvR
45
+ ---
46
+
47
+ # Frozen Encoder BioMedBERT Medical Triage Classifier
48
+
49
+ ## Model Description
50
+
51
+ This repository contains a frozen-encoder BioMedBERT sequence classification model. The pretrained encoder is kept frozen and only the classification head is trained.
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
+ microsoft/BiomedNLP-BiomedBERT-base-uncased-abstract-fulltext
148
+ ```
149
+
150
+ | Parameter | Value |
151
+ |---|---:|
152
+ | Fine-tuning method | Frozen Encoder + Trainable Classification Head |
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
+ | Trainable modules | pooler, classifier |
165
+
166
+ Additional training metadata is available in [`training_config.json`](./training_config.json).
167
+
168
+ ## Evaluation Results
169
+
170
+ The model was evaluated on the held-out test split.
171
+
172
+ | Metric | Test Score |
173
+ |---|---:|
174
+ | Accuracy | 0.6038 |
175
+ | Macro Precision | 0.6201 |
176
+ | Macro Recall / Sensitivity | 0.6058 |
177
+ | Macro Specificity | 0.7995 |
178
+ | Macro F1 | 0.6107 |
179
+ | Macro AUC OvR | 0.8076 |
180
+ | Macro IoU / Jaccard | 0.4444 |
181
+ | Test Loss | 0.8381 |
182
+
183
+ ### Per-Class Results
184
+
185
+ 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.
186
+
187
+ These results should be interpreted in the context of the small dataset size and the academic nature of the experiment.
188
+
189
+ ## How to Use
190
+
191
+ ```python
192
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
193
+ import torch
194
+
195
+ repo_id = "cristian-untaru/frozen-encoder-biomedbert-medical-triage"
196
+
197
+ tokenizer = AutoTokenizer.from_pretrained(repo_id)
198
+ model = AutoModelForSequenceClassification.from_pretrained(repo_id)
199
+
200
+ text = "I have chest pain, shortness of breath, and I feel dizzy."
201
+
202
+ inputs = tokenizer(
203
+ text,
204
+ return_tensors="pt",
205
+ truncation=True,
206
+ padding=True,
207
+ max_length=128
208
+ )
209
+
210
+ with torch.no_grad():
211
+ outputs = model(**inputs)
212
+ probabilities = torch.softmax(outputs.logits, dim=-1)
213
+ predicted_class_id = torch.argmax(probabilities, dim=-1).item()
214
+
215
+ predicted_label = model.config.id2label[predicted_class_id]
216
+ confidence = probabilities[0][predicted_class_id].item()
217
+
218
+ print("Predicted label:", predicted_label)
219
+ print("Confidence:", round(confidence, 4))
220
+ ```
221
+
222
+
223
+ This model loads with the standard Transformers API and does not require `trust_remote_code=True`.
224
+
225
+
226
+ To verify the label mapping:
227
+
228
+ ```python
229
+ print(model.config.id2label)
230
+ ```
231
+
232
+ Expected output:
233
+
234
+ ```python
235
+ {0: "self_monitor", 1: "consult_gp", 2: "urgent"}
236
+ ```
237
+
238
+ ## Repository Files
239
+
240
+ | File | Description |
241
+ |---|---|
242
+ | `config.json` | Model architecture, label mapping, and classification configuration. |
243
+ | `model.safetensors` | Model weights in SafeTensors format. |
244
+ | `tokenizer.json` | Tokenizer vocabulary and processing pipeline. |
245
+ | `tokenizer_config.json` | Tokenizer configuration. |
246
+ | `training_config.json` | Human-readable training configuration. |
247
+ | `label_map.json` | Mapping between numeric class IDs and triage labels. |
248
+ | `README.md` | Model card documentation. |
249
+ | `.gitattributes` | Git LFS configuration for large model files. |
250
+
251
+ ## Limitations
252
+
253
+ This model has several important limitations:
254
+
255
+ - It was trained on a small academic dataset.
256
+ - The labels are rule-based and not clinically validated by medical experts.
257
+ - It does not perform medical diagnosis.
258
+ - It does not consider patient age, sex, medical history, medication history, vital signs, comorbidities, pregnancy status, allergies, or physical examination findings.
259
+ - It may produce incorrect predictions for rare, ambiguous, incomplete, severe, or contradictory symptom descriptions.
260
+ - It was trained for English text only.
261
+ - It should not be used for emergency triage without medical supervision.
262
+ - Its predictions depend on the quality and completeness of the user-provided text.
263
+
264
+ ## Ethical and Safety Considerations
265
+
266
+ 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.
267
+
268
+ Any real-world deployment would require:
269
+
270
+ - clinical expert review;
271
+ - validation on larger and more representative medical datasets;
272
+ - safety testing;
273
+ - bias and fairness evaluation;
274
+ - monitoring for incorrect or unsafe predictions;
275
+ - clear user-facing warnings;
276
+ - escalation rules for emergency symptoms.
277
+
278
+ ## Medical Disclaimer
279
+
280
+ 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.
281
+
282
+ If symptoms are severe, sudden, worsening, or potentially life-threatening, users should contact emergency services or a qualified healthcare professional immediately.
283
+
284
+ ## Related Datasets
285
+
286
+ - [`cristian-untaru/symcat-medical-triage-dataset`](https://huggingface.co/datasets/cristian-untaru/symcat-medical-triage-dataset)
287
+ - [`cristian-untaru/medquad-retrieval-pretriage`](https://huggingface.co/datasets/cristian-untaru/medquad-retrieval-pretriage)
288
+
289
+ ## Related Models
290
+
291
+ ### Full Fine-Tuned Models
292
+
293
+ - [`cristian-untaru/distilbert-medical-triage`](https://huggingface.co/cristian-untaru/distilbert-medical-triage)
294
+ - [`cristian-untaru/biobert-medical-triage`](https://huggingface.co/cristian-untaru/biobert-medical-triage)
295
+ - [`cristian-untaru/roberta-medical-triage`](https://huggingface.co/cristian-untaru/roberta-medical-triage)
296
+ - [`cristian-untaru/biomedbert-medical-triage`](https://huggingface.co/cristian-untaru/biomedbert-medical-triage)
297
+
298
+ ### LoRA Models
299
+
300
+ - [`cristian-untaru/lora-distilbert-medical-triage`](https://huggingface.co/cristian-untaru/lora-distilbert-medical-triage)
301
+ - [`cristian-untaru/lora-biobert-medical-triage`](https://huggingface.co/cristian-untaru/lora-biobert-medical-triage)
302
+ - [`cristian-untaru/lora-roberta-medical-triage`](https://huggingface.co/cristian-untaru/lora-roberta-medical-triage)
303
+ - [`cristian-untaru/lora-biomedbert-medical-triage`](https://huggingface.co/cristian-untaru/lora-biomedbert-medical-triage)
304
+
305
+ ### Bottleneck MLP Adapter Models
306
+
307
+ - [`cristian-untaru/bottleneck-mlp-distilbert-medical-triage`](https://huggingface.co/cristian-untaru/bottleneck-mlp-distilbert-medical-triage)
308
+ - [`cristian-untaru/bottleneck-mlp-biobert-medical-triage`](https://huggingface.co/cristian-untaru/bottleneck-mlp-biobert-medical-triage)
309
+ - [`cristian-untaru/bottleneck-mlp-roberta-medical-triage`](https://huggingface.co/cristian-untaru/bottleneck-mlp-roberta-medical-triage)
310
+ - [`cristian-untaru/bottleneck-mlp-biomedbert-medical-triage`](https://huggingface.co/cristian-untaru/bottleneck-mlp-biomedbert-medical-triage)
311
+
312
+ ### Frozen Encoder Models
313
+
314
+ - [`cristian-untaru/frozen-encoder-distilbert-medical-triage`](https://huggingface.co/cristian-untaru/frozen-encoder-distilbert-medical-triage)
315
+ - [`cristian-untaru/frozen-encoder-biobert-medical-triage`](https://huggingface.co/cristian-untaru/frozen-encoder-biobert-medical-triage)
316
+ - [`cristian-untaru/frozen-encoder-roberta-medical-triage`](https://huggingface.co/cristian-untaru/frozen-encoder-roberta-medical-triage)
317
+ - [`cristian-untaru/frozen-encoder-biomedbert-medical-triage`](https://huggingface.co/cristian-untaru/frozen-encoder-biomedbert-medical-triage)