TheBloke commited on
Commit
a468fa8
1 Parent(s): d4e98d3

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +522 -0
README.md ADDED
@@ -0,0 +1,522 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: NickyNicky/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v2
3
+ datasets:
4
+ - Open-Orca/OpenOrca
5
+ - OpenAssistant/oasst_top1_2023-08-25
6
+ inference: false
7
+ language:
8
+ - bg
9
+ - ca
10
+ - cs
11
+ - da
12
+ - de
13
+ - en
14
+ - es
15
+ - fr
16
+ - hr
17
+ - hu
18
+ - it
19
+ - nl
20
+ - pl
21
+ - pt
22
+ - ro
23
+ - ru
24
+ - sl
25
+ - sr
26
+ - sv
27
+ - uk
28
+ library_name: transformers
29
+ license: apache-2.0
30
+ model_creator: Nicky
31
+ model_name: Mistral 7B Openorca Oasst Top1 2023 08 25 V2
32
+ model_type: mistral
33
+ prompt_template: '<|im_start|>system
34
+
35
+ {system_message}<|im_end|>
36
+
37
+ <|im_start|>user
38
+
39
+ {prompt}<|im_end|>
40
+
41
+ <|im_start|>assistant
42
+
43
+ '
44
+ quantized_by: TheBloke
45
+ ---
46
+ <!-- markdownlint-disable MD041 -->
47
+
48
+ <!-- header start -->
49
+ <!-- 200823 -->
50
+ <div style="width: auto; margin-left: auto; margin-right: auto">
51
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
52
+ </div>
53
+ <div style="display: flex; justify-content: space-between; width: 100%;">
54
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
55
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
56
+ </div>
57
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
58
+ <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>
59
+ </div>
60
+ </div>
61
+ <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>
62
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
63
+ <!-- header end -->
64
+
65
+ # Mistral 7B Openorca Oasst Top1 2023 08 25 V2 - AWQ
66
+ - Model creator: [Nicky](https://huggingface.co/NickyNicky)
67
+ - Original model: [Mistral 7B Openorca Oasst Top1 2023 08 25 V2](https://huggingface.co/NickyNicky/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v2)
68
+
69
+ <!-- description start -->
70
+ ## Description
71
+
72
+ This repo contains AWQ model files for [Nicky's Mistral 7B Openorca Oasst Top1 2023 08 25 V2](https://huggingface.co/NickyNicky/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v2).
73
+
74
+ These files were quantised using hardware kindly provided by [Massed Compute](https://massedcompute.com/).
75
+
76
+
77
+ ### About AWQ
78
+
79
+ 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.
80
+
81
+ AWQ models are currently supported on Linux and Windows, with NVidia GPUs only. macOS users: please use GGUF models instead.
82
+
83
+ It is supported by:
84
+
85
+ - [Text Generation Webui](https://github.com/oobabooga/text-generation-webui) - using Loader: AutoAWQ
86
+ - [vLLM](https://github.com/vllm-project/vllm) - version 0.2.2 or later for support for all model types.
87
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference)
88
+ - [Transformers](https://huggingface.co/docs/transformers) version 4.35.0 and later, from any code or client that supports Transformers
89
+ - [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) - for use from Python code
90
+
91
+ <!-- description end -->
92
+ <!-- repositories-available start -->
93
+ ## Repositories available
94
+
95
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v2-AWQ)
96
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v2-GPTQ)
97
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v2-GGUF)
98
+ * [Nicky's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/NickyNicky/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v2)
99
+ <!-- repositories-available end -->
100
+
101
+ <!-- prompt-template start -->
102
+ ## Prompt template: ChatML
103
+
104
+ ```
105
+ <|im_start|>system
106
+ {system_message}<|im_end|>
107
+ <|im_start|>user
108
+ {prompt}<|im_end|>
109
+ <|im_start|>assistant
110
+
111
+ ```
112
+
113
+ <!-- prompt-template end -->
114
+
115
+
116
+ <!-- README_AWQ.md-provided-files start -->
117
+ ## Provided files, and AWQ parameters
118
+
119
+ I currently release 128g GEMM models only. The addition of group_size 32 models, and GEMV kernel models, is being actively considered.
120
+
121
+ Models are released as sharded safetensors files.
122
+
123
+ | Branch | Bits | GS | AWQ Dataset | Seq Len | Size |
124
+ | ------ | ---- | -- | ----------- | ------- | ---- |
125
+ | [main](https://huggingface.co/TheBloke/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v2-AWQ/tree/main) | 4 | 128 | [VMware Open Instruct](https://huggingface.co/datasets/VMware/open-instruct/viewer/) | 4096 | 4.15 GB
126
+
127
+ <!-- README_AWQ.md-provided-files end -->
128
+
129
+ <!-- README_AWQ.md-text-generation-webui start -->
130
+ ## How to easily download and use this model in [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
131
+
132
+ Please make sure you're using the latest version of [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
133
+
134
+ 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.
135
+
136
+ 1. Click the **Model tab**.
137
+ 2. Under **Download custom model or LoRA**, enter `TheBloke/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v2-AWQ`.
138
+ 3. Click **Download**.
139
+ 4. The model will start downloading. Once it's finished it will say "Done".
140
+ 5. In the top left, click the refresh icon next to **Model**.
141
+ 6. In the **Model** dropdown, choose the model you just downloaded: `Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v2-AWQ`
142
+ 7. Select **Loader: AutoAWQ**.
143
+ 8. Click Load, and the model will load and is now ready for use.
144
+ 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.
145
+ 10. Once you're ready, click the **Text Generation** tab and enter a prompt to get started!
146
+ <!-- README_AWQ.md-text-generation-webui end -->
147
+
148
+ <!-- README_AWQ.md-use-from-vllm start -->
149
+ ## Multi-user inference server: vLLM
150
+
151
+ Documentation on installing and using vLLM [can be found here](https://vllm.readthedocs.io/en/latest/).
152
+
153
+ - Please ensure you are using vLLM version 0.2 or later.
154
+ - When using vLLM as a server, pass the `--quantization awq` parameter.
155
+
156
+ For example:
157
+
158
+ ```shell
159
+ python3 -m vllm.entrypoints.api_server --model TheBloke/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v2-AWQ --quantization awq --dtype auto
160
+ ```
161
+
162
+ - When using vLLM from Python code, again set `quantization=awq`.
163
+
164
+ For example:
165
+
166
+ ```python
167
+ from vllm import LLM, SamplingParams
168
+
169
+ prompts = [
170
+ "Tell me about AI",
171
+ "Write a story about llamas",
172
+ "What is 291 - 150?",
173
+ "How much wood would a woodchuck chuck if a woodchuck could chuck wood?",
174
+ ]
175
+ prompt_template=f'''<|im_start|>system
176
+ {system_message}<|im_end|>
177
+ <|im_start|>user
178
+ {prompt}<|im_end|>
179
+ <|im_start|>assistant
180
+ '''
181
+
182
+ prompts = [prompt_template.format(prompt=prompt) for prompt in prompts]
183
+
184
+ sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
185
+
186
+ llm = LLM(model="TheBloke/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v2-AWQ", quantization="awq", dtype="auto")
187
+
188
+ outputs = llm.generate(prompts, sampling_params)
189
+
190
+ # Print the outputs.
191
+ for output in outputs:
192
+ prompt = output.prompt
193
+ generated_text = output.outputs[0].text
194
+ print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
195
+ ```
196
+ <!-- README_AWQ.md-use-from-vllm start -->
197
+
198
+ <!-- README_AWQ.md-use-from-tgi start -->
199
+ ## Multi-user inference server: Hugging Face Text Generation Inference (TGI)
200
+
201
+ Use TGI version 1.1.0 or later. The official Docker container is: `ghcr.io/huggingface/text-generation-inference:1.1.0`
202
+
203
+ Example Docker parameters:
204
+
205
+ ```shell
206
+ --model-id TheBloke/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v2-AWQ --port 3000 --quantize awq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
207
+ ```
208
+
209
+ Example Python code for interfacing with TGI (requires [huggingface-hub](https://github.com/huggingface/huggingface_hub) 0.17.0 or later):
210
+
211
+ ```shell
212
+ pip3 install huggingface-hub
213
+ ```
214
+
215
+ ```python
216
+ from huggingface_hub import InferenceClient
217
+
218
+ endpoint_url = "https://your-endpoint-url-here"
219
+
220
+ prompt = "Tell me about AI"
221
+ prompt_template=f'''<|im_start|>system
222
+ {system_message}<|im_end|>
223
+ <|im_start|>user
224
+ {prompt}<|im_end|>
225
+ <|im_start|>assistant
226
+ '''
227
+
228
+ client = InferenceClient(endpoint_url)
229
+ response = client.text_generation(prompt,
230
+ max_new_tokens=128,
231
+ do_sample=True,
232
+ temperature=0.7,
233
+ top_p=0.95,
234
+ top_k=40,
235
+ repetition_penalty=1.1)
236
+
237
+ print(f"Model output: ", response)
238
+ ```
239
+ <!-- README_AWQ.md-use-from-tgi end -->
240
+
241
+ <!-- README_AWQ.md-use-from-python start -->
242
+ ## Inference from Python code using Transformers
243
+
244
+ ### Install the necessary packages
245
+
246
+ - Requires: [Transformers](https://huggingface.co/docs/transformers) 4.35.0 or later.
247
+ - Requires: [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) 0.1.6 or later.
248
+
249
+ ```shell
250
+ pip3 install --upgrade "autoawq>=0.1.6" "transformers>=4.35.0"
251
+ ```
252
+
253
+ Note that if you are using PyTorch 2.0.1, the above AutoAWQ command will automatically upgrade you to PyTorch 2.1.0.
254
+
255
+ If you are using CUDA 11.8 and wish to continue using PyTorch 2.0.1, instead run this command:
256
+
257
+ ```shell
258
+ pip3 install https://github.com/casper-hansen/AutoAWQ/releases/download/v0.1.6/autoawq-0.1.6+cu118-cp310-cp310-linux_x86_64.whl
259
+ ```
260
+
261
+ If you have problems installing [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) using the pre-built wheels, install it from source instead:
262
+
263
+ ```shell
264
+ pip3 uninstall -y autoawq
265
+ git clone https://github.com/casper-hansen/AutoAWQ
266
+ cd AutoAWQ
267
+ pip3 install .
268
+ ```
269
+
270
+ ### Transformers example code (requires Transformers 4.35.0 and later)
271
+
272
+ ```python
273
+ from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
274
+
275
+ model_name_or_path = "TheBloke/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v2-AWQ"
276
+
277
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
278
+ model = AutoModelForCausalLM.from_pretrained(
279
+ model_name_or_path,
280
+ low_cpu_mem_usage=True,
281
+ device_map="cuda:0"
282
+ )
283
+
284
+ # Using the text streamer to stream output one token at a time
285
+ streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
286
+
287
+ prompt = "Tell me about AI"
288
+ prompt_template=f'''<|im_start|>system
289
+ {system_message}<|im_end|>
290
+ <|im_start|>user
291
+ {prompt}<|im_end|>
292
+ <|im_start|>assistant
293
+ '''
294
+
295
+ # Convert prompt to tokens
296
+ tokens = tokenizer(
297
+ prompt_template,
298
+ return_tensors='pt'
299
+ ).input_ids.cuda()
300
+
301
+ generation_params = {
302
+ "do_sample": True,
303
+ "temperature": 0.7,
304
+ "top_p": 0.95,
305
+ "top_k": 40,
306
+ "max_new_tokens": 512,
307
+ "repetition_penalty": 1.1
308
+ }
309
+
310
+ # Generate streamed output, visible one token at a time
311
+ generation_output = model.generate(
312
+ tokens,
313
+ streamer=streamer,
314
+ **generation_params
315
+ )
316
+
317
+ # Generation without a streamer, which will include the prompt in the output
318
+ generation_output = model.generate(
319
+ tokens,
320
+ **generation_params
321
+ )
322
+
323
+ # Get the tokens from the output, decode them, print them
324
+ token_output = generation_output[0]
325
+ text_output = tokenizer.decode(token_output)
326
+ print("model.generate output: ", text_output)
327
+
328
+ # Inference is also possible via Transformers' pipeline
329
+ from transformers import pipeline
330
+
331
+ pipe = pipeline(
332
+ "text-generation",
333
+ model=model,
334
+ tokenizer=tokenizer,
335
+ **generation_params
336
+ )
337
+
338
+ pipe_output = pipe(prompt_template)[0]['generated_text']
339
+ print("pipeline output: ", pipe_output)
340
+
341
+ ```
342
+ <!-- README_AWQ.md-use-from-python end -->
343
+
344
+ <!-- README_AWQ.md-compatibility start -->
345
+ ## Compatibility
346
+
347
+ The files provided are tested to work with:
348
+
349
+ - [text-generation-webui](https://github.com/oobabooga/text-generation-webui) using `Loader: AutoAWQ`.
350
+ - [vLLM](https://github.com/vllm-project/vllm) version 0.2.0 and later.
351
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference) version 1.1.0 and later.
352
+ - [Transformers](https://huggingface.co/docs/transformers) version 4.35.0 and later.
353
+ - [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) version 0.1.1 and later.
354
+
355
+ <!-- README_AWQ.md-compatibility end -->
356
+
357
+ <!-- footer start -->
358
+ <!-- 200823 -->
359
+ ## Discord
360
+
361
+ For further support, and discussions on these models and AI in general, join us at:
362
+
363
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
364
+
365
+ ## Thanks, and how to contribute
366
+
367
+ Thanks to the [chirper.ai](https://chirper.ai) team!
368
+
369
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
370
+
371
+ 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.
372
+
373
+ 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.
374
+
375
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
376
+
377
+ * Patreon: https://patreon.com/TheBlokeAI
378
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
379
+
380
+ **Special thanks to**: Aemon Algiz.
381
+
382
+ **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
383
+
384
+
385
+ Thank you to all my generous patrons and donaters!
386
+
387
+ And thank you again to a16z for their generous grant.
388
+
389
+ <!-- footer end -->
390
+
391
+ # Original model card: Nicky's Mistral 7B Openorca Oasst Top1 2023 08 25 V2
392
+
393
+
394
+
395
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/641b435ba5f876fe30c5ae0a/rJ1RxzuE-3gzgCppx-T8f.png)
396
+
397
+ ```
398
+ reference-data-model:
399
+
400
+ datasets:
401
+ - OpenAssistant/oasst_top1_2023-08-25:
402
+ lang: "bg,ca,cs,da,de,en,es,fr,hr,hu,it,nl,pl,pt,ro,ru,sl,sr,sv,uk"
403
+ link: https://huggingface.co/datasets/OpenAssistant/oasst_top1_2023-08-25
404
+
405
+ model:
406
+ - Open-Orca/Mistral-7B-OpenOrca
407
+ Link:
408
+ https://huggingface.co/Open-Orca/Mistral-7B-OpenOrca
409
+
410
+ 100 examples of generating:
411
+ - Link:
412
+ https://huggingface.co/NickyNicky/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v2/blob/main/output.xlsx
413
+
414
+ Activated training with:
415
+ - Link:
416
+ https://huggingface.co/blog/tomaarsen/attention-sinks
417
+ https://github.com/tomaarsen/attention_sinks
418
+ https://arxiv.org/abs/2309.17453
419
+
420
+ Version:
421
+ - Link:
422
+ https://huggingface.co/NickyNicky/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v1
423
+ https://huggingface.co/NickyNicky/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v3
424
+
425
+ ```
426
+
427
+
428
+ ##
429
+
430
+
431
+ ```py
432
+ # attention-sinks
433
+ pip install attention_sinks
434
+
435
+ # flash-attn
436
+ !export CUDA_HOME=/usr/local/cuda-11.8
437
+ !MAX_JOBS=4 pip install flash-attn --no-build-isolation -qqq
438
+ !pip install git+"https://github.com/HazyResearch/flash-attention.git#subdirectory=csrc/rotary" -qqq
439
+ ```
440
+
441
+
442
+ ## Version
443
+ ```py
444
+ import torch, transformers,torchvision
445
+ torch.__version__,transformers.__version__, torchvision.__version__
446
+ #OUTPUTS: ('2.0.1+cu118', '4.34.0.dev0', '0.15.2+cu118')
447
+ ```
448
+
449
+ ## How to use
450
+ ```py
451
+
452
+ from transformers import (
453
+ AutoModelForCausalLM,
454
+ AutoTokenizer,
455
+ BitsAndBytesConfig,
456
+ HfArgumentParser,
457
+ TrainingArguments,
458
+ pipeline,
459
+ logging,
460
+ GenerationConfig,
461
+ TextIteratorStreamer,
462
+ )
463
+
464
+ from attention_sinks import AutoModelForCausalLM
465
+
466
+ import torch
467
+
468
+ # model_id = 'Open-Orca/Mistral-7B-OpenOrca'
469
+ model_id='NickyNicky/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v2'
470
+
471
+ model = AutoModelForCausalLM.from_pretrained(model_id,
472
+ device_map="auto",
473
+ trust_remote_code=True,
474
+ torch_dtype=torch.bfloat16,
475
+ load_in_4bit=True,
476
+ low_cpu_mem_usage= True,
477
+
478
+ attention_sink_size=4,
479
+ attention_sink_window_size=1024, #512, # <- Low for the sake of faster generation
480
+ )
481
+
482
+ max_length=2048
483
+ print("max_length",max_length)
484
+
485
+
486
+ tokenizer = AutoTokenizer.from_pretrained(model_id,
487
+ # use_fast = False,
488
+ max_length=max_length,)
489
+
490
+ tokenizer.pad_token = tokenizer.eos_token
491
+ tokenizer.padding_side = 'right'
492
+
493
+ #EXAMPLE #1
494
+ txt="""<|im_start|>user
495
+ I'm looking for an efficient Python script to output prime numbers. Can you help me out? I'm interested in a script that can handle large numbers and output them quickly. Also, it would be great if the script could take a range of numbers as input and output all the prime numbers within that range. Can you generate a script that fits these requirements? Thanks!<|im_end|>
496
+ <|im_start|>assistant
497
+ """
498
+
499
+ #EXAMPLE #2
500
+ txt="""<|im_start|>user
501
+ Estoy desarrollando una REST API con Nodejs, y estoy tratando de aplicar algún sistema de seguridad, ya sea con tokens o algo similar, me puedes ayudar?<|im_end|>
502
+ <|im_start|>assistant
503
+ """
504
+
505
+ inputs = tokenizer.encode(txt, return_tensors="pt").to("cuda")
506
+
507
+ generation_config = GenerationConfig(
508
+ max_new_tokens=max_new_tokens,
509
+ temperature=0.7,
510
+ top_p=0.9,
511
+ top_k=len_tokens,
512
+ repetition_penalty=1.11,
513
+ do_sample=True,
514
+ # pad_token_id=tokenizer.eos_token_id,
515
+ # eos_token_id=tokenizer.eos_token_id,
516
+ # use_cache=True,
517
+ # stopping_criteria= StoppingCriteriaList([stopping_criteria]),
518
+ )
519
+ outputs = model.generate(generation_config=generation_config,
520
+ input_ids=inputs,)
521
+ tokenizer.decode(outputs[0], skip_special_tokens=False) #True
522
+ ```