Update README.md
Browse files
README.md
CHANGED
@@ -11,12 +11,122 @@ language:
|
|
11 |
- en
|
12 |
---
|
13 |
|
14 |
-
#
|
15 |
|
16 |
-
-
|
17 |
-
- **License:** apache-2.0
|
18 |
-
- **Finetuned from model :** unsloth/mistral-7b-instruct-v0.1-bnb-4bit
|
19 |
|
20 |
-
|
|
|
21 |
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
- en
|
12 |
---
|
13 |
|
14 |
+
# Model Card for Mistral-7B-Instruct-v0.1-Unsloth-MedicalQA
|
15 |
|
16 |
+
<img src="https://files.oaiusercontent.com/file-SRkkqbc6KKUWGAfvWfrZpA?se=2025-01-11T20%3A14%3A07Z&sp=r&sv=2024-08-04&sr=b&rscc=max-age%3D604800%2C%20immutable%2C%20private&rscd=attachment%3B%20filename%3D9f951e1f-ad60-431b-b016-e4d79f30a3ab.webp&sig=PwbELJUHXlMlgk3T4MoDPH7nVYfPEXN0ypjadk1DuEc%3D" alt="drawing" width="400"/>
|
|
|
|
|
17 |
|
18 |
+
<font color="FF0000" size="5"><b>
|
19 |
+
This is a medical question-answering model fine-tuned for healthcare domain</b></font>
|
20 |
|
21 |
+
<br><b>Foundation Model: https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.1<br/>
|
22 |
+
Dataset: https://huggingface.co/datasets/Laurent1/MedQuad-MedicalQnADataset_128tokens_max<br/></b>
|
23 |
+
|
24 |
+
The model has been fine-tuned using CUDA-enabled GPU hardware with optimized training through [Unsloth](https://github.com/unslothai/unsloth).
|
25 |
+
|
26 |
+
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="100"/>](https://github.com/unslothai/unsloth)
|
27 |
+
|
28 |
+
|
29 |
+
## Model Details
|
30 |
+
|
31 |
+
The model is based upon the foundation model: Mistral-7B-Instruct-v0.1.<br/>
|
32 |
+
It has been tuned with Supervised Fine-tuning Trainer using the Unsloth optimization framework for faster and more efficient training.
|
33 |
+
|
34 |
+
### Libraries
|
35 |
+
- unsloth
|
36 |
+
- transformers
|
37 |
+
- torch
|
38 |
+
- trl
|
39 |
+
- peft
|
40 |
+
- einops
|
41 |
+
- bitsandbytes
|
42 |
+
- datasets
|
43 |
+
|
44 |
+
## Training Configuration
|
45 |
+
|
46 |
+
### Model Parameters
|
47 |
+
- max_sequence_length = 2048
|
48 |
+
- load_in_4bit = True
|
49 |
+
- LoRA rank (r) = 32
|
50 |
+
- lora_alpha = 16
|
51 |
+
- lora_dropout = 0
|
52 |
+
|
53 |
+
### Target Modules for LoRA
|
54 |
+
- q_proj
|
55 |
+
- k_proj
|
56 |
+
- v_proj
|
57 |
+
- o_proj
|
58 |
+
- gate_proj
|
59 |
+
- up_proj
|
60 |
+
- down_proj
|
61 |
+
|
62 |
+
### Training Hyperparameters
|
63 |
+
- per_device_train_batch_size = 2
|
64 |
+
- gradient_accumulation_steps = 16
|
65 |
+
- warmup_steps = 5
|
66 |
+
- warmup_ratio = 0.03
|
67 |
+
- max_steps = 1600
|
68 |
+
- learning_rate = 1e-4
|
69 |
+
- weight_decay = 0.01
|
70 |
+
- lr_scheduler_type = "linear"
|
71 |
+
- optimizer = "paged_adamw_32bit"
|
72 |
+
|
73 |
+
## Training Statistics
|
74 |
+
|
75 |
+
### Hardware Utilization
|
76 |
+
- Training duration: 10,561.28 seconds (approximately 176.02 minutes)
|
77 |
+
- Peak reserved memory: 5.416 GB
|
78 |
+
- Peak reserved memory for training: 0.748 GB
|
79 |
+
- Peak reserved memory % of max memory: 13.689%
|
80 |
+
- Peak reserved memory for training % of max memory: 1.891%
|
81 |
+
|
82 |
+
### Dataset
|
83 |
+
The model was trained on the MedQuad dataset, which contains medical questions and answers. The training data was processed using a chat template format for instruction-tuning.
|
84 |
+
|
85 |
+
## Bias, Risks, and Limitations
|
86 |
+
|
87 |
+
<font color="FF0000">
|
88 |
+
Users (both direct and downstream) should be aware of the following:
|
89 |
+
|
90 |
+
1. This model is intended for medical question-answering but should not be used as a substitute for professional medical advice.
|
91 |
+
2. The model's responses should be verified by healthcare professionals before making any medical decisions.
|
92 |
+
3. Generation of plausible yet incorrect medical information remains a possibility.
|
93 |
+
4. The model's knowledge is limited to its training data and may not cover all medical conditions or recent medical developments.
|
94 |
+
</font>
|
95 |
+
|
96 |
+
## Usage
|
97 |
+
|
98 |
+
The model can be loaded and used with the Unsloth library:
|
99 |
+
|
100 |
+
```python
|
101 |
+
from unsloth import FastLanguageModel
|
102 |
+
max_seq_length = 2048 # Choose any! We auto support RoPE Scaling internally!
|
103 |
+
dtype = (
|
104 |
+
None # None for auto detection. Float16 for Tesla T4, V100, Bfloat16 for Ampere+
|
105 |
+
)
|
106 |
+
model, tokenizer = FastLanguageModel.from_pretrained(
|
107 |
+
"bouthros/Mistral-7B-Instruct-v0.1-Unsloth-MedicalQA",
|
108 |
+
max_seq_length=2048,
|
109 |
+
load_in_4bit=True,
|
110 |
+
)
|
111 |
+
```
|
112 |
+
|
113 |
+
Example usage:
|
114 |
+
```python
|
115 |
+
messages = [
|
116 |
+
{"from": "human", "value": "What are the types of liver cancer?"},
|
117 |
+
]
|
118 |
+
inputs = tokenizer.apply_chat_template(
|
119 |
+
messages,
|
120 |
+
tokenize=True,
|
121 |
+
add_generation_prompt=True,
|
122 |
+
return_tensors="pt"
|
123 |
+
).to("cuda")
|
124 |
+
```
|
125 |
+
|
126 |
+
## Model Access
|
127 |
+
|
128 |
+
The model is available on Hugging Face Hub at: bouthros/Mistral-7B-Instruct-v0.1-Unsloth-MedicalQA
|
129 |
+
|
130 |
+
## Citation
|
131 |
+
|
132 |
+
If you use this model, please cite the original Mistral-7B-Instruct-v0.1 model and the MedQuad dataset.
|