Upload README.md
Browse files
README.md
ADDED
@@ -0,0 +1,452 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
base_model: m42-health/med42-70b
|
3 |
+
inference: false
|
4 |
+
language:
|
5 |
+
- en
|
6 |
+
license: other
|
7 |
+
license_name: med42
|
8 |
+
model_creator: M42 Health
|
9 |
+
model_name: Med42 70B
|
10 |
+
model_type: llama
|
11 |
+
pipeline_tag: text-generation
|
12 |
+
prompt_template: '<|system|>: You are a helpful medical assistant created by M42 Health
|
13 |
+
in the UAE.
|
14 |
+
|
15 |
+
<|prompter|>:{prompt}
|
16 |
+
|
17 |
+
<|assistant|>:
|
18 |
+
|
19 |
+
'
|
20 |
+
quantized_by: TheBloke
|
21 |
+
tags:
|
22 |
+
- m42
|
23 |
+
- health
|
24 |
+
- healthcare
|
25 |
+
- clinical-llm
|
26 |
+
---
|
27 |
+
<!-- markdownlint-disable MD041 -->
|
28 |
+
|
29 |
+
<!-- header start -->
|
30 |
+
<!-- 200823 -->
|
31 |
+
<div style="width: auto; margin-left: auto; margin-right: auto">
|
32 |
+
<img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
|
33 |
+
</div>
|
34 |
+
<div style="display: flex; justify-content: space-between; width: 100%;">
|
35 |
+
<div style="display: flex; flex-direction: column; align-items: flex-start;">
|
36 |
+
<p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
|
37 |
+
</div>
|
38 |
+
<div style="display: flex; flex-direction: column; align-items: flex-end;">
|
39 |
+
<p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://www.patreon.com/TheBlokeAI">Want to contribute? TheBloke's Patreon page</a></p>
|
40 |
+
</div>
|
41 |
+
</div>
|
42 |
+
<div style="text-align:center; margin-top: 0em; margin-bottom: 0em"><p style="margin-top: 0.25em; margin-bottom: 0em;">TheBloke's LLM work is generously supported by a grant from <a href="https://a16z.com">andreessen horowitz (a16z)</a></p></div>
|
43 |
+
<hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
|
44 |
+
<!-- header end -->
|
45 |
+
|
46 |
+
# Med42 70B - AWQ
|
47 |
+
- Model creator: [M42 Health](https://huggingface.co/m42-health)
|
48 |
+
- Original model: [Med42 70B](https://huggingface.co/m42-health/med42-70b)
|
49 |
+
|
50 |
+
<!-- description start -->
|
51 |
+
## Description
|
52 |
+
|
53 |
+
This repo contains AWQ model files for [M42 Health's Med42 70B](https://huggingface.co/m42-health/med42-70b).
|
54 |
+
|
55 |
+
These files were quantised using hardware kindly provided by [Massed Compute](https://massedcompute.com/).
|
56 |
+
|
57 |
+
|
58 |
+
### About AWQ
|
59 |
+
|
60 |
+
AWQ is an efficient, accurate and blazing-fast low-bit weight quantization method, currently supporting 4-bit quantization. Compared to GPTQ, it offers faster Transformers-based inference with equivalent or better quality compared to the most commonly used GPTQ settings.
|
61 |
+
|
62 |
+
It is supported by:
|
63 |
+
|
64 |
+
- [Text Generation Webui](https://github.com/oobabooga/text-generation-webui) - using Loader: AutoAWQ
|
65 |
+
- [vLLM](https://github.com/vllm-project/vllm) - Llama and Mistral models only
|
66 |
+
- [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference)
|
67 |
+
- [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) - for use from Python code
|
68 |
+
|
69 |
+
<!-- description end -->
|
70 |
+
<!-- repositories-available start -->
|
71 |
+
## Repositories available
|
72 |
+
|
73 |
+
* [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/med42-70B-AWQ)
|
74 |
+
* [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/med42-70B-GPTQ)
|
75 |
+
* [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/med42-70B-GGUF)
|
76 |
+
* [M42 Health's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/m42-health/med42-70b)
|
77 |
+
<!-- repositories-available end -->
|
78 |
+
|
79 |
+
<!-- prompt-template start -->
|
80 |
+
## Prompt template: Med42
|
81 |
+
|
82 |
+
```
|
83 |
+
<|system|>: You are a helpful medical assistant created by M42 Health in the UAE.
|
84 |
+
<|prompter|>:{prompt}
|
85 |
+
<|assistant|>:
|
86 |
+
|
87 |
+
```
|
88 |
+
|
89 |
+
<!-- prompt-template end -->
|
90 |
+
<!-- licensing start -->
|
91 |
+
## Licensing
|
92 |
+
|
93 |
+
The creator of the source model has listed its license as `other`, and this quantization has therefore used that same license.
|
94 |
+
|
95 |
+
As this model is based on Llama 2, it is also subject to the Meta Llama 2 license terms, and the license files for that are additionally included. It should therefore be considered as being claimed to be licensed under both licenses. I contacted Hugging Face for clarification on dual licensing but they do not yet have an official position. Should this change, or should Meta provide any feedback on this situation, I will update this section accordingly.
|
96 |
+
|
97 |
+
In the meantime, any questions regarding licensing, and in particular how these two licenses might interact, should be directed to the original model repository: [M42 Health's Med42 70B](https://huggingface.co/m42-health/med42-70b).
|
98 |
+
<!-- licensing end -->
|
99 |
+
<!-- README_AWQ.md-provided-files start -->
|
100 |
+
## Provided files, and AWQ parameters
|
101 |
+
|
102 |
+
For my first release of AWQ models, I am releasing 128g models only. I will consider adding 32g as well if there is interest, and once I have done perplexity and evaluation comparisons, but at this time 32g models are still not fully tested with AutoAWQ and vLLM.
|
103 |
+
|
104 |
+
Models are released as sharded safetensors files.
|
105 |
+
|
106 |
+
| Branch | Bits | GS | AWQ Dataset | Seq Len | Size |
|
107 |
+
| ------ | ---- | -- | ----------- | ------- | ---- |
|
108 |
+
| [main](https://huggingface.co/TheBloke/med42-70B-AWQ/tree/main) | 4 | 128 | [Medical Meadow WikiDoc](https://huggingface.co/datasets/medalpaca/medical_meadow_wikidoc) | 4096 | 36.61 GB
|
109 |
+
|
110 |
+
<!-- README_AWQ.md-provided-files end -->
|
111 |
+
|
112 |
+
<!-- README_AWQ.md-text-generation-webui start -->
|
113 |
+
## How to easily download and use this model in [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
|
114 |
+
|
115 |
+
Please make sure you're using the latest version of [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
|
116 |
+
|
117 |
+
It is strongly recommended to use the text-generation-webui one-click-installers unless you're sure you know how to make a manual install.
|
118 |
+
|
119 |
+
1. Click the **Model tab**.
|
120 |
+
2. Under **Download custom model or LoRA**, enter `TheBloke/med42-70B-AWQ`.
|
121 |
+
3. Click **Download**.
|
122 |
+
4. The model will start downloading. Once it's finished it will say "Done".
|
123 |
+
5. In the top left, click the refresh icon next to **Model**.
|
124 |
+
6. In the **Model** dropdown, choose the model you just downloaded: `med42-70B-AWQ`
|
125 |
+
7. Select **Loader: AutoAWQ**.
|
126 |
+
8. Click Load, and the model will load and is now ready for use.
|
127 |
+
9. If you want any custom settings, set them and then click **Save settings for this model** followed by **Reload the Model** in the top right.
|
128 |
+
10. Once you're ready, click the **Text Generation** tab and enter a prompt to get started!
|
129 |
+
<!-- README_AWQ.md-text-generation-webui end -->
|
130 |
+
|
131 |
+
<!-- README_AWQ.md-use-from-vllm start -->
|
132 |
+
## Multi-user inference server: vLLM
|
133 |
+
|
134 |
+
Documentation on installing and using vLLM [can be found here](https://vllm.readthedocs.io/en/latest/).
|
135 |
+
|
136 |
+
- Please ensure you are using vLLM version 0.2 or later.
|
137 |
+
- When using vLLM as a server, pass the `--quantization awq` parameter.
|
138 |
+
|
139 |
+
For example:
|
140 |
+
|
141 |
+
```shell
|
142 |
+
python3 python -m vllm.entrypoints.api_server --model TheBloke/med42-70B-AWQ --quantization awq
|
143 |
+
```
|
144 |
+
|
145 |
+
- When using vLLM from Python code, again set `quantization=awq`.
|
146 |
+
|
147 |
+
For example:
|
148 |
+
|
149 |
+
```python
|
150 |
+
from vllm import LLM, SamplingParams
|
151 |
+
|
152 |
+
prompts = [
|
153 |
+
"Tell me about AI",
|
154 |
+
"Write a story about llamas",
|
155 |
+
"What is 291 - 150?",
|
156 |
+
"How much wood would a woodchuck chuck if a woodchuck could chuck wood?",
|
157 |
+
]
|
158 |
+
prompt_template=f'''<|system|>: You are a helpful medical assistant created by M42 Health in the UAE.
|
159 |
+
<|prompter|>:{prompt}
|
160 |
+
<|assistant|>:
|
161 |
+
'''
|
162 |
+
|
163 |
+
prompts = [prompt_template.format(prompt=prompt) for prompt in prompts]
|
164 |
+
|
165 |
+
sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
|
166 |
+
|
167 |
+
llm = LLM(model="TheBloke/med42-70B-AWQ", quantization="awq", dtype="auto")
|
168 |
+
|
169 |
+
outputs = llm.generate(prompts, sampling_params)
|
170 |
+
|
171 |
+
# Print the outputs.
|
172 |
+
for output in outputs:
|
173 |
+
prompt = output.prompt
|
174 |
+
generated_text = output.outputs[0].text
|
175 |
+
print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
|
176 |
+
```
|
177 |
+
<!-- README_AWQ.md-use-from-vllm start -->
|
178 |
+
|
179 |
+
<!-- README_AWQ.md-use-from-tgi start -->
|
180 |
+
## Multi-user inference server: Hugging Face Text Generation Inference (TGI)
|
181 |
+
|
182 |
+
Use TGI version 1.1.0 or later. The official Docker container is: `ghcr.io/huggingface/text-generation-inference:1.1.0`
|
183 |
+
|
184 |
+
Example Docker parameters:
|
185 |
+
|
186 |
+
```shell
|
187 |
+
--model-id TheBloke/med42-70B-AWQ --port 3000 --quantize awq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
|
188 |
+
```
|
189 |
+
|
190 |
+
Example Python code for interfacing with TGI (requires [huggingface-hub](https://github.com/huggingface/huggingface_hub) 0.17.0 or later):
|
191 |
+
|
192 |
+
```shell
|
193 |
+
pip3 install huggingface-hub
|
194 |
+
```
|
195 |
+
|
196 |
+
```python
|
197 |
+
from huggingface_hub import InferenceClient
|
198 |
+
|
199 |
+
endpoint_url = "https://your-endpoint-url-here"
|
200 |
+
|
201 |
+
prompt = "Tell me about AI"
|
202 |
+
prompt_template=f'''<|system|>: You are a helpful medical assistant created by M42 Health in the UAE.
|
203 |
+
<|prompter|>:{prompt}
|
204 |
+
<|assistant|>:
|
205 |
+
'''
|
206 |
+
|
207 |
+
client = InferenceClient(endpoint_url)
|
208 |
+
response = client.text_generation(prompt,
|
209 |
+
max_new_tokens=128,
|
210 |
+
do_sample=True,
|
211 |
+
temperature=0.7,
|
212 |
+
top_p=0.95,
|
213 |
+
top_k=40,
|
214 |
+
repetition_penalty=1.1)
|
215 |
+
|
216 |
+
print(f"Model output: ", response)
|
217 |
+
```
|
218 |
+
<!-- README_AWQ.md-use-from-tgi end -->
|
219 |
+
|
220 |
+
<!-- README_AWQ.md-use-from-python start -->
|
221 |
+
## Inference from Python code using AutoAWQ
|
222 |
+
|
223 |
+
### Install the AutoAWQ package
|
224 |
+
|
225 |
+
Requires: [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) 0.1.1 or later.
|
226 |
+
|
227 |
+
```shell
|
228 |
+
pip3 install autoawq
|
229 |
+
```
|
230 |
+
|
231 |
+
If you have problems installing [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) using the pre-built wheels, install it from source instead:
|
232 |
+
|
233 |
+
```shell
|
234 |
+
pip3 uninstall -y autoawq
|
235 |
+
git clone https://github.com/casper-hansen/AutoAWQ
|
236 |
+
cd AutoAWQ
|
237 |
+
pip3 install .
|
238 |
+
```
|
239 |
+
|
240 |
+
### AutoAWQ example code
|
241 |
+
|
242 |
+
```python
|
243 |
+
from awq import AutoAWQForCausalLM
|
244 |
+
from transformers import AutoTokenizer
|
245 |
+
|
246 |
+
model_name_or_path = "TheBloke/med42-70B-AWQ"
|
247 |
+
|
248 |
+
# Load tokenizer
|
249 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=False)
|
250 |
+
# Load model
|
251 |
+
model = AutoAWQForCausalLM.from_quantized(model_name_or_path, fuse_layers=True,
|
252 |
+
trust_remote_code=False, safetensors=True)
|
253 |
+
|
254 |
+
prompt = "Tell me about AI"
|
255 |
+
prompt_template=f'''<|system|>: You are a helpful medical assistant created by M42 Health in the UAE.
|
256 |
+
<|prompter|>:{prompt}
|
257 |
+
<|assistant|>:
|
258 |
+
'''
|
259 |
+
|
260 |
+
print("*** Running model.generate:")
|
261 |
+
|
262 |
+
token_input = tokenizer(
|
263 |
+
prompt_template,
|
264 |
+
return_tensors='pt'
|
265 |
+
).input_ids.cuda()
|
266 |
+
|
267 |
+
# Generate output
|
268 |
+
generation_output = model.generate(
|
269 |
+
token_input,
|
270 |
+
do_sample=True,
|
271 |
+
temperature=0.7,
|
272 |
+
top_p=0.95,
|
273 |
+
top_k=40,
|
274 |
+
max_new_tokens=512
|
275 |
+
)
|
276 |
+
|
277 |
+
# Get the tokens from the output, decode them, print them
|
278 |
+
token_output = generation_output[0]
|
279 |
+
text_output = tokenizer.decode(token_output)
|
280 |
+
print("LLM output: ", text_output)
|
281 |
+
|
282 |
+
"""
|
283 |
+
# Inference should be possible with transformers pipeline as well in future
|
284 |
+
# But currently this is not yet supported by AutoAWQ (correct as of September 25th 2023)
|
285 |
+
from transformers import pipeline
|
286 |
+
|
287 |
+
print("*** Pipeline:")
|
288 |
+
pipe = pipeline(
|
289 |
+
"text-generation",
|
290 |
+
model=model,
|
291 |
+
tokenizer=tokenizer,
|
292 |
+
max_new_tokens=512,
|
293 |
+
do_sample=True,
|
294 |
+
temperature=0.7,
|
295 |
+
top_p=0.95,
|
296 |
+
top_k=40,
|
297 |
+
repetition_penalty=1.1
|
298 |
+
)
|
299 |
+
|
300 |
+
print(pipe(prompt_template)[0]['generated_text'])
|
301 |
+
"""
|
302 |
+
```
|
303 |
+
<!-- README_AWQ.md-use-from-python end -->
|
304 |
+
|
305 |
+
<!-- README_AWQ.md-compatibility start -->
|
306 |
+
## Compatibility
|
307 |
+
|
308 |
+
The files provided are tested to work with:
|
309 |
+
|
310 |
+
- [text-generation-webui](https://github.com/oobabooga/text-generation-webui) using `Loader: AutoAWQ`.
|
311 |
+
- [vLLM](https://github.com/vllm-project/vllm) version 0.2.0 and later.
|
312 |
+
- [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference) version 1.1.0 and later.
|
313 |
+
- [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) version 0.1.1 and later.
|
314 |
+
|
315 |
+
<!-- README_AWQ.md-compatibility end -->
|
316 |
+
|
317 |
+
<!-- footer start -->
|
318 |
+
<!-- 200823 -->
|
319 |
+
## Discord
|
320 |
+
|
321 |
+
For further support, and discussions on these models and AI in general, join us at:
|
322 |
+
|
323 |
+
[TheBloke AI's Discord server](https://discord.gg/theblokeai)
|
324 |
+
|
325 |
+
## Thanks, and how to contribute
|
326 |
+
|
327 |
+
Thanks to the [chirper.ai](https://chirper.ai) team!
|
328 |
+
|
329 |
+
Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
|
330 |
+
|
331 |
+
I've had a lot of people ask if they can contribute. I enjoy providing models and helping people, and would love to be able to spend even more time doing it, as well as expanding into new projects like fine tuning/training.
|
332 |
+
|
333 |
+
If you're able and willing to contribute it will be most gratefully received and will help me to keep providing more models, and to start work on new AI projects.
|
334 |
+
|
335 |
+
Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
|
336 |
+
|
337 |
+
* Patreon: https://patreon.com/TheBlokeAI
|
338 |
+
* Ko-Fi: https://ko-fi.com/TheBlokeAI
|
339 |
+
|
340 |
+
**Special thanks to**: Aemon Algiz.
|
341 |
+
|
342 |
+
**Patreon special mentions**: Pierre Kircher, Stanislav Ovsiannikov, Michael Levine, Eugene Pentland, Andrey, 준교 김, Randy H, Fred von Graf, Artur Olbinski, Caitlyn Gatomon, terasurfer, Jeff Scroggin, James Bentley, Vadim, Gabriel Puliatti, Harry Royden McLaughlin, Sean Connelly, Dan Guido, Edmond Seymore, Alicia Loh, subjectnull, AzureBlack, Manuel Alberto Morcote, Thomas Belote, Lone Striker, Chris Smitley, Vitor Caleffi, Johann-Peter Hartmann, Clay Pascal, biorpg, Brandon Frisco, sidney chen, transmissions 11, Pedro Madruga, jinyuan sun, Ajan Kanaga, Emad Mostaque, Trenton Dambrowitz, Jonathan Leane, Iucharbius, usrbinkat, vamX, George Stoitzev, Luke Pendergrass, theTransient, Olakabola, Swaroop Kallakuri, Cap'n Zoog, Brandon Phillips, Michael Dempsey, Nikolai Manek, danny, Matthew Berman, Gabriel Tamborski, alfie_i, Raymond Fosdick, Tom X Nguyen, Raven Klaugh, LangChain4j, Magnesian, Illia Dulskyi, David Ziegler, Mano Prime, Luis Javier Navarrete Lozano, Erik Bjäreholt, 阿明, Nathan Dryer, Alex, Rainer Wilmers, zynix, TL, Joseph William Delisle, John Villwock, Nathan LeClaire, Willem Michiel, Joguhyik, GodLy, OG, Alps Aficionado, Jeffrey Morgan, ReadyPlayerEmma, Tiffany J. Kim, Sebastain Graf, Spencer Kim, Michael Davis, webtim, Talal Aujan, knownsqashed, John Detwiler, Imad Khwaja, Deo Leter, Jerry Meng, Elijah Stavena, Rooh Singh, Pieter, SuperWojo, Alexandros Triantafyllidis, Stephen Murray, Ai Maven, ya boyyy, Enrico Ros, Ken Nordquist, Deep Realms, Nicholas, Spiking Neurons AB, Elle, Will Dee, Jack West, RoA, Luke @flexchar, Viktor Bowallius, Derek Yates, Subspace Studios, jjj, Toran Billups, Asp the Wyvern, Fen Risland, Ilya, NimbleBox.ai, Chadd, Nitin Borwankar, Emre, Mandus, Leonard Tan, Kalila, K, Trailburnt, S_X, Cory Kujawski
|
343 |
+
|
344 |
+
|
345 |
+
Thank you to all my generous patrons and donaters!
|
346 |
+
|
347 |
+
And thank you again to a16z for their generous grant.
|
348 |
+
|
349 |
+
<!-- footer end -->
|
350 |
+
|
351 |
+
# Original model card: M42 Health's Med42 70B
|
352 |
+
|
353 |
+
# **Med42 - Clinical Large Language Model**
|
354 |
+
Med42 is an open-access clinical large language model (LLM) developed by M42 to expand access to medical knowledge. Built off LLaMA-2 and comprising 70 billion parameters, this generative AI system provides high-quality answers to medical questions.
|
355 |
+
|
356 |
+
## Model Details
|
357 |
+
*Note: Use of this model is governed by the M42 Health license. In order to download the model weights (and tokenizer), please read the [Med42 License](https://huggingface.co/spaces/m42-health/License) and accept our License by requesting access here.*
|
358 |
+
|
359 |
+
Beginning with the base LLaMa-2 model, Med42 was instruction-tuned on a dataset of ~250M tokens compiled from different open-access sources, including medical flashcards, exam questions, and open-domain dialogues.
|
360 |
+
|
361 |
+
**Model Developers:** M42 Health AI Team
|
362 |
+
|
363 |
+
**Finetuned from model:** Llama-2 - 70B
|
364 |
+
|
365 |
+
**Context length:** 4k tokens
|
366 |
+
|
367 |
+
**Input:** Text only data
|
368 |
+
|
369 |
+
**Output:** Model generates text only
|
370 |
+
|
371 |
+
**Status:** This is a static model trained on an offline dataset. Future versions of the tuned models will be released as we enhance model's performance.
|
372 |
+
|
373 |
+
**License:** A custom license is available [here](https://huggingface.co/spaces/m42-health/License)
|
374 |
+
|
375 |
+
**Research Paper:** TBA
|
376 |
+
|
377 |
+
## Intended Use
|
378 |
+
Med42 is being made available for further testing and assessment as an AI assistant to enhance clinical decision-making and enhance access to an LLM for healthcare use. Potential use cases include:
|
379 |
+
- Medical question answering
|
380 |
+
- Patient record summarization
|
381 |
+
- Aiding medical diagnosis
|
382 |
+
- General health Q&A
|
383 |
+
|
384 |
+
To get the expected features and performance for the model, a specific formatting needs to be followed, including the `<|system|>`, `<|prompter|>` and `<|assistant|>` tags.
|
385 |
+
|
386 |
+
```python
|
387 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
388 |
+
|
389 |
+
model_name_or_path = "m42-health/med42-70b"
|
390 |
+
|
391 |
+
model = AutoModelForCausalLM.from_pretrained(model_name_or_path,
|
392 |
+
device_map="auto")
|
393 |
+
|
394 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
|
395 |
+
|
396 |
+
prompt = "What are the symptoms of diabetes ?"
|
397 |
+
prompt_template=f'''
|
398 |
+
<|system|>: You are a helpful medical assistant created by M42 Health in the UAE.
|
399 |
+
<|prompter|>:{prompt}
|
400 |
+
<|assistant|>:
|
401 |
+
'''
|
402 |
+
|
403 |
+
input_ids = tokenizer(prompt_template, return_tensors='pt').input_ids.cuda()
|
404 |
+
output = model.generate(inputs=input_ids, temperature=0.7, do_sample=True,eos_token_id=tokenizer.eos_token_id, pad_token_id=tokenizer.pad_token_id, max_new_tokens=512)
|
405 |
+
print(tokenizer.decode(output[0]))
|
406 |
+
```
|
407 |
+
|
408 |
+
## Hardware and Software
|
409 |
+
|
410 |
+
The training process was performed on the Condor Galaxy 1 (CG-1) supercomputer platform.
|
411 |
+
|
412 |
+
|
413 |
+
## Evaluation Results
|
414 |
+
|
415 |
+
Med42 achieves achieves competitive performance on various medical benchmarks, including MedQA, MedMCQA, PubMedQA, HeadQA, and Measuring Massive Multitask Language Understanding (MMLU) clinical topics. For all evaluations reported so far, we use [EleutherAI's evaluation harness library](https://github.com/EleutherAI/lm-evaluation-harness) and report zero-shot accuracies (except otherwise stated). We compare the performance with that reported for other models (ClinicalCamel-70B, GPT-3.5, GPT-4.0, Med-PaLM 2).
|
416 |
+
|
417 |
+
|Dataset|Med42|ClinicalCamel-70B|GPT-3.5|GPT-4.0|Med-PaLM-2 (5-shot)*|
|
418 |
+
|---|---|---|---|---|---|
|
419 |
+
|MMLU Clinical Knowledge|74.3|69.8|69.8|86.0|88.3|
|
420 |
+
|MMLU College Biology|84.0|79.2|72.2|95.1|94.4|
|
421 |
+
|MMLU College Medicine|68.8|67.0|61.3|76.9|80.9|
|
422 |
+
|MMLU Medical Genetics|86.0|69.0|70.0|91.0|90.0|
|
423 |
+
|MMLU Professional Medicine|79.8|71.3|70.2|93.0|95.2|
|
424 |
+
|MMLU Anatomy|67.4|62.2|56.3|80.0|77.8|
|
425 |
+
|MedMCQA|60.9|47.0|50.1|69.5|71.3|
|
426 |
+
|MedQA|61.5|53.4|50.8|78.9|79.7|
|
427 |
+
|USMLE Self-Assessment|71.7|-|49.1|83.8|-|
|
428 |
+
|USMLE Sample Exam|72.0|54.3|56.9|84.3|-|
|
429 |
+
|
430 |
+
**We note that 0-shot performance is not reported for Med-PaLM 2. Further details can be found at [https://github.com/m42health/med42](https://github.com/m42health/med42)*.
|
431 |
+
|
432 |
+
|
433 |
+
### Key performance metrics:
|
434 |
+
- Med42 achieves a 72% accuracy on the US Medical Licensing Examination (USMLE) sample exam, surpassing the prior state of the art among openly available medical LLMs.
|
435 |
+
- 61.5% on MedQA dataset (compared to 50.8% for GPT-3.5)
|
436 |
+
- Consistently higher performance on MMLU clinical topics compared to GPT-3.5.
|
437 |
+
|
438 |
+
## Limitations & Safe Use
|
439 |
+
- Med42 is not ready for real clinical use. Extensive human evaluation is undergoing as it is required to ensure safety.
|
440 |
+
- Potential for generating incorrect or harmful information.
|
441 |
+
- Risk of perpetuating biases in training data.
|
442 |
+
|
443 |
+
Use this model responsibly! Do not rely on it for medical usage without rigorous safety testing.
|
444 |
+
|
445 |
+
## Accessing Med42 and Reporting Issues
|
446 |
+
|
447 |
+
Please report any software "bug" or other problems through one of the following means:
|
448 |
+
|
449 |
+
- Reporting issues with the model: [https://github.com/m42health/med42](https://github.com/m42health/med42)
|
450 |
+
- Reporting risky content generated by the model, bugs and/or any security concerns: [https://forms.office.com/r/YMJu3kcKat](https://forms.office.com/r/YMJu3kcKat)
|
451 |
+
- M42’s privacy policy available at [https://m42.ae/privacy-policy/](https://m42.ae/privacy-policy/)
|
452 |
+
- Reporting violations of the Acceptable Use Policy or unlicensed uses of Med42: <med42@m42.ae>
|