TheBloke commited on
Commit
20465db
1 Parent(s): 0f7a8b5

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +379 -0
README.md ADDED
@@ -0,0 +1,379 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: NousResearch/Yarn-Mistral-7b-64k
3
+ datasets:
4
+ - emozilla/yarn-train-tokenized-16k-mistral
5
+ inference: false
6
+ library_name: transformers
7
+ metrics:
8
+ - perplexity
9
+ model_creator: NousResearch
10
+ model_name: Yarn Mistral 7B 64K
11
+ model_type: mistral
12
+ prompt_template: '{prompt}
13
+
14
+ '
15
+ quantized_by: TheBloke
16
+ ---
17
+ <!-- markdownlint-disable MD041 -->
18
+
19
+ <!-- header start -->
20
+ <!-- 200823 -->
21
+ <div style="width: auto; margin-left: auto; margin-right: auto">
22
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
23
+ </div>
24
+ <div style="display: flex; justify-content: space-between; width: 100%;">
25
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
26
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
27
+ </div>
28
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
29
+ <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>
30
+ </div>
31
+ </div>
32
+ <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>
33
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
34
+ <!-- header end -->
35
+
36
+ # Yarn Mistral 7B 64K - AWQ
37
+ - Model creator: [NousResearch](https://huggingface.co/NousResearch)
38
+ - Original model: [Yarn Mistral 7B 64K](https://huggingface.co/NousResearch/Yarn-Mistral-7b-64k)
39
+
40
+ <!-- description start -->
41
+ ## Description
42
+
43
+ This repo contains AWQ model files for [NousResearch's Yarn Mistral 7B 64K](https://huggingface.co/NousResearch/Yarn-Mistral-7b-64k).
44
+
45
+ These files were quantised using hardware kindly provided by [Massed Compute](https://massedcompute.com/).
46
+
47
+
48
+ ### About AWQ
49
+
50
+ 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.
51
+
52
+ It is supported by:
53
+
54
+ - [Text Generation Webui](https://github.com/oobabooga/text-generation-webui) - using Loader: AutoAWQ
55
+ - [vLLM](https://github.com/vllm-project/vllm) - Llama and Mistral models only
56
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference)
57
+ - [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) - for use from Python code
58
+
59
+ <!-- description end -->
60
+ <!-- repositories-available start -->
61
+ ## Repositories available
62
+
63
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/Yarn-Mistral-7B-64k-AWQ)
64
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/Yarn-Mistral-7B-64k-GPTQ)
65
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/Yarn-Mistral-7B-64k-GGUF)
66
+ * [NousResearch's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/NousResearch/Yarn-Mistral-7b-64k)
67
+ <!-- repositories-available end -->
68
+
69
+ <!-- prompt-template start -->
70
+ ## Prompt template: None
71
+
72
+ ```
73
+ {prompt}
74
+
75
+ ```
76
+
77
+ <!-- prompt-template end -->
78
+
79
+
80
+ <!-- README_AWQ.md-provided-files start -->
81
+ ## Provided files, and AWQ parameters
82
+
83
+ 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.
84
+
85
+ Models are released as sharded safetensors files.
86
+
87
+ | Branch | Bits | GS | AWQ Dataset | Seq Len | Size |
88
+ | ------ | ---- | -- | ----------- | ------- | ---- |
89
+ | [main](https://huggingface.co/TheBloke/Yarn-Mistral-7B-64k-AWQ/tree/main) | 4 | 128 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-v1/test) | 4096 | 4.15 GB
90
+
91
+ <!-- README_AWQ.md-provided-files end -->
92
+
93
+ <!-- README_AWQ.md-text-generation-webui start -->
94
+ ## How to easily download and use this model in [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
95
+
96
+ Please make sure you're using the latest version of [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
97
+
98
+ 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.
99
+
100
+ 1. Click the **Model tab**.
101
+ 2. Under **Download custom model or LoRA**, enter `TheBloke/Yarn-Mistral-7B-64k-AWQ`.
102
+ 3. Click **Download**.
103
+ 4. The model will start downloading. Once it's finished it will say "Done".
104
+ 5. In the top left, click the refresh icon next to **Model**.
105
+ 6. In the **Model** dropdown, choose the model you just downloaded: `Yarn-Mistral-7B-64k-AWQ`
106
+ 7. Select **Loader: AutoAWQ**.
107
+ 8. Click Load, and the model will load and is now ready for use.
108
+ 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.
109
+ 10. Once you're ready, click the **Text Generation** tab and enter a prompt to get started!
110
+ <!-- README_AWQ.md-text-generation-webui end -->
111
+
112
+ <!-- README_AWQ.md-use-from-vllm start -->
113
+ ## Multi-user inference server: vLLM
114
+
115
+ Documentation on installing and using vLLM [can be found here](https://vllm.readthedocs.io/en/latest/).
116
+
117
+ - Please ensure you are using vLLM version 0.2 or later.
118
+ - When using vLLM as a server, pass the `--quantization awq` parameter.
119
+
120
+ For example:
121
+
122
+ ```shell
123
+ python3 python -m vllm.entrypoints.api_server --model TheBloke/Yarn-Mistral-7B-64k-AWQ --quantization awq
124
+ ```
125
+
126
+ - When using vLLM from Python code, again set `quantization=awq`.
127
+
128
+ For example:
129
+
130
+ ```python
131
+ from vllm import LLM, SamplingParams
132
+
133
+ prompts = [
134
+ "Tell me about AI",
135
+ "Write a story about llamas",
136
+ "What is 291 - 150?",
137
+ "How much wood would a woodchuck chuck if a woodchuck could chuck wood?",
138
+ ]
139
+ prompt_template=f'''{prompt}
140
+ '''
141
+
142
+ prompts = [prompt_template.format(prompt=prompt) for prompt in prompts]
143
+
144
+ sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
145
+
146
+ llm = LLM(model="TheBloke/Yarn-Mistral-7B-64k-AWQ", quantization="awq", dtype="auto")
147
+
148
+ outputs = llm.generate(prompts, sampling_params)
149
+
150
+ # Print the outputs.
151
+ for output in outputs:
152
+ prompt = output.prompt
153
+ generated_text = output.outputs[0].text
154
+ print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
155
+ ```
156
+ <!-- README_AWQ.md-use-from-vllm start -->
157
+
158
+ <!-- README_AWQ.md-use-from-tgi start -->
159
+ ## Multi-user inference server: Hugging Face Text Generation Inference (TGI)
160
+
161
+ Use TGI version 1.1.0 or later. The official Docker container is: `ghcr.io/huggingface/text-generation-inference:1.1.0`
162
+
163
+ Example Docker parameters:
164
+
165
+ ```shell
166
+ --model-id TheBloke/Yarn-Mistral-7B-64k-AWQ --port 3000 --quantize awq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
167
+ ```
168
+
169
+ Example Python code for interfacing with TGI (requires [huggingface-hub](https://github.com/huggingface/huggingface_hub) 0.17.0 or later):
170
+
171
+ ```shell
172
+ pip3 install huggingface-hub
173
+ ```
174
+
175
+ ```python
176
+ from huggingface_hub import InferenceClient
177
+
178
+ endpoint_url = "https://your-endpoint-url-here"
179
+
180
+ prompt = "Tell me about AI"
181
+ prompt_template=f'''{prompt}
182
+ '''
183
+
184
+ client = InferenceClient(endpoint_url)
185
+ response = client.text_generation(prompt,
186
+ max_new_tokens=128,
187
+ do_sample=True,
188
+ temperature=0.7,
189
+ top_p=0.95,
190
+ top_k=40,
191
+ repetition_penalty=1.1)
192
+
193
+ print(f"Model output: ", response)
194
+ ```
195
+ <!-- README_AWQ.md-use-from-tgi end -->
196
+
197
+ <!-- README_AWQ.md-use-from-python start -->
198
+ ## Inference from Python code using AutoAWQ
199
+
200
+ ### Install the AutoAWQ package
201
+
202
+ Requires: [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) 0.1.1 or later.
203
+
204
+ ```shell
205
+ pip3 install autoawq
206
+ ```
207
+
208
+ If you have problems installing [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) using the pre-built wheels, install it from source instead:
209
+
210
+ ```shell
211
+ pip3 uninstall -y autoawq
212
+ git clone https://github.com/casper-hansen/AutoAWQ
213
+ cd AutoAWQ
214
+ pip3 install .
215
+ ```
216
+
217
+ ### AutoAWQ example code
218
+
219
+ ```python
220
+ from awq import AutoAWQForCausalLM
221
+ from transformers import AutoTokenizer
222
+
223
+ model_name_or_path = "TheBloke/Yarn-Mistral-7B-64k-AWQ"
224
+
225
+ # Load tokenizer
226
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=True)
227
+ # Load model
228
+ model = AutoAWQForCausalLM.from_quantized(model_name_or_path, fuse_layers=True,
229
+ trust_remote_code=True, safetensors=True)
230
+
231
+ prompt = "Tell me about AI"
232
+ prompt_template=f'''{prompt}
233
+ '''
234
+
235
+ print("*** Running model.generate:")
236
+
237
+ token_input = tokenizer(
238
+ prompt_template,
239
+ return_tensors='pt'
240
+ ).input_ids.cuda()
241
+
242
+ # Generate output
243
+ generation_output = model.generate(
244
+ token_input,
245
+ do_sample=True,
246
+ temperature=0.7,
247
+ top_p=0.95,
248
+ top_k=40,
249
+ max_new_tokens=512
250
+ )
251
+
252
+ # Get the tokens from the output, decode them, print them
253
+ token_output = generation_output[0]
254
+ text_output = tokenizer.decode(token_output)
255
+ print("LLM output: ", text_output)
256
+
257
+ """
258
+ # Inference should be possible with transformers pipeline as well in future
259
+ # But currently this is not yet supported by AutoAWQ (correct as of September 25th 2023)
260
+ from transformers import pipeline
261
+
262
+ print("*** Pipeline:")
263
+ pipe = pipeline(
264
+ "text-generation",
265
+ model=model,
266
+ tokenizer=tokenizer,
267
+ max_new_tokens=512,
268
+ do_sample=True,
269
+ temperature=0.7,
270
+ top_p=0.95,
271
+ top_k=40,
272
+ repetition_penalty=1.1
273
+ )
274
+
275
+ print(pipe(prompt_template)[0]['generated_text'])
276
+ """
277
+ ```
278
+ <!-- README_AWQ.md-use-from-python end -->
279
+
280
+ <!-- README_AWQ.md-compatibility start -->
281
+ ## Compatibility
282
+
283
+ The files provided are tested to work with:
284
+
285
+ - [text-generation-webui](https://github.com/oobabooga/text-generation-webui) using `Loader: AutoAWQ`.
286
+ - [vLLM](https://github.com/vllm-project/vllm) version 0.2.0 and later.
287
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference) version 1.1.0 and later.
288
+ - [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) version 0.1.1 and later.
289
+
290
+ <!-- README_AWQ.md-compatibility end -->
291
+
292
+ <!-- footer start -->
293
+ <!-- 200823 -->
294
+ ## Discord
295
+
296
+ For further support, and discussions on these models and AI in general, join us at:
297
+
298
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
299
+
300
+ ## Thanks, and how to contribute
301
+
302
+ Thanks to the [chirper.ai](https://chirper.ai) team!
303
+
304
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
305
+
306
+ 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.
307
+
308
+ 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.
309
+
310
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
311
+
312
+ * Patreon: https://patreon.com/TheBlokeAI
313
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
314
+
315
+ **Special thanks to**: Aemon Algiz.
316
+
317
+ **Patreon special mentions**: Brandon Frisco, LangChain4j, Spiking Neurons AB, transmissions 11, Joseph William Delisle, Nitin Borwankar, Willem Michiel, Michael Dempsey, vamX, Jeffrey Morgan, zynix, jjj, Omer Bin Jawed, Sean Connelly, jinyuan sun, Jeromy Smith, Shadi, Pawan Osman, Chadd, Elijah Stavena, Illia Dulskyi, Sebastain Graf, Stephen Murray, terasurfer, Edmond Seymore, Celu Ramasamy, Mandus, Alex, biorpg, Ajan Kanaga, Clay Pascal, Raven Klaugh, 阿明, K, ya boyyy, usrbinkat, Alicia Loh, John Villwock, ReadyPlayerEmma, Chris Smitley, Cap'n Zoog, fincy, GodLy, S_X, sidney chen, Cory Kujawski, OG, Mano Prime, AzureBlack, Pieter, Kalila, Spencer Kim, Tom X Nguyen, Stanislav Ovsiannikov, Michael Levine, Andrey, Trailburnt, Vadim, Enrico Ros, Talal Aujan, Brandon Phillips, Jack West, Eugene Pentland, Michael Davis, Will Dee, webtim, Jonathan Leane, Alps Aficionado, Rooh Singh, Tiffany J. Kim, theTransient, Luke @flexchar, Elle, Caitlyn Gatomon, Ari Malik, subjectnull, Johann-Peter Hartmann, Trenton Dambrowitz, Imad Khwaja, Asp the Wyvern, Emad Mostaque, Rainer Wilmers, Alexandros Triantafyllidis, Nicholas, Pedro Madruga, SuperWojo, Harry Royden McLaughlin, James Bentley, Olakabola, David Ziegler, Ai Maven, Jeff Scroggin, Nikolai Manek, Deo Leter, Matthew Berman, Fen Risland, Ken Nordquist, Manuel Alberto Morcote, Luke Pendergrass, TL, Fred von Graf, Randy H, Dan Guido, NimbleBox.ai, Vitor Caleffi, Gabriel Tamborski, knownsqashed, Lone Striker, Erik Bjäreholt, John Detwiler, Leonard Tan, Iucharbius
318
+
319
+
320
+ Thank you to all my generous patrons and donaters!
321
+
322
+ And thank you again to a16z for their generous grant.
323
+
324
+ <!-- footer end -->
325
+
326
+ # Original model card: NousResearch's Yarn Mistral 7B 64K
327
+
328
+
329
+ # Model Card: Nous-Yarn-Mistral-7b-64k
330
+
331
+ [Preprint (arXiv)](https://arxiv.org/abs/2309.00071)
332
+ [GitHub](https://github.com/jquesnelle/yarn)
333
+ ![yarn](https://raw.githubusercontent.com/jquesnelle/yarn/mistral/data/proofpile-long-small-mistral.csv.png)
334
+
335
+ ## Model Description
336
+
337
+ Nous-Yarn-Mistral-7b-64k is a state-of-the-art language model for long context, further pretrained on long context data for 1000 steps using the YaRN extension method.
338
+ It is an extension of [Mistral-7B-v0.1](https://huggingface.co/mistralai/Mistral-7B-v0.1) and supports a 64k token context window.
339
+
340
+ To use, pass `trust_remote_code=True` when loading the model, for example
341
+
342
+ ```python
343
+ model = AutoModelForCausalLM.from_pretrained("NousResearch/Yarn-Mistral-7b-64k",
344
+ use_flash_attention_2=True,
345
+ torch_dtype=torch.bfloat16,
346
+ device_map="auto",
347
+ trust_remote_code=True)
348
+ ```
349
+
350
+ In addition you will need to use the latest version of `transformers` (until 4.35 comes out)
351
+ ```sh
352
+ pip install git+https://github.com/huggingface/transformers
353
+ ```
354
+
355
+ ## Benchmarks
356
+
357
+ Long context benchmarks:
358
+ | Model | Context Window | 8k PPL | 16k PPL | 32k PPL | 64k PPL | 128k PPL |
359
+ |-------|---------------:|------:|----------:|-----:|-----:|------------:|
360
+ | [Mistral-7B-v0.1](https://huggingface.co/mistralai/Mistral-7B-v0.1) | 8k | 2.96 | - | - | - | - |
361
+ | [Yarn-Mistral-7b-64k](https://huggingface.co/NousResearch/Yarn-Mistral-7b-64k) | 64k | 3.04 | 2.65 | 2.44 | 2.20 | - |
362
+ | [Yarn-Mistral-7b-128k](https://huggingface.co/NousResearch/Yarn-Mistral-7b-128k) | 128k | 3.08 | 2.68 | 2.47 | 2.24 | 2.19 |
363
+
364
+ Short context benchmarks showing that quality degradation is minimal:
365
+ | Model | Context Window | ARC-c | Hellaswag | MMLU | Truthful QA |
366
+ |-------|---------------:|------:|----------:|-----:|------------:|
367
+ | [Mistral-7B-v0.1](https://huggingface.co/mistralai/Mistral-7B-v0.1) | 8k | 59.98 | 83.31 | 64.16 | 42.15 |
368
+ | [Yarn-Mistral-7b-64k](https://huggingface.co/NousResearch/Yarn-Mistral-7b-64k) | 64k | 59.38 | 81.21 | 61.32 | 42.50 |
369
+ | [Yarn-Mistral-7b-128k](https://huggingface.co/NousResearch/Yarn-Mistral-7b-128k) | 128k | 58.87 | 80.58 | 60.64 | 42.46 |
370
+
371
+ ## Collaborators
372
+
373
+ - [bloc97](https://github.com/bloc97): Methods, paper and evals
374
+ - [@theemozilla](https://twitter.com/theemozilla): Methods, paper, model training, and evals
375
+ - [@EnricoShippole](https://twitter.com/EnricoShippole): Model training
376
+ - [honglu2875](https://github.com/honglu2875): Paper and evals
377
+
378
+ The authors would like to thank LAION AI for their support of compute for this model.
379
+ It was trained on the [JUWELS](https://www.fz-juelich.de/en/ias/jsc/systems/supercomputers/juwels) supercomputer.