TheBloke commited on
Commit
99507e2
1 Parent(s): de9304c

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +416 -0
README.md ADDED
@@ -0,0 +1,416 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: malhajar/meditron-7b-chat
3
+ datasets:
4
+ - yahma/alpaca-cleaned
5
+ inference: false
6
+ language:
7
+ - en
8
+ license: llama2
9
+ model_creator: Mohamad Alhajar
10
+ model_name: Meditron 7B Chat
11
+ model_type: llama
12
+ prompt_template: '### Instruction:
13
+
14
+ {prompt}
15
+
16
+
17
+ ### Response:
18
+
19
+ '
20
+ quantized_by: TheBloke
21
+ tags:
22
+ - Medicine
23
+ ---
24
+ <!-- markdownlint-disable MD041 -->
25
+
26
+ <!-- header start -->
27
+ <!-- 200823 -->
28
+ <div style="width: auto; margin-left: auto; margin-right: auto">
29
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
30
+ </div>
31
+ <div style="display: flex; justify-content: space-between; width: 100%;">
32
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
33
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
34
+ </div>
35
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
36
+ <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>
37
+ </div>
38
+ </div>
39
+ <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>
40
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
41
+ <!-- header end -->
42
+
43
+ # Meditron 7B Chat - AWQ
44
+ - Model creator: [Mohamad Alhajar](https://huggingface.co/malhajar)
45
+ - Original model: [Meditron 7B Chat](https://huggingface.co/malhajar/meditron-7b-chat)
46
+
47
+ <!-- description start -->
48
+ ## Description
49
+
50
+ This repo contains AWQ model files for [Mohamad Alhajar's Meditron 7B Chat](https://huggingface.co/malhajar/meditron-7b-chat).
51
+
52
+ These files were quantised using hardware kindly provided by [Massed Compute](https://massedcompute.com/).
53
+
54
+
55
+ ### About AWQ
56
+
57
+ 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.
58
+
59
+ AWQ models are currently supported on Linux and Windows, with NVidia GPUs only. macOS users: please use GGUF models instead.
60
+
61
+ It is supported by:
62
+
63
+ - [Text Generation Webui](https://github.com/oobabooga/text-generation-webui) - using Loader: AutoAWQ
64
+ - [vLLM](https://github.com/vllm-project/vllm) - version 0.2.2 or later for support for all model types.
65
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference)
66
+ - [Transformers](https://huggingface.co/docs/transformers) version 4.35.0 and later, from any code or client that supports Transformers
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/meditron-7B-chat-AWQ)
74
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/meditron-7B-chat-GPTQ)
75
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/meditron-7B-chat-GGUF)
76
+ * [Mohamad Alhajar's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/malhajar/meditron-7b-chat)
77
+ <!-- repositories-available end -->
78
+
79
+ <!-- prompt-template start -->
80
+ ## Prompt template: Alpaca-InstructOnly2
81
+
82
+ ```
83
+ ### Instruction:
84
+ {prompt}
85
+
86
+ ### Response:
87
+
88
+ ```
89
+
90
+ <!-- prompt-template end -->
91
+
92
+
93
+ <!-- README_AWQ.md-provided-files start -->
94
+ ## Provided files, and AWQ parameters
95
+
96
+ I currently release 128g GEMM models only. The addition of group_size 32 models, and GEMV kernel models, is being actively considered.
97
+
98
+ Models are released as sharded safetensors files.
99
+
100
+ | Branch | Bits | GS | AWQ Dataset | Seq Len | Size |
101
+ | ------ | ---- | -- | ----------- | ------- | ---- |
102
+ | [main](https://huggingface.co/TheBloke/meditron-7B-chat-AWQ/tree/main) | 4 | 128 | [Medical Medaow WikiDoc](https://huggingface.co/datasets/medalpaca/medical_meadow_wikidoc/viewer/) | 2048 | 3.89 GB
103
+
104
+ <!-- README_AWQ.md-provided-files end -->
105
+
106
+ <!-- README_AWQ.md-text-generation-webui start -->
107
+ ## How to easily download and use this model in [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
108
+
109
+ Please make sure you're using the latest version of [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
110
+
111
+ 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.
112
+
113
+ 1. Click the **Model tab**.
114
+ 2. Under **Download custom model or LoRA**, enter `TheBloke/meditron-7B-chat-AWQ`.
115
+ 3. Click **Download**.
116
+ 4. The model will start downloading. Once it's finished it will say "Done".
117
+ 5. In the top left, click the refresh icon next to **Model**.
118
+ 6. In the **Model** dropdown, choose the model you just downloaded: `meditron-7B-chat-AWQ`
119
+ 7. Select **Loader: AutoAWQ**.
120
+ 8. Click Load, and the model will load and is now ready for use.
121
+ 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.
122
+ 10. Once you're ready, click the **Text Generation** tab and enter a prompt to get started!
123
+ <!-- README_AWQ.md-text-generation-webui end -->
124
+
125
+ <!-- README_AWQ.md-use-from-vllm start -->
126
+ ## Multi-user inference server: vLLM
127
+
128
+ Documentation on installing and using vLLM [can be found here](https://vllm.readthedocs.io/en/latest/).
129
+
130
+ - Please ensure you are using vLLM version 0.2 or later.
131
+ - When using vLLM as a server, pass the `--quantization awq` parameter.
132
+
133
+ For example:
134
+
135
+ ```shell
136
+ python3 -m vllm.entrypoints.api_server --model TheBloke/meditron-7B-chat-AWQ --quantization awq --dtype auto
137
+ ```
138
+
139
+ - When using vLLM from Python code, again set `quantization=awq`.
140
+
141
+ For example:
142
+
143
+ ```python
144
+ from vllm import LLM, SamplingParams
145
+
146
+ prompts = [
147
+ "Tell me about AI",
148
+ "Write a story about llamas",
149
+ "What is 291 - 150?",
150
+ "How much wood would a woodchuck chuck if a woodchuck could chuck wood?",
151
+ ]
152
+ prompt_template=f'''### Instruction:
153
+ {prompt}
154
+
155
+ ### Response:
156
+ '''
157
+
158
+ prompts = [prompt_template.format(prompt=prompt) for prompt in prompts]
159
+
160
+ sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
161
+
162
+ llm = LLM(model="TheBloke/meditron-7B-chat-AWQ", quantization="awq", dtype="auto")
163
+
164
+ outputs = llm.generate(prompts, sampling_params)
165
+
166
+ # Print the outputs.
167
+ for output in outputs:
168
+ prompt = output.prompt
169
+ generated_text = output.outputs[0].text
170
+ print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
171
+ ```
172
+ <!-- README_AWQ.md-use-from-vllm start -->
173
+
174
+ <!-- README_AWQ.md-use-from-tgi start -->
175
+ ## Multi-user inference server: Hugging Face Text Generation Inference (TGI)
176
+
177
+ Use TGI version 1.1.0 or later. The official Docker container is: `ghcr.io/huggingface/text-generation-inference:1.1.0`
178
+
179
+ Example Docker parameters:
180
+
181
+ ```shell
182
+ --model-id TheBloke/meditron-7B-chat-AWQ --port 3000 --quantize awq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
183
+ ```
184
+
185
+ Example Python code for interfacing with TGI (requires [huggingface-hub](https://github.com/huggingface/huggingface_hub) 0.17.0 or later):
186
+
187
+ ```shell
188
+ pip3 install huggingface-hub
189
+ ```
190
+
191
+ ```python
192
+ from huggingface_hub import InferenceClient
193
+
194
+ endpoint_url = "https://your-endpoint-url-here"
195
+
196
+ prompt = "Tell me about AI"
197
+ prompt_template=f'''### Instruction:
198
+ {prompt}
199
+
200
+ ### Response:
201
+ '''
202
+
203
+ client = InferenceClient(endpoint_url)
204
+ response = client.text_generation(prompt,
205
+ max_new_tokens=128,
206
+ do_sample=True,
207
+ temperature=0.7,
208
+ top_p=0.95,
209
+ top_k=40,
210
+ repetition_penalty=1.1)
211
+
212
+ print(f"Model output: ", response)
213
+ ```
214
+ <!-- README_AWQ.md-use-from-tgi end -->
215
+
216
+ <!-- README_AWQ.md-use-from-python start -->
217
+ ## Inference from Python code using Transformers
218
+
219
+ ### Install the necessary packages
220
+
221
+ - Requires: [Transformers](https://huggingface.co/docs/transformers) 4.35.0 or later.
222
+ - Requires: [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) 0.1.6 or later.
223
+
224
+ ```shell
225
+ pip3 install --upgrade "autoawq>=0.1.6" "transformers>=4.35.0"
226
+ ```
227
+
228
+ Note that if you are using PyTorch 2.0.1, the above AutoAWQ command will automatically upgrade you to PyTorch 2.1.0.
229
+
230
+ If you are using CUDA 11.8 and wish to continue using PyTorch 2.0.1, instead run this command:
231
+
232
+ ```shell
233
+ pip3 install https://github.com/casper-hansen/AutoAWQ/releases/download/v0.1.6/autoawq-0.1.6+cu118-cp310-cp310-linux_x86_64.whl
234
+ ```
235
+
236
+ If you have problems installing [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) using the pre-built wheels, install it from source instead:
237
+
238
+ ```shell
239
+ pip3 uninstall -y autoawq
240
+ git clone https://github.com/casper-hansen/AutoAWQ
241
+ cd AutoAWQ
242
+ pip3 install .
243
+ ```
244
+
245
+ ### Transformers example code (requires Transformers 4.35.0 and later)
246
+
247
+ ```python
248
+ from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
249
+
250
+ model_name_or_path = "TheBloke/meditron-7B-chat-AWQ"
251
+
252
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
253
+ model = AutoModelForCausalLM.from_pretrained(
254
+ model_name_or_path,
255
+ low_cpu_mem_usage=True,
256
+ device_map="cuda:0"
257
+ )
258
+
259
+ # Using the text streamer to stream output one token at a time
260
+ streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
261
+
262
+ prompt = "Tell me about AI"
263
+ prompt_template=f'''### Instruction:
264
+ {prompt}
265
+
266
+ ### Response:
267
+ '''
268
+
269
+ # Convert prompt to tokens
270
+ tokens = tokenizer(
271
+ prompt_template,
272
+ return_tensors='pt'
273
+ ).input_ids.cuda()
274
+
275
+ generation_params = {
276
+ "do_sample": True,
277
+ "temperature": 0.7,
278
+ "top_p": 0.95,
279
+ "top_k": 40,
280
+ "max_new_tokens": 512,
281
+ "repetition_penalty": 1.1
282
+ }
283
+
284
+ # Generate streamed output, visible one token at a time
285
+ generation_output = model.generate(
286
+ tokens,
287
+ streamer=streamer,
288
+ **generation_params
289
+ )
290
+
291
+ # Generation without a streamer, which will include the prompt in the output
292
+ generation_output = model.generate(
293
+ tokens,
294
+ **generation_params
295
+ )
296
+
297
+ # Get the tokens from the output, decode them, print them
298
+ token_output = generation_output[0]
299
+ text_output = tokenizer.decode(token_output)
300
+ print("model.generate output: ", text_output)
301
+
302
+ # Inference is also possible via Transformers' pipeline
303
+ from transformers import pipeline
304
+
305
+ pipe = pipeline(
306
+ "text-generation",
307
+ model=model,
308
+ tokenizer=tokenizer,
309
+ **generation_params
310
+ )
311
+
312
+ pipe_output = pipe(prompt_template)[0]['generated_text']
313
+ print("pipeline output: ", pipe_output)
314
+
315
+ ```
316
+ <!-- README_AWQ.md-use-from-python end -->
317
+
318
+ <!-- README_AWQ.md-compatibility start -->
319
+ ## Compatibility
320
+
321
+ The files provided are tested to work with:
322
+
323
+ - [text-generation-webui](https://github.com/oobabooga/text-generation-webui) using `Loader: AutoAWQ`.
324
+ - [vLLM](https://github.com/vllm-project/vllm) version 0.2.0 and later.
325
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference) version 1.1.0 and later.
326
+ - [Transformers](https://huggingface.co/docs/transformers) version 4.35.0 and later.
327
+ - [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) version 0.1.1 and later.
328
+
329
+ <!-- README_AWQ.md-compatibility end -->
330
+
331
+ <!-- footer start -->
332
+ <!-- 200823 -->
333
+ ## Discord
334
+
335
+ For further support, and discussions on these models and AI in general, join us at:
336
+
337
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
338
+
339
+ ## Thanks, and how to contribute
340
+
341
+ Thanks to the [chirper.ai](https://chirper.ai) team!
342
+
343
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
344
+
345
+ 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.
346
+
347
+ 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.
348
+
349
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
350
+
351
+ * Patreon: https://patreon.com/TheBlokeAI
352
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
353
+
354
+ **Special thanks to**: Aemon Algiz.
355
+
356
+ **Patreon special mentions**: Michael Levine, 阿明, Trailburnt, Nikolai Manek, John Detwiler, Randy H, Will Dee, Sebastain Graf, NimbleBox.ai, Eugene Pentland, Emad Mostaque, Ai Maven, Jim Angel, Jeff Scroggin, Michael Davis, Manuel Alberto Morcote, Stephen Murray, Robert, Justin Joy, Luke @flexchar, Brandon Frisco, Elijah Stavena, S_X, Dan Guido, Undi ., Komninos Chatzipapas, Shadi, theTransient, Lone Striker, Raven Klaugh, jjj, Cap'n Zoog, Michel-Marie MAUDET (LINAGORA), Matthew Berman, David, Fen Risland, Omer Bin Jawed, Luke Pendergrass, Kalila, OG, Erik Bjäreholt, Rooh Singh, Joseph William Delisle, Dan Lewis, TL, John Villwock, AzureBlack, Brad, Pedro Madruga, Caitlyn Gatomon, K, jinyuan sun, Mano Prime, Alex, Jeffrey Morgan, Alicia Loh, Illia Dulskyi, Chadd, transmissions 11, fincy, Rainer Wilmers, ReadyPlayerEmma, knownsqashed, Mandus, biorpg, Deo Leter, Brandon Phillips, SuperWojo, Sean Connelly, Iucharbius, Jack West, Harry Royden McLaughlin, Nicholas, terasurfer, Vitor Caleffi, Duane Dunston, Johann-Peter Hartmann, David Ziegler, Olakabola, Ken Nordquist, Trenton Dambrowitz, Tom X Nguyen, Vadim, Ajan Kanaga, Leonard Tan, Clay Pascal, Alexandros Triantafyllidis, JM33133, Xule, vamX, ya boyyy, subjectnull, Talal Aujan, Alps Aficionado, wassieverse, Ari Malik, James Bentley, Woland, Spencer Kim, Michael Dempsey, Fred von Graf, Elle, zynix, William Richards, Stanislav Ovsiannikov, Edmond Seymore, Jonathan Leane, Martin Kemka, usrbinkat, Enrico Ros
357
+
358
+
359
+ Thank you to all my generous patrons and donaters!
360
+
361
+ And thank you again to a16z for their generous grant.
362
+
363
+ <!-- footer end -->
364
+
365
+ # Original model card: Mohamad Alhajar's Meditron 7B Chat
366
+
367
+ # Model Card for Model ID
368
+
369
+ <!-- Provide a quick summary of what the model is/does. -->
370
+ meditron-7b-chat is a finetuned version of [`epfl-llm/meditron-7b`](https://huggingface.co/epfl-llm/meditron-7b) using SFT Training on the Alpaca Dataset.
371
+ This model can answer information about different excplicit ideas in medicine (see [`epfl-llm/meditron-7b`](https://huggingface.co/epfl-llm/meditron-7b) for more info)
372
+
373
+ ### Model Description
374
+
375
+ - **Finetuned by:** [`Mohamad Alhajar`](https://www.linkedin.com/in/muhammet-alhajar/)
376
+ - **Language(s) (NLP):** English
377
+ - **Finetuned from model:** [`epfl-llm/meditron-7b`](https://huggingface.co/epfl-llm/meditron-7b)
378
+
379
+ ### Prompt Template
380
+ ```
381
+ ### Instruction:
382
+
383
+ <prompt> (without the <>)
384
+
385
+ ### Response:
386
+ ```
387
+
388
+
389
+ ## How to Get Started with the Model
390
+
391
+ Use the code sample provided in the original post to interact with the model.
392
+ ```python
393
+ from transformers import AutoTokenizer,AutoModelForCausalLM
394
+
395
+ model_id = "malhajar/meditron-7b-chat"
396
+ model = AutoModelForCausalLM.from_pretrained(model_name_or_path,
397
+ device_map="auto",
398
+ torch_dtype=torch.float16,
399
+ revision="main")
400
+
401
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
402
+
403
+ question: "what is tract infection?"
404
+ # For generating a response
405
+ prompt = '''
406
+ ### Instruction:
407
+ {question}
408
+
409
+ ### Response:'''
410
+ input_ids = tokenizer(prompt, return_tensors="pt").input_ids
411
+ output = model.generate(inputs=input_ids,max_new_tokens=512,pad_token_id=tokenizer.eos_token_id,top_k=50, do_sample=True,
412
+ top_p=0.95)
413
+ response = tokenizer.decode(output[0])
414
+
415
+ print(response)
416
+ ```