Upload fine-tuned pregnancy assistant model
Browse files- README.md +65 -0
- adapter_config.json +28 -0
- adapter_model.safetensors +3 -0
- chat_template.jinja +15 -0
- optimizer.pt +3 -0
- rng_state.pth +3 -0
- scheduler.pt +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +15 -0
- trainer_state.json +69 -0
- training_args.bin +3 -0
README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: peft
|
| 3 |
+
base_model: TinyLlama/TinyLlama-1.1B-Chat-v1.0
|
| 4 |
+
tags:
|
| 5 |
+
- generated_from_trainer
|
| 6 |
+
- pregnancy
|
| 7 |
+
- healthcare
|
| 8 |
+
- maternal-health
|
| 9 |
+
- domain-specific
|
| 10 |
+
model-index:
|
| 11 |
+
- name: pregnancy-assistant-tinyllama
|
| 12 |
+
results: []
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# Pregnancy Healthcare Assistant
|
| 16 |
+
|
| 17 |
+
This model is a fine-tuned version of [TinyLlama/TinyLlama-1.1B-Chat-v1.0](https://huggingface.co/TinyLlama/TinyLlama-1.1B-Chat-v1.0) using LoRA (Low-Rank Adaptation) for pregnancy and maternal healthcare questions.
|
| 18 |
+
|
| 19 |
+
## Model Description
|
| 20 |
+
|
| 21 |
+
- **Base Model:** TinyLlama-1.1B-Chat-v1.0
|
| 22 |
+
- **Fine-tuning Method:** LoRA (Parameter-Efficient Fine-Tuning)
|
| 23 |
+
- **Training Data:** 2,806 pregnancy and maternal health Q&A pairs
|
| 24 |
+
- **Domain:** Pregnancy, maternal health, prenatal care, labor, delivery, breastfeeding, postpartum
|
| 25 |
+
|
| 26 |
+
## Intended Use
|
| 27 |
+
|
| 28 |
+
This model is designed to provide informational responses to pregnancy and maternal health questions.
|
| 29 |
+
**Important:** This model should NOT replace professional medical advice. Always consult qualified healthcare providers for medical concerns.
|
| 30 |
+
|
| 31 |
+
## Usage
|
| 32 |
+
|
| 33 |
+
```python
|
| 34 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 35 |
+
from peft import PeftModel
|
| 36 |
+
import torch
|
| 37 |
+
|
| 38 |
+
# Load base model
|
| 39 |
+
base_model = AutoModelForCausalLM.from_pretrained("TinyLlama/TinyLlama-1.1B-Chat-v1.0")
|
| 40 |
+
tokenizer = AutoTokenizer.from_pretrained("TinyLlama/TinyLlama-1.1B-Chat-v1.0")
|
| 41 |
+
|
| 42 |
+
# Load fine-tuned adapter
|
| 43 |
+
model = PeftModel.from_pretrained(base_model, "Irutingabo/pregnancy-assistant-tinyllama")
|
| 44 |
+
|
| 45 |
+
# Generate response
|
| 46 |
+
prompt = "What are the signs of early labor?"
|
| 47 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
| 48 |
+
with torch.no_grad():
|
| 49 |
+
outputs = model.generate(**inputs, max_new_tokens=200, temperature=0.7)
|
| 50 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
## Limitations
|
| 54 |
+
|
| 55 |
+
- Specialized for pregnancy/maternal health domain only
|
| 56 |
+
- General knowledge outside this domain is limited
|
| 57 |
+
- Should not be used for medical diagnosis or treatment decisions
|
| 58 |
+
- Always recommend consulting healthcare professionals
|
| 59 |
+
|
| 60 |
+
## Training Details
|
| 61 |
+
|
| 62 |
+
- Training method: LoRA fine-tuning
|
| 63 |
+
- Trainable parameters: 4.5M (0.41% of total model parameters)
|
| 64 |
+
- Training dataset: Custom pregnancy Q&A dataset
|
| 65 |
+
- Training framework: Transformers + PEFT
|
adapter_config.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alpha_pattern": {},
|
| 3 |
+
"auto_mapping": null,
|
| 4 |
+
"base_model_name_or_path": "TinyLlama/TinyLlama-1.1B-Chat-v1.0",
|
| 5 |
+
"bias": "none",
|
| 6 |
+
"fan_in_fan_out": false,
|
| 7 |
+
"inference_mode": true,
|
| 8 |
+
"init_lora_weights": true,
|
| 9 |
+
"layers_pattern": null,
|
| 10 |
+
"layers_to_transform": null,
|
| 11 |
+
"loftq_config": {},
|
| 12 |
+
"lora_alpha": 32,
|
| 13 |
+
"lora_dropout": 0.05,
|
| 14 |
+
"megatron_config": null,
|
| 15 |
+
"megatron_core": "megatron.core",
|
| 16 |
+
"modules_to_save": null,
|
| 17 |
+
"peft_type": "LORA",
|
| 18 |
+
"r": 16,
|
| 19 |
+
"rank_pattern": {},
|
| 20 |
+
"revision": null,
|
| 21 |
+
"target_modules": [
|
| 22 |
+
"q_proj",
|
| 23 |
+
"o_proj",
|
| 24 |
+
"v_proj",
|
| 25 |
+
"k_proj"
|
| 26 |
+
],
|
| 27 |
+
"task_type": "CAUSAL_LM"
|
| 28 |
+
}
|
adapter_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f118e33f59ea201e7d0ff1c8f06eada6d7f837e39d6c6f093888bf5912c38f59
|
| 3 |
+
size 18045856
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% for message in messages %}
|
| 2 |
+
{% if message['role'] == 'user' %}
|
| 3 |
+
{{ '<|user|>
|
| 4 |
+
' + message['content'] + eos_token }}
|
| 5 |
+
{% elif message['role'] == 'system' %}
|
| 6 |
+
{{ '<|system|>
|
| 7 |
+
' + message['content'] + eos_token }}
|
| 8 |
+
{% elif message['role'] == 'assistant' %}
|
| 9 |
+
{{ '<|assistant|>
|
| 10 |
+
' + message['content'] + eos_token }}
|
| 11 |
+
{% endif %}
|
| 12 |
+
{% if loop.last and add_generation_prompt %}
|
| 13 |
+
{{ '<|assistant|>' }}
|
| 14 |
+
{% endif %}
|
| 15 |
+
{% endfor %}
|
optimizer.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ed0718d27c3b2ffa7aa1a15aa0bfcaefb99b4f4e460393b2d4a873db209838b2
|
| 3 |
+
size 36188171
|
rng_state.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:542a68b831ecc7aa982bd00d19fca1663a5fdeab5dffa870a8e2b78b9fd394b8
|
| 3 |
+
size 14455
|
scheduler.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f39d74e535d6e97d5d7879be451cda0ea223fa1ec3843dabb0dab4232a47e07f
|
| 3 |
+
size 1465
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"bos_token": "<s>",
|
| 4 |
+
"clean_up_tokenization_spaces": false,
|
| 5 |
+
"eos_token": "</s>",
|
| 6 |
+
"is_local": false,
|
| 7 |
+
"legacy": false,
|
| 8 |
+
"model_max_length": 2048,
|
| 9 |
+
"pad_token": "</s>",
|
| 10 |
+
"padding_side": "right",
|
| 11 |
+
"sp_model_kwargs": {},
|
| 12 |
+
"tokenizer_class": "TokenizersBackend",
|
| 13 |
+
"unk_token": "<unk>",
|
| 14 |
+
"use_default_system_prompt": false
|
| 15 |
+
}
|
trainer_state.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"best_global_step": null,
|
| 3 |
+
"best_metric": null,
|
| 4 |
+
"best_model_checkpoint": null,
|
| 5 |
+
"epoch": 0.039603960396039604,
|
| 6 |
+
"eval_steps": 500,
|
| 7 |
+
"global_step": 50,
|
| 8 |
+
"is_hyper_param_search": false,
|
| 9 |
+
"is_local_process_zero": true,
|
| 10 |
+
"is_world_process_zero": true,
|
| 11 |
+
"log_history": [
|
| 12 |
+
{
|
| 13 |
+
"epoch": 0.007920792079207921,
|
| 14 |
+
"grad_norm": 1.0817395448684692,
|
| 15 |
+
"learning_rate": 0.00045000000000000004,
|
| 16 |
+
"loss": 1.3794532775878907,
|
| 17 |
+
"step": 10
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"epoch": 0.015841584158415842,
|
| 21 |
+
"grad_norm": 0.5635583400726318,
|
| 22 |
+
"learning_rate": 0.00045000000000000004,
|
| 23 |
+
"loss": 0.805211353302002,
|
| 24 |
+
"step": 20
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"epoch": 0.023762376237623763,
|
| 28 |
+
"grad_norm": 0.5437660813331604,
|
| 29 |
+
"learning_rate": 0.00039444444444444444,
|
| 30 |
+
"loss": 0.8068445205688477,
|
| 31 |
+
"step": 30
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"epoch": 0.031683168316831684,
|
| 35 |
+
"grad_norm": 0.39760076999664307,
|
| 36 |
+
"learning_rate": 0.0003388888888888889,
|
| 37 |
+
"loss": 0.7344035625457763,
|
| 38 |
+
"step": 40
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"epoch": 0.039603960396039604,
|
| 42 |
+
"grad_norm": 0.4437391757965088,
|
| 43 |
+
"learning_rate": 0.00028333333333333335,
|
| 44 |
+
"loss": 0.7755752563476562,
|
| 45 |
+
"step": 50
|
| 46 |
+
}
|
| 47 |
+
],
|
| 48 |
+
"logging_steps": 10,
|
| 49 |
+
"max_steps": 100,
|
| 50 |
+
"num_input_tokens_seen": 0,
|
| 51 |
+
"num_train_epochs": 1,
|
| 52 |
+
"save_steps": 50,
|
| 53 |
+
"stateful_callbacks": {
|
| 54 |
+
"TrainerControl": {
|
| 55 |
+
"args": {
|
| 56 |
+
"should_epoch_stop": false,
|
| 57 |
+
"should_evaluate": false,
|
| 58 |
+
"should_log": false,
|
| 59 |
+
"should_save": true,
|
| 60 |
+
"should_training_stop": false
|
| 61 |
+
},
|
| 62 |
+
"attributes": {}
|
| 63 |
+
}
|
| 64 |
+
},
|
| 65 |
+
"total_flos": 128422622822400.0,
|
| 66 |
+
"train_batch_size": 1,
|
| 67 |
+
"trial_name": null,
|
| 68 |
+
"trial_params": null
|
| 69 |
+
}
|
training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3a930054d093cc5d69a207b163feab267fc6f6c74a882d9be2ed6272091063ae
|
| 3 |
+
size 5201
|