G-AshwinKumar commited on
Commit
483beb9
1 Parent(s): c3b1de7

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +248 -1
README.md CHANGED
@@ -11,4 +11,251 @@ library_name: transformers
11
  tags:
12
  - biology
13
  - medical
14
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  tags:
12
  - biology
13
  - medical
14
+ ---
15
+ # Aloe: A New Family of Healthcare LLMs
16
+
17
+ Aloe is a new family of healthcare LLMs that is highly competitive with all previous open models of its range and reaches state-of-the-art results at its size by using model merging and advanced prompting strategies. Aloe scores high in metrics measuring ethics and factuality, thanks to a combined red teaming and alignment effort. Complete training details, model merging configurations, and all training data (including synthetically generated data) will be shared. Additionally, the prompting repository used in this work to produce state-of-the-art results during inference will also be shared. Aloe comes with a healthcare-specific risk assessment to contribute to the safe use and deployment of such systems.
18
+
19
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/62972c4979f193515da1d38e/VhWO_Q-lO3Pc72ed0fGVY.png" width="60%">
20
+
21
+
22
+ ## Model Details
23
+
24
+ ### [](https://huggingface.co/templates/model-card-example#model-description)Model Description
25
+
26
+ - **Developed by:** [HPAI](https://hpai.bsc.es/)
27
+ - **Model type:** Causal decoder-only transformer language model
28
+ - **Language(s) (NLP):** English (mainly)
29
+ - **License:** [Meta Llama 3 License](https://llama.meta.com/llama3/license/)
30
+ - **Finetuned from model :** [meta-llama/Meta-Llama-3-8B · Hugging Face](https://huggingface.co/meta-llama/Meta-Llama-3-8B)
31
+
32
+ ### [](https://huggingface.co/templates/model-card-example#model-sources-optional)Model Sources [optional]
33
+
34
+ - **Repository:** Coming Soon
35
+ - **Paper [optional]:** Coming soon
36
+
37
+ ## Uses
38
+
39
+ ### Direct Use
40
+
41
+ We encourage the use of Aloe for research purposes, as a
42
+ stepping stone to build better foundational models for healthcare.
43
+
44
+ ### Out-of-Scope Use
45
+
46
+ These models are not to be used for clinical practice, medical diagnosis, or any other form of direct or indirect healthcare advice. Models are prone to error and can produce toxic content. The use of Aloe models for activities harmful for individuals, such as spam, fraud, or impersonation, is prohibited.
47
+
48
+ ## Bias, Risks, and Limitations
49
+
50
+ First let us consider Healthcare professional impersonation, a fraudulent behaviour which currently generates billions of dollars in profit https://www.justice.gov/opa/pr/justice-department-charges-dozens-12-billion-health-care-fraud. A model such as Aloe could be used to increase the efficacy of such deceiving activities, making them more widespread. The main preventive actions are public literacy on the unreliability of digitised information and the importance of medical registration, and legislation enforcing AI-generated content disclaimers. The second risk we consider is medical decision-making without professional supervision. While this is already an issue in modern societies (\eg self-medication) a model such as Aloe, capable of producing high-quality conversational data, can facilitate self-delusion, particularly in the presence of sycophancy. By producing tailored responses, it can also be used to generate actionable answers. Public literacy on the dangers of self-diagnosis is one of the main defences, together with the introduction of disclaimers and warnings on the models' outputs. The last risk we consider is the access to information on dangerous substances or procedures. While the literature on sensitive content can already be found on different sources (\eg libraries, internet, dark web), LLMs can centralize such access, making it nearly impossible to control the flow of such information. Model alignment can help in that regard, but so far the effects remain insufficient, as jailbreaking methods still overcome it.
51
+
52
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/62972c4979f193515da1d38e/JR7AU-DwJRNAmk8vFPmfT.png" width="60%">
53
+
54
+ ### Recommendations
55
+
56
+ We avoid the use of all personal data in our training. Model safety cannot be guaranteed, as shown in the red teaming results. Aloe can produce toxic content under the appropriate prompts. For these reasons, minors should not be left alone to interact with Aloe without supervision.
57
+
58
+ ## How to Get Started with the Model
59
+
60
+ Use the code below to get started with the model. You can run conversational inference using the Transformers pipeline abstraction, or by leveraging the Auto classes with the `generate()` function. Let's see examples of both.
61
+
62
+ #### Transformers pipeline
63
+
64
+ ```python
65
+ import transformers
66
+ import torch
67
+
68
+ model_id = "HPAI-BSC/Llama3-Aloe-8B-Alpha"
69
+
70
+ pipeline = transformers.pipeline(
71
+ "text-generation",
72
+ model=model_id,
73
+ model_kwargs={"torch_dtype": torch.bfloat16},
74
+ device_map="auto",
75
+ )
76
+
77
+ messages = [
78
+ {"role": "system", "content": "You are an expert medical assistant named Aloe, developed by the High Performance Artificial Intelligence Group at Barcelona Supercomputing Center(BSC). You are to be a helpful, respectful, and honest assistant."},
79
+ {"role": "user", "content": "Hello."},
80
+ ]
81
+
82
+ prompt = pipeline.tokenizer.apply_chat_template(
83
+ messages,
84
+ tokenize=False,
85
+ add_generation_prompt=True
86
+ )
87
+
88
+ terminators = [
89
+ pipeline.tokenizer.eos_token_id,
90
+ pipeline.tokenizer.convert_tokens_to_ids("<|eot_id|>")
91
+ ]
92
+
93
+ outputs = pipeline(
94
+ prompt,
95
+ max_new_tokens=256,
96
+ eos_token_id=terminators,
97
+ do_sample=True,
98
+ temperature=0.6,
99
+ top_p=0.9,
100
+ )
101
+ print(outputs[0]["generated_text"][len(prompt):])
102
+ ```
103
+
104
+ #### Transformers AutoModelForCausalLM
105
+
106
+ ```python
107
+ from transformers import AutoTokenizer, AutoModelForCausalLM
108
+ import torch
109
+
110
+ model_id = "HPAI-BSC/Llama3-Aloe-8B-Alpha"
111
+
112
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
113
+ model = AutoModelForCausalLM.from_pretrained(
114
+ model_id,
115
+ torch_dtype=torch.bfloat16,
116
+ device_map="auto",
117
+ )
118
+
119
+ messages = [
120
+ {"role": "system", "content": "You are an expert medical assistant named Aloe, developed by the High Performance Artificial Intelligence Group at Barcelona Supercomputing Center(BSC). You are to be a helpful, respectful, and honest assistant."},
121
+ {"role": "user", "content": "Hello"},
122
+ ]
123
+
124
+ input_ids = tokenizer.apply_chat_template(
125
+ messages,
126
+ add_generation_prompt=True,
127
+ return_tensors="pt"
128
+ ).to(model.device)
129
+
130
+ terminators = [
131
+ tokenizer.eos_token_id,
132
+ tokenizer.convert_tokens_to_ids("<|eot_id|>")
133
+ ]
134
+
135
+ outputs = model.generate(
136
+ input_ids,
137
+ max_new_tokens=256,
138
+ eos_token_id=terminators,
139
+ do_sample=True,
140
+ temperature=0.6,
141
+ top_p=0.9,
142
+ )
143
+ response = outputs[0][input_ids.shape[-1]:]
144
+ print(tokenizer.decode(response, skip_special_tokens=True))
145
+ ```
146
+
147
+ ## Training Details
148
+
149
+ Supervised fine-tuning on top of Llama 3 8B using medical and general domain datasets, model merging using DARE-TIES process, two-stage DPO process for human preference alignment. More details coming soon.
150
+
151
+ ### Training Data
152
+
153
+ - Medical and general domain datasets, including synthetic data generated using Mixtral-8x7B and Genstruct
154
+ - argilla/dpo-mix-7k
155
+ - nvidia/HelpSteer
156
+ - Custom preference data with adversarial prompts generated from Anthropic Harmless, Chen et al., and original prompts
157
+
158
+ ### Training Procedure
159
+
160
+ #### Preprocessing [optional]
161
+
162
+ [More Information Needed]
163
+
164
+ #### Training Hyperparameters
165
+
166
+ - **Training regime:** [More Information Needed]
167
+
168
+ #### Speeds, Sizes, Times [optional]
169
+
170
+ [More Information Needed]
171
+
172
+ ## Evaluation
173
+
174
+ ### Testing Data, Factors & Metrics
175
+
176
+ #### Testing Data
177
+
178
+ - [MedQA (USMLE)](https://huggingface.co/datasets/bigbio/med_qa)
179
+ - [MedMCQA](https://huggingface.co/datasets/medmcqa)
180
+ - [PubMedQA](https://huggingface.co/datasets/bigbio/pubmed_qa)
181
+ - [MMLU-Medical](https://huggingface.co/datasets/lukaemon/mmlu)
182
+ - [MedQA-4-Option](https://huggingface.co/datasets/GBaker/MedQA-USMLE-4-options)
183
+
184
+ #### Factors
185
+
186
+ [More Information Needed]
187
+
188
+ #### Metrics
189
+
190
+ - Accuracy: suite the evaluation of multiple-choice question-answering tasks.
191
+
192
+ ### Results
193
+
194
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/62972c4979f193515da1d38e/5viYXiXgsTnlMLVRNa1NP.png" width="70%">
195
+
196
+
197
+ #### Summary
198
+
199
+ To compare Aloe with the most competitive open models (both general purpose and healthcare-specific) we use popular healthcare datasets (\eg PubMedQA, MedMCQA, MedQA and MMLU for six medical tasks only), together with the new and highly reliable CareQA. We produce the standard MultiMedQA score for reference, by computing the weighted average accuracy on all scores except CareQA. Additionally, we calculate the arithmetic mean across all datasets. The Medical MMLU is calculated by averaging the six medical subtasks: Anatomy, Clinical knowledge, College Biology, College medicine, Medical genetics, and Professional medicine.
200
+
201
+ Benchmark results indicate the training conducted on Aloe has boosted its performance slightly above Llama3-8B-Instruct. Llama3-Aloe-8B-Alpha outperforms larger models like Meditron 70B, and is close to larger base models, like Yi-34} For the former, this gain is consistent even when using SC-CoT, using their best-reported variant. All these results make Llama3-Aloe-8B-Alpha the best healthcare LLM of its size.
202
+
203
+ With the help of prompting techniques the performance of Llama3-Aloe-8B-Alpha is significantly improved. Medprompting in particular provides a 7\% increase in reported accuracy, after which \aloealpha only lags behind the ten times bigger Llama-3-70B-Instruct. This improvement is mostly consistent across medical fields. Llama3-Aloe-8B-Alpha with medprompting beats the performance of Meditron 70B with their self reported 20 shot SC-CoT in MMLU med and is slightly worse in the other benchmarks.
204
+
205
+ ## Model Examination [optional]
206
+
207
+ [More Information Needed]
208
+
209
+ ## Environmental Impact
210
+
211
+ 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).
212
+
213
+ - **Hardware Type:** 4xH100
214
+ - **Hours used:** 7,000
215
+ - **Hardware Provider:** Barcelona Supercomputing Center
216
+ - **Compute Region:** Spain
217
+ - **Carbon Emitted:** 439.25kg
218
+
219
+ ## Technical Specifications [optional]
220
+
221
+ ### Model Architecture and Objective
222
+
223
+ [More Information Needed]
224
+
225
+ ### Compute Infrastructure
226
+
227
+ [More Information Needed]
228
+
229
+ #### Hardware
230
+
231
+ [More Information Needed]
232
+
233
+ #### Software
234
+
235
+ [More Information Needed]
236
+
237
+ ## Citation [optional]
238
+
239
+ **BibTeX:**
240
+
241
+ [More Information Needed]
242
+
243
+ **APA:**
244
+
245
+ [More Information Needed]
246
+
247
+ ## Glossary [optional]
248
+
249
+ [More Information Needed]
250
+
251
+ ## More Information [optional]
252
+
253
+ [More Information Needed]
254
+
255
+ ## Model Card Authors [optional]
256
+
257
+ [More Information Needed]
258
+
259
+ ## Model Card Contact
260
+
261
+ mailto:hpai@bsc.es