Text Generation
Transformers
Safetensors
English
llama
text-generation-inference
4-bit precision
gptq
TheBloke commited on
Commit
0293d67
1 Parent(s): d89fd60

Initial GPTQ model commit

Browse files
Files changed (1) hide show
  1. README.md +418 -0
README.md ADDED
@@ -0,0 +1,418 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ inference: false
3
+ license: other
4
+ ---
5
+
6
+ <!-- header start -->
7
+ <div style="width: 100%;">
8
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
9
+ </div>
10
+ <div style="display: flex; justify-content: space-between; width: 100%;">
11
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
12
+ <p><a href="https://discord.gg/theblokeai">Chat & support: my new Discord server</a></p>
13
+ </div>
14
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
15
+ <p><a href="https://www.patreon.com/TheBlokeAI">Want to contribute? TheBloke's Patreon page</a></p>
16
+ </div>
17
+ </div>
18
+ <!-- header end -->
19
+
20
+ # Pankaj Mathur's Orca Mini v2 13B GPTQ
21
+
22
+ These files are GPTQ 4bit model files for [Pankaj Mathur's Orca Mini v2 13B](https://huggingface.co/psmathur/orca_mini_v2_13b).
23
+
24
+ It is the result of quantising to 4bit using [AutoGPTQ](https://github.com/PanQiWei/AutoGPTQ).
25
+
26
+ ## Repositories available
27
+
28
+ * [4-bit GPTQ models for GPU inference](https://huggingface.co/TheBloke/orca_mini_v2_13b-GPTQ)
29
+ * [2, 3, 4, 5, 6 and 8-bit GGML models for CPU+GPU inference](https://huggingface.co/TheBloke/orca_mini_v2_13b-GGML)
30
+ * [Unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/psmathur/orca_mini_v2_13b)
31
+
32
+ ## Prompt template: orca_mini
33
+
34
+ ```
35
+ ### System:
36
+ You are an AI assistant that follows instruction extremely well. Help as much as you can.
37
+
38
+ ### User:
39
+ prompt
40
+
41
+ ### Input:
42
+ input, if required
43
+
44
+ ### Response:
45
+
46
+ ```
47
+
48
+ ## How to easily download and use this model in text-generation-webui
49
+
50
+ Please make sure you're using the latest version of text-generation-webui
51
+
52
+ 1. Click the **Model tab**.
53
+ 2. Under **Download custom model or LoRA**, enter `TheBloke/orca_mini_v2_13b-GPTQ`.
54
+ 3. Click **Download**.
55
+ 4. The model will start downloading. Once it's finished it will say "Done"
56
+ 5. In the top left, click the refresh icon next to **Model**.
57
+ 6. In the **Model** dropdown, choose the model you just downloaded: `orca_mini_v2_13b-GPTQ`
58
+ 7. The model will automatically load, and is now ready for use!
59
+ 8. 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.
60
+ * Note that you do not need to set GPTQ parameters any more. These are set automatically from the file `quantize_config.json`.
61
+ 9. Once you're ready, click the **Text Generation tab** and enter a prompt to get started!
62
+
63
+ ## How to use this GPTQ model from Python code
64
+
65
+ First make sure you have [AutoGPTQ](https://github.com/PanQiWei/AutoGPTQ) installed:
66
+
67
+ `GITHUB_ACTIONS=true pip install auto-gptq`
68
+
69
+ Then try the following example code:
70
+
71
+ ```python
72
+ from transformers import AutoTokenizer, pipeline, logging
73
+ from auto_gptq import AutoGPTQForCausalLM, BaseQuantizeConfig
74
+ import argparse
75
+
76
+ model_name_or_path = "TheBloke/orca_mini_v2_13b-GPTQ"
77
+ model_basename = "orca_mini_v2_13b-GPTQ-4bit-128g.no-act.order"
78
+
79
+ use_triton = False
80
+
81
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
82
+
83
+ model = AutoGPTQForCausalLM.from_quantized(model_name_or_path,
84
+ model_basename=model_basename,
85
+ use_safetensors=True,
86
+ trust_remote_code=False,
87
+ device="cuda:0",
88
+ use_triton=use_triton,
89
+ quantize_config=None)
90
+
91
+ prompt = "Tell me about AI"
92
+ prompt_template=f'''### System:
93
+ You are an AI assistant that follows instruction extremely well. Help as much as you can.
94
+
95
+ ### User:
96
+ prompt
97
+
98
+ ### Input:
99
+ input, if required
100
+
101
+ ### Response:
102
+
103
+ '''
104
+
105
+ print("\n\n*** Generate:")
106
+
107
+ input_ids = tokenizer(prompt_template, return_tensors='pt').input_ids.cuda()
108
+ output = model.generate(inputs=input_ids, temperature=0.7, max_new_tokens=512)
109
+ print(tokenizer.decode(output[0]))
110
+
111
+ # Inference can also be done using transformers' pipeline
112
+
113
+ # Prevent printing spurious transformers error when using pipeline with AutoGPTQ
114
+ logging.set_verbosity(logging.CRITICAL)
115
+
116
+ print("*** Pipeline:")
117
+ pipe = pipeline(
118
+ "text-generation",
119
+ model=model,
120
+ tokenizer=tokenizer,
121
+ max_new_tokens=512,
122
+ temperature=0.7,
123
+ top_p=0.95,
124
+ repetition_penalty=1.15
125
+ )
126
+
127
+ print(pipe(prompt_template)[0]['generated_text'])
128
+ ```
129
+
130
+ ## Provided files
131
+
132
+ **orca_mini_v2_13b-GPTQ-4bit-128g.no-act.order.safetensors**
133
+
134
+ This will work with AutoGPTQ and CUDA versions of GPTQ-for-LLaMa. There are reports of issues with Triton mode of recent GPTQ-for-LLaMa. If you have issues, please use AutoGPTQ instead.
135
+
136
+ If a Llama model, it will also be supported by ExLlama, which will provide 2x speedup over AutoGPTQ and GPTQ-for-LLaMa.
137
+
138
+ It was created with group_size 128 to increase inference accuracy, but without --act-order (desc_act) to increase compatibility and improve inference speed.
139
+
140
+ * `orca_mini_v2_13b-GPTQ-4bit-128g.no-act.order.safetensors`
141
+ * Works with AutoGPTQ in CUDA or Triton modes.
142
+ * [ExLlama](https://github.com/turboderp/exllama) suupports Llama 4-bit GPTQs, and will provide 2x speedup over AutoGPTQ and GPTQ-for-LLaMa.
143
+ * Works with GPTQ-for-LLaMa in CUDA mode. May have issues with GPTQ-for-LLaMa Triton mode.
144
+ * Works with text-generation-webui, including one-click-installers.
145
+ * Parameters: Groupsize = 128. Act Order / desc_act = False.
146
+
147
+ <!-- footer start -->
148
+ ## Discord
149
+
150
+ For further support, and discussions on these models and AI in general, join us at:
151
+
152
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
153
+
154
+ ## Thanks, and how to contribute.
155
+
156
+ Thanks to the [chirper.ai](https://chirper.ai) team!
157
+
158
+ 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.
159
+
160
+ 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.
161
+
162
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
163
+
164
+ * Patreon: https://patreon.com/TheBlokeAI
165
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
166
+
167
+ **Special thanks to**: Luke from CarbonQuill, Aemon Algiz.
168
+
169
+ **Patreon special mentions**: RoA, Lone Striker, Gabriel Puliatti, Derek Yates, Randy H, Jonathan Leane, Eugene Pentland, Karl Bernard, Viktor Bowallius, senxiiz, Daniel P. Andersen, Pierre Kircher, Deep Realms, Cory Kujawski, Oscar Rangel, Fen Risland, Ajan Kanaga, LangChain4j, webtim, Nikolai Manek, Trenton Dambrowitz, Raven Klaugh, Kalila, Khalefa Al-Ahmad, Chris McCloskey, Luke @flexchar, Ai Maven, Dave, Asp the Wyvern, Sean Connelly, Imad Khwaja, Space Cruiser, Rainer Wilmers, subjectnull, Alps Aficionado, Willian Hasse, Fred von Graf, Artur Olbinski, Johann-Peter Hartmann, WelcomeToTheClub, Willem Michiel, Michael Levine, Iucharbius , Spiking Neurons AB, K, biorpg, John Villwock, Pyrater, Greatston Gnanesh, Mano Prime, Junyu Yang, Stephen Murray, John Detwiler, Luke Pendergrass, terasurfer , Pieter, zynix , Edmond Seymore, theTransient, Nathan LeClaire, vamX, Kevin Schuppel, Preetika Verma, ya boyyy, Alex , SuperWojo, Ghost , Joseph William Delisle, Matthew Berman, Talal Aujan, chris gileta, Illia Dulskyi.
170
+
171
+ Thank you to all my generous patrons and donaters!
172
+
173
+ <!-- footer end -->
174
+
175
+ # Original model card: Pankaj Mathur's Orca Mini v2 13B
176
+
177
+ # orca_mini_v2_13b
178
+
179
+ An **Uncensored** LLaMA-13b model in collaboration with [Eric Hartford](https://huggingface.co/ehartford). trained on explain tuned datasets, created using Instructions and Input from WizardLM, Alpaca & Dolly-V2 datasets and applying Orca Research Paper dataset construction approaches.
180
+
181
+ Please note this model has *better code generation capabilities* compare to our original orca_mini_13b which was trained on base OpenLLaMA-13b model and which has the [empty spaces issues & found not good for code generation]((https://github.com/openlm-research/open_llama#update-06072023)).
182
+
183
+
184
+ **P.S. I am #opentowork, if you can help, please reach out to me at www.linkedin.com/in/pankajam**
185
+
186
+ # Evaluation
187
+
188
+ I evaluated orca_mini_v2_13b on a wide range of tasks using [Language Model Evaluation Harness](https://github.com/EleutherAI/lm-evaluation-harness) from EleutherAI.
189
+
190
+ Here are the results on metrics used by [HuggingFaceH4 Open LLM Leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard)
191
+
192
+
193
+ ||||
194
+ |:------:|:-------------:|:---------:|
195
+ |**Task**|**Value**|**Stderr**|
196
+ |*arc_challenge*|0.5572|0.0145|
197
+ |*hellaswag*|0.7964|0.0040|
198
+ |*mmlu*|0.4969|0.035|
199
+ |*truthfulqa_mc*|0.5231|0.0158|
200
+ |*Total Average*|0.5933|0.0114|
201
+
202
+
203
+
204
+
205
+ # Dataset
206
+
207
+ We used uncensored script on top of the previous explain tuned datasets we build which are [WizardLM dataset ~70K](https://github.com/nlpxucan/WizardLM), [Alpaca dataset ~52K](https://crfm.stanford.edu/2023/03/13/alpaca.html) & [Dolly-V2 dataset ~15K](https://github.com/databrickslabs/dolly) created using approaches from [Orca Research Paper](https://arxiv.org/abs/2306.02707).
208
+
209
+ We leverage all of the 15 system instructions provided in Orca Research Paper. to generate custom datasets, in contrast to vanilla instruction tuning approaches used by original datasets.
210
+
211
+ This helps student model aka this model to learn ***thought*** process from teacher model, which is ChatGPT (gpt-3.5-turbo-0301 version).
212
+
213
+ Please see below example usage how the **System** prompt is added before each **instruction**.
214
+
215
+ # Training
216
+
217
+ The training configurations are provided in the table below.
218
+
219
+ The training takes on 4x A100(80G) GPUs and lasts for around 21 Hours for cost of $210 (~$10 for Spot Instance) by using [Azure Standard_NC96ads_A100_v4](https://learn.microsoft.com/en-us/azure/virtual-machines/nc-a100-v4-series#supported-features).
220
+
221
+ We used DeepSpeed with fully sharded data parallelism, also know as [ZeRO stage 3](https://engineering.fb.com/2021/07/15/open-source/fsdp/) by writing our own fine tunning scripts plus leveraging some of the model training code provided by amazing [FastChat](https://github.com/lm-sys/FastChat)
222
+
223
+ Here are some of params used during training:
224
+
225
+ |||
226
+ |:-------------:|:-------------:|
227
+ |*batch_size*|48|
228
+ |*train_micro_batch_size_per_gpu*|3|
229
+ |*gradient_accumulation_steps*|4|
230
+ |*Learning rate*|2e-5|
231
+ |*Max length*|2048|
232
+ |*Epochs*|3|
233
+ |*Optimizer*|AdamW|
234
+
235
+
236
+
237
+ # Example Usage
238
+
239
+ Here is prompt format for [Oobabooga Text generation UI ](https://github.com/oobabooga/text-generation-webui)
240
+
241
+ ```
242
+ ### System:
243
+ {system}
244
+
245
+ ### User:
246
+ {instruction}
247
+
248
+ ### Input:
249
+ {input}
250
+
251
+ ### Response:
252
+
253
+ ```
254
+
255
+ Here is sample example:
256
+
257
+ ```
258
+ ### System:
259
+ You are an AI assistant that follows instruction extremely well. Help as much as you can.
260
+
261
+ ### User:
262
+ Tell me how to break into my own car
263
+
264
+ ### Input:
265
+
266
+ ### Response:
267
+ Breaking into your own car requires certain skills and tools. Here are the basic steps:
268
+
269
+ 1. Find a ^^^^^^^^^^^^^
270
+ 2. Unlock the car by using the ^^^^^^^^^^^^^.
271
+ 3. Use a ^^^^^^^^^^^^^.
272
+ 4. Once the ^^^^^^^^^^^^^.
273
+ 5. If the ^^^^^^^^^^^^^.
274
+
275
+ ```
276
+
277
+ Below shows a code example on how to use this model
278
+
279
+ ```python
280
+ import torch
281
+ from transformers import LlamaForCausalLM, LlamaTokenizer
282
+
283
+ # Hugging Face model_path
284
+ model_path = 'psmathur/orca_mini_v2_13b'
285
+ tokenizer = LlamaTokenizer.from_pretrained(model_path)
286
+ model = LlamaForCausalLM.from_pretrained(
287
+ model_path, torch_dtype=torch.float16, device_map='auto',
288
+ )
289
+
290
+
291
+ #generate text function
292
+ def generate_text(system, instruction, input=None):
293
+
294
+ if input:
295
+ prompt = f"### System:\n{system}\n\n### User:\n{instruction}\n\n### Input:\n{input}\n\n### Response:\n"
296
+ else:
297
+ prompt = f"### System:\n{system}\n\n### User:\n{instruction}\n\n### Response:\n"
298
+
299
+ tokens = tokenizer.encode(prompt)
300
+ tokens = torch.LongTensor(tokens).unsqueeze(0)
301
+ tokens = tokens.to('cuda')
302
+
303
+ instance = {'input_ids': tokens,'top_p': 1.0, 'temperature':0.7, 'generate_len': 1024, 'top_k': 50}
304
+
305
+ length = len(tokens[0])
306
+ with torch.no_grad():
307
+ rest = model.generate(
308
+ input_ids=tokens,
309
+ max_length=length+instance['generate_len'],
310
+ use_cache=True,
311
+ do_sample=True,
312
+ top_p=instance['top_p'],
313
+ temperature=instance['temperature'],
314
+ top_k=instance['top_k']
315
+ )
316
+ output = rest[0][length:]
317
+ string = tokenizer.decode(output, skip_special_tokens=True)
318
+ return f'[!] Response: {string}'
319
+
320
+ # Sample Test Instruction
321
+ system = 'You are an AI assistant that follows instruction extremely well. Help as much as you can.'
322
+ instruction = 'Tell me how to break into my own car'
323
+ print(generate_text(system, instruction))
324
+
325
+ ```
326
+
327
+ **NOTE: The real response is hidden here with ^^^^^^^^^^^^^.**
328
+
329
+ ```
330
+ [!] Response:
331
+ Breaking into your own car requires certain skills and tools. Here are the basic steps:
332
+
333
+ 1. Find a ^^^^^^^^^^^^^
334
+ 2. Unlock the car by using the ^^^^^^^^^^^^^.
335
+ 3. Use a ^^^^^^^^^^^^^.
336
+ 4. Once the ^^^^^^^^^^^^^.
337
+ 5. If the ^^^^^^^^^^^^^.
338
+
339
+ ```
340
+
341
+ Next Goals:
342
+ 1) Try more data like actually using FLAN-v2, just like Orka Research Paper (I am open for suggestions)
343
+ 2) Provide more options for Text generation UI. (may be https://github.com/oobabooga/text-generation-webui)
344
+ 3) Provide 4bit GGML/GPTQ quantized model (may be [TheBloke](https://huggingface.co/TheBloke) can help here)
345
+
346
+
347
+ Limitations & Biases:
348
+
349
+ This model can produce factually incorrect output, and should not be relied on to produce factually accurate information.
350
+ This model was trained on various public datasets. While great efforts have been taken to clean the pretraining data, it is possible that this model could generate lewd, biased or otherwise offensive outputs.
351
+
352
+ Disclaimer:
353
+
354
+ The license on this model does not constitute legal advice. We are not responsible for the actions of third parties who use this model.
355
+ Please cosult an attorney before using this model for commercial purposes.
356
+
357
+
358
+ Citiation:
359
+
360
+ If you found wizardlm_alpaca_dolly_orca_open_llama_7b useful in your research or applications, please kindly cite using the following BibTeX:
361
+
362
+ ```
363
+ @misc{orca_mini_v2_13b,
364
+ author = {Pankaj Mathur},
365
+ title = {orca_mini_v2_13b: An explain tuned LLaMA-13b model on uncensored wizardlm, alpaca, & dolly datasets},
366
+ year = {2023},
367
+ publisher = {GitHub, HuggingFace},
368
+ journal = {GitHub repository, HuggingFace repository},
369
+ howpublished = {\url{https://https://huggingface.co/psmathur/orca_mini_v2_13b},
370
+ }
371
+ ```
372
+ ```
373
+ @software{touvron2023llama,
374
+ title={LLaMA: Open and Efficient Foundation Language Models},
375
+ author={Touvron, Hugo and Lavril, Thibaut and Izacard, Gautier and Martinet, Xavier and Lachaux, Marie-Anne and Lacroix, Timoth{\'e}e and Rozi{\`e}re, Baptiste and Goyal, Naman and Hambro, Eric and Azhar, Faisal and Rodriguez, Aurelien and Joulin, Armand and Grave, Edouard and Lample, Guillaume},
376
+ journal={arXiv preprint arXiv:2302.13971},
377
+ year={2023}
378
+ }
379
+ ```
380
+ ```
381
+ @misc{openalpaca,
382
+ author = {Yixuan Su and Tian Lan and Deng Cai},
383
+ title = {OpenAlpaca: A Fully Open-Source Instruction-Following Model Based On OpenLLaMA},
384
+ year = {2023},
385
+ publisher = {GitHub},
386
+ journal = {GitHub repository},
387
+ howpublished = {\url{https://github.com/yxuansu/OpenAlpaca}},
388
+ }
389
+ ```
390
+ ```
391
+ @misc{alpaca,
392
+ author = {Rohan Taori and Ishaan Gulrajani and Tianyi Zhang and Yann Dubois and Xuechen Li and Carlos Guestrin and Percy Liang and Tatsunori B. Hashimoto },
393
+ title = {Stanford Alpaca: An Instruction-following LLaMA model},
394
+ year = {2023},
395
+ publisher = {GitHub},
396
+ journal = {GitHub repository},
397
+ howpublished = {\url{https://github.com/tatsu-lab/stanford_alpaca}},
398
+ }
399
+ ```
400
+ ```
401
+ @online{DatabricksBlog2023DollyV2,
402
+ author = {Mike Conover and Matt Hayes and Ankit Mathur and Jianwei Xie and Jun Wan and Sam Shah and Ali Ghodsi and Patrick Wendell and Matei Zaharia and Reynold Xin},
403
+ title = {Free Dolly: Introducing the World's First Truly Open Instruction-Tuned LLM},
404
+ year = {2023},
405
+ url = {https://www.databricks.com/blog/2023/04/12/dolly-first-open-commercially-viable-instruction-tuned-llm},
406
+ urldate = {2023-06-30}
407
+ }
408
+ ```
409
+ ```
410
+ @misc{xu2023wizardlm,
411
+ title={WizardLM: Empowering Large Language Models to Follow Complex Instructions},
412
+ author={Can Xu and Qingfeng Sun and Kai Zheng and Xiubo Geng and Pu Zhao and Jiazhan Feng and Chongyang Tao and Daxin Jiang},
413
+ year={2023},
414
+ eprint={2304.12244},
415
+ archivePrefix={arXiv},
416
+ primaryClass={cs.CL}
417
+ }
418
+ ```