matthewchung74
commited on
Commit
·
9098f0f
1
Parent(s):
a9ef974
Update README.md
Browse files
README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
---
|
2 |
library_name: peft
|
3 |
base_model: mistralai/Mistral-7B-v0.1
|
|
|
4 |
---
|
5 |
|
6 |
# Model Card for MedMistral-7B
|
@@ -15,85 +16,98 @@ base_model: mistralai/Mistral-7B-v0.1
|
|
15 |
|
16 |
### Model Description
|
17 |
|
18 |
-
|
|
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
- **
|
23 |
-
- **
|
24 |
-
- **Model type:** [More Information Needed]
|
25 |
-
- **Language(s) (NLP):** [More Information Needed]
|
26 |
-
- **License:** [More Information Needed]
|
27 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
28 |
|
29 |
### Model Sources [optional]
|
30 |
|
31 |
<!-- Provide the basic links for the model. -->
|
32 |
|
33 |
-
- **Repository:**
|
34 |
-
- **Paper [optional]:** [More Information Needed]
|
35 |
-
- **Demo [optional]:** [More Information Needed]
|
36 |
|
37 |
## Uses
|
38 |
|
39 |
-
|
40 |
|
41 |
### Direct Use
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
|
|
|
|
48 |
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
-
|
52 |
|
53 |
-
|
54 |
|
55 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
56 |
-
|
57 |
-
[More Information Needed]
|
58 |
|
59 |
## Bias, Risks, and Limitations
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
[More Information Needed]
|
64 |
-
|
65 |
-
### Recommendations
|
66 |
-
|
67 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
68 |
-
|
69 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
70 |
|
71 |
## How to Get Started with the Model
|
72 |
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
## Training Details
|
78 |
|
79 |
### Training Data
|
80 |
|
81 |
-
|
82 |
|
83 |
-
|
84 |
|
85 |
### Training Procedure
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
#### Preprocessing [optional]
|
90 |
-
|
91 |
-
[More Information Needed]
|
92 |
-
|
93 |
|
94 |
#### Training Hyperparameters
|
95 |
|
96 |
-
- **Training regime:**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
|
98 |
#### Speeds, Sizes, Times [optional]
|
99 |
|
@@ -103,119 +117,10 @@ Use the code below to get started with the model.
|
|
103 |
|
104 |
## Evaluation
|
105 |
|
106 |
-
|
107 |
-
|
108 |
-
### Testing Data, Factors & Metrics
|
109 |
-
|
110 |
-
#### Testing Data
|
111 |
-
|
112 |
-
<!-- This should link to a Data Card if possible. -->
|
113 |
-
|
114 |
-
[More Information Needed]
|
115 |
-
|
116 |
-
#### Factors
|
117 |
-
|
118 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
119 |
-
|
120 |
-
[More Information Needed]
|
121 |
-
|
122 |
-
#### Metrics
|
123 |
-
|
124 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
125 |
-
|
126 |
-
[More Information Needed]
|
127 |
-
|
128 |
-
### Results
|
129 |
-
|
130 |
-
[More Information Needed]
|
131 |
-
|
132 |
-
#### Summary
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
## Model Examination [optional]
|
137 |
-
|
138 |
-
<!-- Relevant interpretability work for the model goes here -->
|
139 |
-
|
140 |
-
[More Information Needed]
|
141 |
-
|
142 |
-
## Environmental Impact
|
143 |
-
|
144 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
145 |
-
|
146 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
147 |
-
|
148 |
-
- **Hardware Type:** [More Information Needed]
|
149 |
-
- **Hours used:** [More Information Needed]
|
150 |
-
- **Cloud Provider:** [More Information Needed]
|
151 |
-
- **Compute Region:** [More Information Needed]
|
152 |
-
- **Carbon Emitted:** [More Information Needed]
|
153 |
-
|
154 |
-
## Technical Specifications [optional]
|
155 |
-
|
156 |
-
### Model Architecture and Objective
|
157 |
-
|
158 |
-
[More Information Needed]
|
159 |
-
|
160 |
-
### Compute Infrastructure
|
161 |
-
|
162 |
-
[More Information Needed]
|
163 |
-
|
164 |
-
#### Hardware
|
165 |
-
|
166 |
-
[More Information Needed]
|
167 |
-
|
168 |
-
#### Software
|
169 |
-
|
170 |
-
[More Information Needed]
|
171 |
-
|
172 |
-
## Citation [optional]
|
173 |
-
|
174 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
175 |
-
|
176 |
-
**BibTeX:**
|
177 |
-
|
178 |
-
[More Information Needed]
|
179 |
-
|
180 |
-
**APA:**
|
181 |
-
|
182 |
-
[More Information Needed]
|
183 |
-
|
184 |
-
## Glossary [optional]
|
185 |
-
|
186 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
187 |
-
|
188 |
-
[More Information Needed]
|
189 |
-
|
190 |
-
## More Information [optional]
|
191 |
-
|
192 |
-
[More Information Needed]
|
193 |
-
|
194 |
-
## Model Card Authors [optional]
|
195 |
-
|
196 |
-
[More Information Needed]
|
197 |
-
|
198 |
-
## Model Card Contact
|
199 |
-
|
200 |
-
[More Information Needed]
|
201 |
-
|
202 |
-
|
203 |
-
## Training procedure
|
204 |
-
|
205 |
-
|
206 |
-
The following `bitsandbytes` quantization config was used during training:
|
207 |
-
- quant_method: bitsandbytes
|
208 |
-
- load_in_8bit: False
|
209 |
-
- load_in_4bit: True
|
210 |
-
- llm_int8_threshold: 6.0
|
211 |
-
- llm_int8_skip_modules: None
|
212 |
-
- llm_int8_enable_fp32_cpu_offload: False
|
213 |
-
- llm_int8_has_fp16_weight: False
|
214 |
-
- bnb_4bit_quant_type: nf4
|
215 |
-
- bnb_4bit_use_double_quant: True
|
216 |
-
- bnb_4bit_compute_dtype: bfloat16
|
217 |
|
218 |
-
|
219 |
|
|
|
220 |
|
221 |
-
|
|
|
1 |
---
|
2 |
library_name: peft
|
3 |
base_model: mistralai/Mistral-7B-v0.1
|
4 |
+
license: apache-2.0
|
5 |
---
|
6 |
|
7 |
# Model Card for MedMistral-7B
|
|
|
16 |
|
17 |
### Model Description
|
18 |
|
19 |
+
MedMistral-7B is a Mistral fine tune 180993 samples from the [medmcqa](https://huggingface.co/datasets/medmcqa)
|
20 |
+
dataset.
|
21 |
|
22 |
+
- **Developed by:** [segmed.ai](https://segmed.ai)
|
23 |
+
- **Model type:** QLoRA Fine tune Mistral 7B
|
24 |
+
- **License:** Apache 2.0
|
25 |
+
- **Finetuned from model :** [Mistral-7B-v0.1](https://huggingface.co/mistralai/Mistral-7B-v0.1)
|
|
|
|
|
|
|
|
|
26 |
|
27 |
### Model Sources [optional]
|
28 |
|
29 |
<!-- Provide the basic links for the model. -->
|
30 |
|
31 |
+
- **Repository:** https://github.com/segmed/med_mistral
|
|
|
|
|
32 |
|
33 |
## Uses
|
34 |
|
35 |
+
This model is to demonstrate medical domain knowledge, but is not intended for medical advise.
|
36 |
|
37 |
### Direct Use
|
38 |
|
39 |
+
Prompts used in training followed this format:
|
40 |
+
```
|
41 |
+
You are a helpful medical assistant. Your task is to answer the following question one of the options and explain why.
|
42 |
+
### Question: Turban epiglottitis is a clinical finding in - [0] Tubercular laryngitis [1] Tubercular pharyngitis [2] Polypoid degeneration of vocal cord [3] Subglottic hemangioma
|
43 |
+
|
44 |
+
### Answer: 0
|
45 |
+
### Explanation: Ans. is 4a' i.e.. Tubercular laryngitis Laryngeal examination in TB lary ngitiso Hyperaemia of the vocal cord in its whole extent or confined to posterior part with impairment of adduction is the first sign.o Swelling in the interarytenoid region giving a mammilated appearance,o Ulceration of vocal cord giving mouse-nibbled appearance.o Superficial ragged ulceration on the arytenoids and interarytenoid region,o Granulation tissue in interarvtenoid region or vocal process of arytenoid,o Pseudoedema of the epiglottis 'Turban epiglottis",o Swelling of ventricular bands and aryepiglottic folds,o Marked pallor of surrounding mucosa.
|
46 |
+
```
|
47 |
|
48 |
+
And for inference, you would need to remove the answer.
|
49 |
+
```
|
50 |
+
You are a helpful medical assistant. Your task is to answer the following question one of the options and explain why.
|
51 |
+
### Question: Turban epiglottitis is a clinical finding in - [0] Tubercular laryngitis [1] Tubercular pharyngitis [2] Polypoid degeneration of vocal cord [3] Subglottic hemangioma
|
52 |
+
|
53 |
+
### Answer:
|
54 |
+
```
|
55 |
|
56 |
+
### Downstream Use
|
57 |
|
58 |
+
This model could be further fine tuned on your specific medical dataset.
|
59 |
|
|
|
|
|
|
|
60 |
|
61 |
## Bias, Risks, and Limitations
|
62 |
|
63 |
+
This model is not intended for medical use.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
## How to Get Started with the Model
|
66 |
|
67 |
+
Download the model and call generate_tokens using the prompt format defined above.
|
68 |
+
```
|
69 |
+
def generate_tokens(m, prompt, max_new_tokens=32):
|
70 |
+
model_input = tokenizer(prompt, return_tensors="pt").to("cuda")
|
71 |
+
m.eval()
|
72 |
+
with torch.no_grad():
|
73 |
+
return tokenizer.decode(m.generate(**model_input, max_new_tokens=max_new_tokens, do_sample=True, top_k=0, num_return_sequences=1, temperature=0.1, eos_token_id=tokenizer.eos_token_id)[0].cuda())
|
74 |
+
```
|
75 |
+
These are the hyper-parameters which yielded the best results when experimenting.
|
76 |
|
77 |
## Training Details
|
78 |
|
79 |
### Training Data
|
80 |
|
81 |
+
180k samples from the [medmcqa](https://huggingface.co/datasets/medmcqa) were used for training. 914 samples were reserved for test and eval.
|
82 |
|
83 |
+
A small number of samples over 512 tokens were removed to simplify training and to keep the max tokens size small.
|
84 |
|
85 |
### Training Procedure
|
86 |
|
87 |
+
Training
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
#### Training Hyperparameters
|
90 |
|
91 |
+
- **Training regime:** This used the standard qLoRA peft parameters as defined by
|
92 |
+
```
|
93 |
+
peft_config = LoraConfig(
|
94 |
+
r=16,
|
95 |
+
lora_alpha=16,
|
96 |
+
lora_dropout=0.05,
|
97 |
+
bias="none",
|
98 |
+
task_type="CAUSAL_LM",
|
99 |
+
target_modules=[
|
100 |
+
"q_proj",
|
101 |
+
"k_proj",
|
102 |
+
"v_proj",
|
103 |
+
"o_proj",
|
104 |
+
"gate_proj",
|
105 |
+
"up_proj",
|
106 |
+
"down_proj",
|
107 |
+
"lm_head",
|
108 |
+
]
|
109 |
+
)
|
110 |
+
```
|
111 |
|
112 |
#### Speeds, Sizes, Times [optional]
|
113 |
|
|
|
117 |
|
118 |
## Evaluation
|
119 |
|
120 |
+
Evaluation was performed on the holdout of 914 samples from the medmcqa dataset. Given the multiple choice nature of the data, the F1 was computed and explanations thrown away.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
|
122 |
+
F1 medmcqa : 66%
|
123 |
|
124 |
+
Evaluation was also performed on the [pubmed_qa](https://huggingface.co/datasets/pubmed_qa) labeled dataset. Since Yes/No answers were provided, an F1 was calculated. I waant to point out this evaluation is on a completely different dataset with different prompt format.
|
125 |
|
126 |
+
F1 pubmed_qa:
|