Upload PEFT LoRA adapter files
Browse files- .DS_Store +0 -0
- .gitattributes +1 -0
- README.md +93 -0
- adapter_config.json +50 -0
- adapter_model.safetensors +3 -0
- chat_template.jinja +47 -0
- processor_config.json +29 -0
- tokenizer.json +3 -0
- tokenizer_config.json +25 -0
.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
language:
|
| 2 |
+
- en
|
| 3 |
+
tags:
|
| 4 |
+
- peft
|
| 5 |
+
- lora
|
| 6 |
+
- medical
|
| 7 |
+
- triage
|
| 8 |
+
- emergency
|
| 9 |
+
- text-classification
|
| 10 |
+
base_model: google/medgemma-4b-it
|
| 11 |
+
library_name: peft
|
| 12 |
+
pipeline_tag: text-classification
|
| 13 |
+
license: mit
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# ESI-1 LoRA Adapter (MIETIC) for MedGemma 4B
|
| 17 |
+
|
| 18 |
+
## Model Summary
|
| 19 |
+
This repository contains a **LoRA adapter** (not a full standalone model) for **ESI-1 prediction** in emergency triage settings.
|
| 20 |
+
The adapter is trained on **MIETIC** using **few-shot, parameter-efficient fine-tuning (PEFT)** on top of **MedGemma 4B** (`google/medgemma-4b-it`).
|
| 21 |
+
|
| 22 |
+
## Model Details
|
| 23 |
+
- **Model type:** LoRA adapter
|
| 24 |
+
- **Base model:** `google/medgemma-4b-it`
|
| 25 |
+
- **Task:** ESI-1 prediction (emergency severity triage)
|
| 26 |
+
- **Training approach:** Specialized few-shot PEFT
|
| 27 |
+
- **Repository owner:** `AdilA1016`
|
| 28 |
+
|
| 29 |
+
## Files in this Repo
|
| 30 |
+
- `adapter_config.json`
|
| 31 |
+
- `adapter_model.safetensors`
|
| 32 |
+
- `chat_template.jinja`
|
| 33 |
+
- `processor_config.json`
|
| 34 |
+
- `tokenizer_config.json`
|
| 35 |
+
- `tokenizer.json`
|
| 36 |
+
|
| 37 |
+
## Intended Use
|
| 38 |
+
This model is intended for **research and decision-support prototyping** for emergency triage workflows.
|
| 39 |
+
It is **not** intended to replace clinician judgment.
|
| 40 |
+
|
| 41 |
+
## Out-of-Scope / Limitations
|
| 42 |
+
- Not validated as an autonomous clinical decision maker.
|
| 43 |
+
- Performance may vary by site, population, and documentation style.
|
| 44 |
+
- Should not be used as the sole basis for real-time medical decisions.
|
| 45 |
+
|
| 46 |
+
## Training Data
|
| 47 |
+
- **Dataset:** MIETIC
|
| 48 |
+
- **Domain:** Emergency/clinical triage text
|
| 49 |
+
- **Label focus:** ESI-1 identification
|
| 50 |
+
|
| 51 |
+
> Add a short description of MIETIC access/curation and any preprocessing steps you applied.
|
| 52 |
+
|
| 53 |
+
## Training Procedure
|
| 54 |
+
- **Method:** LoRA fine-tuning on MedGemma 4B
|
| 55 |
+
- **Regime:** Few-shot specialized adaptation
|
| 56 |
+
- **Frameworks:** PEFT + Transformers
|
| 57 |
+
- **Hardware:** [fill in]
|
| 58 |
+
- **Epochs / steps:** [fill in]
|
| 59 |
+
- **Learning rate:** [fill in]
|
| 60 |
+
- **Batch size:** [fill in]
|
| 61 |
+
- **LoRA config (`r`, `alpha`, target modules):** [fill in]
|
| 62 |
+
|
| 63 |
+
## Evaluation
|
| 64 |
+
- **Validation setup:** [fill in]
|
| 65 |
+
- **Primary metrics:** [fill in, e.g., recall/precision/F1 for ESI-1]
|
| 66 |
+
- **Key results:** [fill in]
|
| 67 |
+
- **Failure modes observed:** [fill in]
|
| 68 |
+
|
| 69 |
+
## Usage
|
| 70 |
+
|
| 71 |
+
```python
|
| 72 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 73 |
+
from peft import PeftModel
|
| 74 |
+
|
| 75 |
+
base_id = "google/medgemma-4b-it"
|
| 76 |
+
adapter_id = "AdilA1016/esi1trainedmodel"
|
| 77 |
+
|
| 78 |
+
tokenizer = AutoTokenizer.from_pretrained(adapter_id)
|
| 79 |
+
base_model = AutoModelForCausalLM.from_pretrained(base_id)
|
| 80 |
+
model = PeftModel.from_pretrained(base_model, adapter_id)
|
| 81 |
+
|
| 82 |
+
## Safety and Ethics
|
| 83 |
+
|
| 84 |
+
This model operates in a high-stakes medical context. Outputs may be incorrect, incomplete, or biased.
|
| 85 |
+
Human oversight by qualified clinicians is required for any practical use.
|
| 86 |
+
|
| 87 |
+
## Citation
|
| 88 |
+
|
| 89 |
+
If you use this adapter, please cite:
|
| 90 |
+
|
| 91 |
+
- MIETIC dataset/source: [fill in]
|
| 92 |
+
- MedGemma base model: [fill in official citation/link]
|
| 93 |
+
- This repository: AdilA1016/esi1trainedmodel
|
adapter_config.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alora_invocation_tokens": null,
|
| 3 |
+
"alpha_pattern": {},
|
| 4 |
+
"arrow_config": null,
|
| 5 |
+
"auto_mapping": {
|
| 6 |
+
"base_model_class": "Gemma3ForConditionalGeneration",
|
| 7 |
+
"parent_library": "transformers.models.gemma3.modeling_gemma3",
|
| 8 |
+
"unsloth_fixed": true
|
| 9 |
+
},
|
| 10 |
+
"base_model_name_or_path": "unsloth/medgemma-4b-it-unsloth-bnb-4bit",
|
| 11 |
+
"bias": "none",
|
| 12 |
+
"corda_config": null,
|
| 13 |
+
"ensure_weight_tying": false,
|
| 14 |
+
"eva_config": null,
|
| 15 |
+
"exclude_modules": null,
|
| 16 |
+
"fan_in_fan_out": false,
|
| 17 |
+
"inference_mode": true,
|
| 18 |
+
"init_lora_weights": true,
|
| 19 |
+
"layer_replication": null,
|
| 20 |
+
"layers_pattern": null,
|
| 21 |
+
"layers_to_transform": null,
|
| 22 |
+
"loftq_config": {},
|
| 23 |
+
"lora_alpha": 16,
|
| 24 |
+
"lora_bias": false,
|
| 25 |
+
"lora_dropout": 0.05,
|
| 26 |
+
"megatron_config": null,
|
| 27 |
+
"megatron_core": "megatron.core",
|
| 28 |
+
"modules_to_save": null,
|
| 29 |
+
"peft_type": "LORA",
|
| 30 |
+
"peft_version": "0.18.1",
|
| 31 |
+
"qalora_group_size": 16,
|
| 32 |
+
"r": 16,
|
| 33 |
+
"rank_pattern": {},
|
| 34 |
+
"revision": null,
|
| 35 |
+
"target_modules": [
|
| 36 |
+
"up_proj",
|
| 37 |
+
"q_proj",
|
| 38 |
+
"o_proj",
|
| 39 |
+
"k_proj",
|
| 40 |
+
"down_proj",
|
| 41 |
+
"v_proj",
|
| 42 |
+
"gate_proj"
|
| 43 |
+
],
|
| 44 |
+
"target_parameters": null,
|
| 45 |
+
"task_type": "CAUSAL_LM",
|
| 46 |
+
"trainable_token_indices": null,
|
| 47 |
+
"use_dora": false,
|
| 48 |
+
"use_qalora": false,
|
| 49 |
+
"use_rslora": false
|
| 50 |
+
}
|
adapter_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:acf2d81c44436f80f82570708da1ee8145011db89c34d172dd17d1cb2d8c902a
|
| 3 |
+
size 131252288
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{{ bos_token }}
|
| 2 |
+
{%- if messages[0]['role'] == 'system' -%}
|
| 3 |
+
{%- if messages[0]['content'] is string -%}
|
| 4 |
+
{%- set first_user_prefix = messages[0]['content'] + '
|
| 5 |
+
|
| 6 |
+
' -%}
|
| 7 |
+
{%- else -%}
|
| 8 |
+
{%- set first_user_prefix = messages[0]['content'][0]['text'] + '
|
| 9 |
+
|
| 10 |
+
' -%}
|
| 11 |
+
{%- endif -%}
|
| 12 |
+
{%- set loop_messages = messages[1:] -%}
|
| 13 |
+
{%- else -%}
|
| 14 |
+
{%- set first_user_prefix = "" -%}
|
| 15 |
+
{%- set loop_messages = messages -%}
|
| 16 |
+
{%- endif -%}
|
| 17 |
+
{%- for message in loop_messages -%}
|
| 18 |
+
{%- if (message['role'] == 'user') != (loop.index0 % 2 == 0) -%}
|
| 19 |
+
{{ raise_exception("Conversation roles must alternate user/assistant/user/assistant/...") }}
|
| 20 |
+
{%- endif -%}
|
| 21 |
+
{%- if (message['role'] == 'assistant') -%}
|
| 22 |
+
{%- set role = "model" -%}
|
| 23 |
+
{%- else -%}
|
| 24 |
+
{%- set role = message['role'] -%}
|
| 25 |
+
{%- endif -%}
|
| 26 |
+
{{ '<start_of_turn>' + role + '
|
| 27 |
+
' + (first_user_prefix if loop.first else "") }}
|
| 28 |
+
{%- if message['content'] is string -%}
|
| 29 |
+
{{ message['content'] | trim }}
|
| 30 |
+
{%- elif message['content'] is iterable -%}
|
| 31 |
+
{%- for item in message['content'] -%}
|
| 32 |
+
{%- if item['type'] == 'image' -%}
|
| 33 |
+
{{ '<start_of_image>' }}
|
| 34 |
+
{%- elif item['type'] == 'text' -%}
|
| 35 |
+
{{ item['text'] | trim }}
|
| 36 |
+
{%- endif -%}
|
| 37 |
+
{%- endfor -%}
|
| 38 |
+
{%- else -%}
|
| 39 |
+
{{ raise_exception("Invalid content type") }}
|
| 40 |
+
{%- endif -%}
|
| 41 |
+
{{ '<end_of_turn>
|
| 42 |
+
' }}
|
| 43 |
+
{%- endfor -%}
|
| 44 |
+
{%- if add_generation_prompt -%}
|
| 45 |
+
{{'<start_of_turn>model
|
| 46 |
+
'}}
|
| 47 |
+
{%- endif -%}
|
processor_config.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"image_processor": {
|
| 3 |
+
"data_format": "channels_first",
|
| 4 |
+
"do_convert_rgb": null,
|
| 5 |
+
"do_normalize": true,
|
| 6 |
+
"do_rescale": true,
|
| 7 |
+
"do_resize": true,
|
| 8 |
+
"image_mean": [
|
| 9 |
+
0.5,
|
| 10 |
+
0.5,
|
| 11 |
+
0.5
|
| 12 |
+
],
|
| 13 |
+
"image_processor_type": "Gemma3ImageProcessorFast",
|
| 14 |
+
"image_seq_length": 256,
|
| 15 |
+
"image_std": [
|
| 16 |
+
0.5,
|
| 17 |
+
0.5,
|
| 18 |
+
0.5
|
| 19 |
+
],
|
| 20 |
+
"resample": 2,
|
| 21 |
+
"rescale_factor": 0.00392156862745098,
|
| 22 |
+
"size": {
|
| 23 |
+
"height": 896,
|
| 24 |
+
"width": 896
|
| 25 |
+
}
|
| 26 |
+
},
|
| 27 |
+
"image_seq_length": 256,
|
| 28 |
+
"processor_class": "Gemma3Processor"
|
| 29 |
+
}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:daab2354f8a74e70d70b4d1f804939b68a8c9624dd06cb7858e52dd8970e9726
|
| 3 |
+
size 33384567
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"boi_token": "<start_of_image>",
|
| 4 |
+
"bos_token": "<bos>",
|
| 5 |
+
"clean_up_tokenization_spaces": false,
|
| 6 |
+
"eoi_token": "<end_of_image>",
|
| 7 |
+
"eos_token": "<end_of_turn>",
|
| 8 |
+
"image_token": "<image_soft_token>",
|
| 9 |
+
"is_local": false,
|
| 10 |
+
"mask_token": "<mask>",
|
| 11 |
+
"model_max_length": 131072,
|
| 12 |
+
"model_specific_special_tokens": {
|
| 13 |
+
"boi_token": "<start_of_image>",
|
| 14 |
+
"eoi_token": "<end_of_image>",
|
| 15 |
+
"image_token": "<image_soft_token>"
|
| 16 |
+
},
|
| 17 |
+
"pad_token": "<pad>",
|
| 18 |
+
"padding_side": "right",
|
| 19 |
+
"processor_class": "Gemma3Processor",
|
| 20 |
+
"sp_model_kwargs": null,
|
| 21 |
+
"spaces_between_special_tokens": false,
|
| 22 |
+
"tokenizer_class": "GemmaTokenizer",
|
| 23 |
+
"unk_token": "<unk>",
|
| 24 |
+
"use_default_system_prompt": false
|
| 25 |
+
}
|