TheBloke commited on
Commit
d425df4
1 Parent(s): 87d5862

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +487 -0
README.md ADDED
@@ -0,0 +1,487 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: NickyNicky/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v1
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 v1
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 v1 - AWQ
66
+ - Model creator: [Nicky](https://huggingface.co/NickyNicky)
67
+ - Original model: [Mistral 7B OpenOrca oasst Top1 2023 08 25 v1](https://huggingface.co/NickyNicky/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v1)
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 v1](https://huggingface.co/NickyNicky/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v1).
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
+ It is supported by:
82
+
83
+ - [Text Generation Webui](https://github.com/oobabooga/text-generation-webui) - using Loader: AutoAWQ
84
+ - [vLLM](https://github.com/vllm-project/vllm) - Llama and Mistral models only
85
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference)
86
+ - [Transformers](https://huggingface.co/docs/transformers) version 4.35.0 and later, from any code or client that supports Transformers
87
+ - [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) - for use from Python code
88
+
89
+ <!-- description end -->
90
+ <!-- repositories-available start -->
91
+ ## Repositories available
92
+
93
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v1-AWQ)
94
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v1-GPTQ)
95
+ * [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-v1-GGUF)
96
+ * [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-v1)
97
+ <!-- repositories-available end -->
98
+
99
+ <!-- prompt-template start -->
100
+ ## Prompt template: ChatML
101
+
102
+ ```
103
+ <|im_start|>system
104
+ {system_message}<|im_end|>
105
+ <|im_start|>user
106
+ {prompt}<|im_end|>
107
+ <|im_start|>assistant
108
+
109
+ ```
110
+
111
+ <!-- prompt-template end -->
112
+
113
+
114
+ <!-- README_AWQ.md-provided-files start -->
115
+ ## Provided files, and AWQ parameters
116
+
117
+ I currently release 128g GEMM models only. The addition of group_size 32 models, and GEMV kernel models, is being actively considered.
118
+
119
+ Models are released as sharded safetensors files.
120
+
121
+ | Branch | Bits | GS | AWQ Dataset | Seq Len | Size |
122
+ | ------ | ---- | -- | ----------- | ------- | ---- |
123
+ | [main](https://huggingface.co/TheBloke/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v1-AWQ/tree/main) | 4 | 128 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-v1/test) | 4096 | 4.15 GB
124
+
125
+ <!-- README_AWQ.md-provided-files end -->
126
+
127
+ <!-- README_AWQ.md-text-generation-webui start -->
128
+ ## How to easily download and use this model in [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
129
+
130
+ Please make sure you're using the latest version of [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
131
+
132
+ 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.
133
+
134
+ 1. Click the **Model tab**.
135
+ 2. Under **Download custom model or LoRA**, enter `TheBloke/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v1-AWQ`.
136
+ 3. Click **Download**.
137
+ 4. The model will start downloading. Once it's finished it will say "Done".
138
+ 5. In the top left, click the refresh icon next to **Model**.
139
+ 6. In the **Model** dropdown, choose the model you just downloaded: `Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v1-AWQ`
140
+ 7. Select **Loader: AutoAWQ**.
141
+ 8. Click Load, and the model will load and is now ready for use.
142
+ 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.
143
+ 10. Once you're ready, click the **Text Generation** tab and enter a prompt to get started!
144
+ <!-- README_AWQ.md-text-generation-webui end -->
145
+
146
+ <!-- README_AWQ.md-use-from-vllm start -->
147
+ ## Multi-user inference server: vLLM
148
+
149
+ Documentation on installing and using vLLM [can be found here](https://vllm.readthedocs.io/en/latest/).
150
+
151
+ - Please ensure you are using vLLM version 0.2 or later.
152
+ - When using vLLM as a server, pass the `--quantization awq` parameter.
153
+
154
+ For example:
155
+
156
+ ```shell
157
+ python3 -m vllm.entrypoints.api_server --model TheBloke/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v1-AWQ --quantization awq --dtype auto
158
+ ```
159
+
160
+ - When using vLLM from Python code, again set `quantization=awq`.
161
+
162
+ For example:
163
+
164
+ ```python
165
+ from vllm import LLM, SamplingParams
166
+
167
+ prompts = [
168
+ "Tell me about AI",
169
+ "Write a story about llamas",
170
+ "What is 291 - 150?",
171
+ "How much wood would a woodchuck chuck if a woodchuck could chuck wood?",
172
+ ]
173
+ prompt_template=f'''<|im_start|>system
174
+ {system_message}<|im_end|>
175
+ <|im_start|>user
176
+ {prompt}<|im_end|>
177
+ <|im_start|>assistant
178
+ '''
179
+
180
+ prompts = [prompt_template.format(prompt=prompt) for prompt in prompts]
181
+
182
+ sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
183
+
184
+ llm = LLM(model="TheBloke/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v1-AWQ", quantization="awq", dtype="auto")
185
+
186
+ outputs = llm.generate(prompts, sampling_params)
187
+
188
+ # Print the outputs.
189
+ for output in outputs:
190
+ prompt = output.prompt
191
+ generated_text = output.outputs[0].text
192
+ print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
193
+ ```
194
+ <!-- README_AWQ.md-use-from-vllm start -->
195
+
196
+ <!-- README_AWQ.md-use-from-tgi start -->
197
+ ## Multi-user inference server: Hugging Face Text Generation Inference (TGI)
198
+
199
+ Use TGI version 1.1.0 or later. The official Docker container is: `ghcr.io/huggingface/text-generation-inference:1.1.0`
200
+
201
+ Example Docker parameters:
202
+
203
+ ```shell
204
+ --model-id TheBloke/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v1-AWQ --port 3000 --quantize awq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
205
+ ```
206
+
207
+ Example Python code for interfacing with TGI (requires [huggingface-hub](https://github.com/huggingface/huggingface_hub) 0.17.0 or later):
208
+
209
+ ```shell
210
+ pip3 install huggingface-hub
211
+ ```
212
+
213
+ ```python
214
+ from huggingface_hub import InferenceClient
215
+
216
+ endpoint_url = "https://your-endpoint-url-here"
217
+
218
+ prompt = "Tell me about AI"
219
+ prompt_template=f'''<|im_start|>system
220
+ {system_message}<|im_end|>
221
+ <|im_start|>user
222
+ {prompt}<|im_end|>
223
+ <|im_start|>assistant
224
+ '''
225
+
226
+ client = InferenceClient(endpoint_url)
227
+ response = client.text_generation(prompt,
228
+ max_new_tokens=128,
229
+ do_sample=True,
230
+ temperature=0.7,
231
+ top_p=0.95,
232
+ top_k=40,
233
+ repetition_penalty=1.1)
234
+
235
+ print(f"Model output: ", response)
236
+ ```
237
+ <!-- README_AWQ.md-use-from-tgi end -->
238
+
239
+ <!-- README_AWQ.md-use-from-python start -->
240
+ ## Inference from Python code using Transformers
241
+
242
+ ### Install the necessary packages
243
+
244
+ - Requires: [Transformers](https://huggingface.co/docs/transformers) 4.35.0 or later.
245
+ - Requires: [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) 0.1.6 or later.
246
+
247
+ ```shell
248
+ pip3 install --upgrade "autoawq>=0.1.6" "transformers>=4.35.0"
249
+ ```
250
+
251
+ Note that if you are using PyTorch 2.0.1, the above AutoAWQ command will automatically upgrade you to PyTorch 2.1.0.
252
+
253
+ If you are using CUDA 11.8 and wish to continue using PyTorch 2.0.1, instead run this command:
254
+
255
+ ```shell
256
+ pip3 install https://github.com/casper-hansen/AutoAWQ/releases/download/v0.1.6/autoawq-0.1.6+cu118-cp310-cp310-linux_x86_64.whl
257
+ ```
258
+
259
+ If you have problems installing [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) using the pre-built wheels, install it from source instead:
260
+
261
+ ```shell
262
+ pip3 uninstall -y autoawq
263
+ git clone https://github.com/casper-hansen/AutoAWQ
264
+ cd AutoAWQ
265
+ pip3 install .
266
+ ```
267
+
268
+ ### Transformers example code (requires Transformers 4.35.0 and later)
269
+
270
+ ```python
271
+ from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
272
+
273
+ model_name_or_path = "TheBloke/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v1-AWQ"
274
+
275
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
276
+ model = AutoModelForCausalLM.from_pretrained(
277
+ model_name_or_path,
278
+ low_cpu_mem_usage=True,
279
+ device_map="cuda:0"
280
+ )
281
+
282
+ # Using the text streamer to stream output one token at a time
283
+ streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
284
+
285
+ prompt = "Tell me about AI"
286
+ prompt_template=f'''<|im_start|>system
287
+ {system_message}<|im_end|>
288
+ <|im_start|>user
289
+ {prompt}<|im_end|>
290
+ <|im_start|>assistant
291
+ '''
292
+
293
+ # Convert prompt to tokens
294
+ tokens = tokenizer(
295
+ prompt_template,
296
+ return_tensors='pt'
297
+ ).input_ids.cuda()
298
+
299
+ generation_params = {
300
+ "do_sample": True,
301
+ "temperature": 0.7,
302
+ "top_p": 0.95,
303
+ "top_k": 40,
304
+ "max_new_tokens": 512,
305
+ "repetition_penalty": 1.1
306
+ }
307
+
308
+ # Generate streamed output, visible one token at a time
309
+ generation_output = model.generate(
310
+ tokens,
311
+ streamer=streamer,
312
+ **generation_params
313
+ )
314
+
315
+ # Generation without a streamer, which will include the prompt in the output
316
+ generation_output = model.generate(
317
+ tokens,
318
+ **generation_params
319
+ )
320
+
321
+ # Get the tokens from the output, decode them, print them
322
+ token_output = generation_output[0]
323
+ text_output = tokenizer.decode(token_output)
324
+ print("model.generate output: ", text_output)
325
+
326
+ # Inference is also possible via Transformers' pipeline
327
+ from transformers import pipeline
328
+
329
+ pipe = pipeline(
330
+ "text-generation",
331
+ model=model,
332
+ tokenizer=tokenizer,
333
+ **generation_params
334
+ )
335
+
336
+ pipe_output = pipe(prompt_template)[0]['generated_text']
337
+ print("pipeline output: ", pipe_output)
338
+
339
+ ```
340
+ <!-- README_AWQ.md-use-from-python end -->
341
+
342
+ <!-- README_AWQ.md-compatibility start -->
343
+ ## Compatibility
344
+
345
+ The files provided are tested to work with:
346
+
347
+ - [text-generation-webui](https://github.com/oobabooga/text-generation-webui) using `Loader: AutoAWQ`.
348
+ - [vLLM](https://github.com/vllm-project/vllm) version 0.2.0 and later.
349
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference) version 1.1.0 and later.
350
+ - [Transformers](https://huggingface.co/docs/transformers) version 4.35.0 and later.
351
+ - [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) version 0.1.1 and later.
352
+
353
+ <!-- README_AWQ.md-compatibility end -->
354
+
355
+ <!-- footer start -->
356
+ <!-- 200823 -->
357
+ ## Discord
358
+
359
+ For further support, and discussions on these models and AI in general, join us at:
360
+
361
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
362
+
363
+ ## Thanks, and how to contribute
364
+
365
+ Thanks to the [chirper.ai](https://chirper.ai) team!
366
+
367
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
368
+
369
+ 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.
370
+
371
+ 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.
372
+
373
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
374
+
375
+ * Patreon: https://patreon.com/TheBlokeAI
376
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
377
+
378
+ **Special thanks to**: Aemon Algiz.
379
+
380
+ **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
381
+
382
+
383
+ Thank you to all my generous patrons and donaters!
384
+
385
+ And thank you again to a16z for their generous grant.
386
+
387
+ <!-- footer end -->
388
+
389
+ # Original model card: Nicky's Mistral 7B OpenOrca oasst Top1 2023 08 25 v1
390
+
391
+
392
+ ```
393
+ reference-data-model:
394
+
395
+ datasets:
396
+ - OpenAssistant/oasst_top1_2023-08-25:
397
+ Lang: "bg,ca,cs,da,de,en,es,fr,hr,hu,it,nl,pl,pt,ro,ru,sl,sr,sv,uk"
398
+ Link: https://huggingface.co/datasets/OpenAssistant/oasst_top1_2023-08-25
399
+
400
+ model:
401
+ - Open-Orca/Mistral-7B-OpenOrca
402
+ Link: https://huggingface.co/Open-Orca/Mistral-7B-OpenOrca
403
+
404
+ 100 examples of generating:
405
+ Link: https://docs.google.com/spreadsheets/d/1_4rqFnhgvjA7trwAaEidaRWczAMzuKpw/edit?usp=sharing&ouid=116592149115238887304&rtpof=true&sd=true
406
+
407
+ Version 2:
408
+ Link: https://huggingface.co/NickyNicky/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v2
409
+
410
+ ```
411
+
412
+
413
+ ## Version
414
+ ```py
415
+ import torch, transformers,torchvision
416
+ torch.__version__,transformers.__version__, torchvision.__version__
417
+ #OUTPUTS: ('2.0.1+cu118', '4.34.0.dev0', '0.15.2+cu118')
418
+ ```
419
+
420
+ ## How to use
421
+ ```py
422
+
423
+ from transformers import (
424
+ AutoModelForCausalLM,
425
+ AutoTokenizer,
426
+ BitsAndBytesConfig,
427
+ HfArgumentParser,
428
+ TrainingArguments,
429
+ pipeline,
430
+ logging,
431
+ GenerationConfig,
432
+ TextIteratorStreamer,
433
+ )
434
+ import torch
435
+
436
+ # model_id = 'Open-Orca/Mistral-7B-OpenOrca'
437
+ model_id='NickyNicky/Mistral-7B-OpenOrca-oasst_top1_2023-08-25-v1'
438
+
439
+ model = AutoModelForCausalLM.from_pretrained(model_id,
440
+ device_map="auto",
441
+ trust_remote_code=True,
442
+ torch_dtype=torch.bfloat16,
443
+ load_in_4bit=True,
444
+ low_cpu_mem_usage= True,
445
+ )
446
+
447
+ max_length=2048
448
+ print("max_length",max_length)
449
+
450
+
451
+ tokenizer = AutoTokenizer.from_pretrained(model_id,
452
+ # use_fast = False,
453
+ max_length=max_length,)
454
+
455
+ tokenizer.pad_token = tokenizer.eos_token
456
+ tokenizer.padding_side = 'right'
457
+
458
+ #EXAMPLE #1
459
+ txt="""<|im_start|>user
460
+ 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|>
461
+ <|im_start|>assistant
462
+ """
463
+
464
+ #EXAMPLE #2
465
+ txt="""<|im_start|>user
466
+ 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|>
467
+ <|im_start|>assistant
468
+ """
469
+
470
+ inputs = tokenizer.encode(txt, return_tensors="pt").to("cuda")
471
+
472
+ generation_config = GenerationConfig(
473
+ max_new_tokens=max_new_tokens,
474
+ temperature=0.7,
475
+ top_p=0.9,
476
+ top_k=len_tokens,
477
+ repetition_penalty=1.11,
478
+ do_sample=True,
479
+ # pad_token_id=tokenizer.eos_token_id,
480
+ # eos_token_id=tokenizer.eos_token_id,
481
+ # use_cache=True,
482
+ # stopping_criteria= StoppingCriteriaList([stopping_criteria]),
483
+ )
484
+ outputs = model.generate(generation_config=generation_config,
485
+ input_ids=inputs,)
486
+ tokenizer.decode(outputs[0], skip_special_tokens=False) #True
487
+ ```