TheBloke commited on
Commit
ffd7d8b
1 Parent(s): 0d85e4b

Initial GPTQ model commit

Browse files
Files changed (1) hide show
  1. README.md +404 -0
README.md ADDED
@@ -0,0 +1,404 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 7B GPTQ
21
+
22
+ These files are GPTQ 4bit model files for [Pankaj Mathur's Orca Mini v2 7B](https://huggingface.co/psmathur/orca_mini_v2_7b).
23
+
24
+ It is the result of quantising to 4bit using [GPTQ-for-LLaMa](https://github.com/qwopqwop200/GPTQ-for-LLaMa).
25
+
26
+ ## Repositories available
27
+
28
+ * [4-bit GPTQ models for GPU inference](https://huggingface.co/TheBloke/orca_mini_v2_7B-GPTQ)
29
+ * [2, 3, 4, 5, 6 and 8-bit GGML models for CPU+GPU inference](https://huggingface.co/TheBloke/orca_mini_v2_7B-GGML)
30
+ * [Unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/psmathur/orca_mini_v2_7b)
31
+
32
+ ## How to easily download and use this model in text-generation-webui
33
+
34
+ Please make sure you're using the latest version of text-generation-webui
35
+
36
+ 1. Click the **Model tab**.
37
+ 2. Under **Download custom model or LoRA**, enter `TheBloke/orca_mini_v2_7B-GPTQ`.
38
+ 3. Click **Download**.
39
+ 4. The model will start downloading. Once it's finished it will say "Done"
40
+ 5. In the top left, click the refresh icon next to **Model**.
41
+ 6. In the **Model** dropdown, choose the model you just downloaded: `orca_mini_v2_7B-GPTQ`
42
+ 7. The model will automatically load, and is now ready for use!
43
+ 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.
44
+ * Note that you do not need to and should not set manual GPTQ parameters any more. These are set automatically from the file `quantize_config.json`.
45
+ 9. Once you're ready, click the **Text Generation tab** and enter a prompt to get started!
46
+
47
+ ## How to use this GPTQ model from Python code
48
+
49
+ First make sure you have [AutoGPTQ](https://github.com/PanQiWei/AutoGPTQ) installed:
50
+
51
+ `pip install auto-gptq`
52
+
53
+ Then try the following example code:
54
+
55
+ ```python
56
+ from transformers import AutoTokenizer, pipeline, logging
57
+ from auto_gptq import AutoGPTQForCausalLM, BaseQuantizeConfig
58
+ import argparse
59
+
60
+ model_name_or_path = "TheBloke/orca_mini_v2_7B-GPTQ"
61
+ model_basename = "orca-mini-v2_7b-GPTQ-4bit-128g.no-act.order"
62
+
63
+ use_triton = False
64
+
65
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
66
+
67
+ model = AutoGPTQForCausalLM.from_quantized(model_name_or_path,
68
+ model_basename=model_basename,
69
+ use_safetensors=True,
70
+ trust_remote_code=False,
71
+ device="cuda:0",
72
+ use_triton=use_triton,
73
+ quantize_config=None)
74
+
75
+ # Note: check the prompt template is correct for this model.
76
+ prompt = "Tell me about AI"
77
+ prompt_template=f'''USER: {prompt}
78
+ ASSISTANT:'''
79
+
80
+ print("\n\n*** Generate:")
81
+
82
+ input_ids = tokenizer(prompt_template, return_tensors='pt').input_ids.cuda()
83
+ output = model.generate(inputs=input_ids, temperature=0.7, max_new_tokens=512)
84
+ print(tokenizer.decode(output[0]))
85
+
86
+ # Inference can also be done using transformers' pipeline
87
+
88
+ # Prevent printing spurious transformers error when using pipeline with AutoGPTQ
89
+ logging.set_verbosity(logging.CRITICAL)
90
+
91
+ print("*** Pipeline:")
92
+ pipe = pipeline(
93
+ "text-generation",
94
+ model=model,
95
+ tokenizer=tokenizer,
96
+ max_new_tokens=512,
97
+ temperature=0.7,
98
+ top_p=0.95,
99
+ repetition_penalty=1.15
100
+ )
101
+
102
+ print(pipe(prompt_template)[0]['generated_text'])
103
+ ```
104
+
105
+ ## Provided files
106
+
107
+ **orca-mini-v2_7b-GPTQ-4bit-128g.no-act.order.safetensors**
108
+
109
+ This will work with AutoGPTQ, ExLlama, 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.
110
+
111
+ It was created with group_size 128 to increase inference accuracy, but without --act-order (desc_act) to increase compatibility and improve inference speed.
112
+
113
+ * `orca-mini-v2_7b-GPTQ-4bit-128g.no-act.order.safetensors`
114
+ * Works with AutoGPTQ in CUDA or Triton modes.
115
+ * LLaMa models also work with [ExLlama](https://github.com/turboderp/exllama}, which usually provides much higher performance, and uses less VRAM, than AutoGPTQ.
116
+ * Works with GPTQ-for-LLaMa in CUDA mode. May have issues with GPTQ-for-LLaMa Triton mode.
117
+ * Works with text-generation-webui, including one-click-installers.
118
+ * Parameters: Groupsize = 128. Act Order / desc_act = False.
119
+
120
+ <!-- footer start -->
121
+ ## Discord
122
+
123
+ For further support, and discussions on these models and AI in general, join us at:
124
+
125
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
126
+
127
+ ## Thanks, and how to contribute.
128
+
129
+ Thanks to the [chirper.ai](https://chirper.ai) team!
130
+
131
+ 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.
132
+
133
+ 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.
134
+
135
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
136
+
137
+ * Patreon: https://patreon.com/TheBlokeAI
138
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
139
+
140
+ **Special thanks to**: Luke from CarbonQuill, Aemon Algiz.
141
+
142
+ **Patreon special mentions**: Spiking Neurons AB, Kevin Schuppel, Cory Kujawski, senxiiz, Luke Pendergrass, John Villwock, Ghost , Alex , Sean Connelly, Space Cruiser, Eugene Pentland, Pyrater, Matthew Berman, Dave, Derek Yates, Jonathan Leane, Viktor Bowallius, Michael Levine, Joseph William Delisle, Fred von Graf, Asp the Wyvern, Nikolai Manek, Pierre Kircher, webtim, K, RoA, Karl Bernard, Artur Olbinski, Rainer Wilmers, Ai Maven, Nathan LeClaire, Ajan Kanaga, Stephen Murray, Edmond Seymore, zynix , Imad Khwaja, John Detwiler, Randy H, subjectnull, Alps Aficionado, Greatston Gnanesh, Trenton Dambrowitz, Junyu Yang, Raven Klaugh, biorpg, Deep Realms, vamX, Talal Aujan, Johann-Peter Hartmann, WelcomeToTheClub, Chris McCloskey, Luke, chris gileta, terasurfer , Iucharbius , Preetika Verma, Willem Michiel, Fen Risland, SuperWojo, Khalefa Al-Ahmad, Daniel P. Andersen, Gabriel Puliatti, Illia Dulskyi, Willian Hasse, Oscar Rangel, ya boyyy, Mano Prime, Lone Striker, Kalila.
143
+
144
+ Thank you to all my generous patrons and donaters!
145
+
146
+ <!-- footer end -->
147
+
148
+ # Original model card: Pankaj Mathur's Orca Mini v2 7B
149
+
150
+ # orca_mini_v2_7b
151
+
152
+ An **Uncensored** LLaMA-7b 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.
153
+
154
+ Please note this model has *better code generation capabilities* compare to our original orca_mini_7b which was trained on base OpenLLaMA-7b model and which has the [empty spaces issues & found not good for code generation]((https://github.com/openlm-research/open_llama#update-06072023)).
155
+
156
+
157
+ **P.S. I am #opentowork, if you can help, please reach out to me at www.linkedin.com/in/pankajam**
158
+
159
+ # Evaluation
160
+
161
+ I evaluated orca_mini_v2_7b on a wide range of tasks using [Language Model Evaluation Harness](https://github.com/EleutherAI/lm-evaluation-harness) from EleutherAI.
162
+
163
+ Here are the zero shot metrics results.
164
+
165
+ |||||||
166
+ |:------:|:-------------:|:---------:|:--------:|:-------:|:--------:|
167
+ |**Task**|**num_fewshot**|**Version**|**Metric**|**Value**|**Stderr**|
168
+ |*arc_easy*|0|0|acc|0.7386|0.0090|
169
+ |*arc_easy*|0|0|acc_norm|0.7066|0.0093|
170
+ |*hellaswag*|0|0|acc|0.5591|0.0050|
171
+ |*hellaswag*|0|0|acc_norm|0.7394|0.0044|
172
+ |*truthfulqa_mc*|0|1|mc1|0.2938|0.0159|
173
+ |*truthfulqa_mc*|0|1|mc2|0.4399|0.0153|
174
+ |*mmlu avg*|0|1|acc|0.4108|0.0153|
175
+ |*mmlu avg*|0|1|acc_norm|0.4108|0.0153|
176
+ |*Total Zero Shot Average*|0|-|-|0.5373|0.011|
177
+
178
+
179
+ Here are the results on metrics used by [HuggingFaceH4 Open LLM Leaderboard](https://huggingface.co/spaces/HuggingFaceH4/open_llm_leaderboard)
180
+
181
+ please note num_fewshots varies for each below task as used by HuggingFaceH4 Open LLM Leaderboard
182
+
183
+ |||||||
184
+ |:------:|:-------------:|:---------:|:--------:|:-------:|:--------:|
185
+ |**Task**|**num_fewshot**|**Version**|**Metric**|**Value**|**Stderr**|
186
+ |*arc_challenge*|25|0|acc|0.4846|0.0146|
187
+ |*arc_challenge*|25|0|acc_norm|0.5077|0.0146|
188
+
189
+
190
+
191
+ # Dataset
192
+
193
+ 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).
194
+
195
+ 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.
196
+
197
+ This helps student model aka this model to learn ***thought*** process from teacher model, which is ChatGPT (gpt-3.5-turbo-0301 version).
198
+
199
+ Please see below example usage how the **System** prompt is added before each **instruction**.
200
+
201
+ # Training
202
+
203
+ The training configurations are provided in the table below.
204
+
205
+ The training takes on 8x A100(80G) GPUs and lasts for around 13 Hours for cost of $195 using [RunPods](https://www.runpod.io/)
206
+
207
+ 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 [OpenAlpaca repo](https://github.com/yxuansu/OpenAlpaca)
208
+
209
+ Here are some of params used during training:
210
+
211
+ |||
212
+ |:-------------:|:-------------:|
213
+ |*batch_size*|96|
214
+ |*train_micro_batch_size_per_gpu*|3|
215
+ |*gradient_accumulation_steps*|4|
216
+ |*Learning rate*|2e-5|
217
+ |*Max length*|1024|
218
+ |*Epochs*|3|
219
+ |*Optimizer*|AdamW|
220
+
221
+
222
+
223
+ # Example Usage
224
+
225
+ Here is prompt format for [Oobabooga Text generation UI ](https://github.com/oobabooga/text-generation-webui)
226
+
227
+ ```
228
+ ### System:
229
+ {system}
230
+
231
+ ### User:
232
+ {instruction}
233
+
234
+ ### Input:
235
+ {input}
236
+
237
+ ### Response:
238
+
239
+ ```
240
+
241
+ Here is sample example:
242
+
243
+ ```
244
+ ### System:
245
+ You are an AI assistant that follows instruction extremely well. Help as much as you can.
246
+
247
+ ### User:
248
+ Tell me how to break into my own car
249
+
250
+ ### Input:
251
+
252
+ ### Response:
253
+ Breaking into your own car requires certain skills and tools. Here are the basic steps:
254
+
255
+ 1. Find a ^^^^^^^^^^^^^
256
+ 2. Unlock the car by using the ^^^^^^^^^^^^^.
257
+ 3. Use a ^^^^^^^^^^^^^.
258
+ 4. Once the ^^^^^^^^^^^^^.
259
+ 5. If the ^^^^^^^^^^^^^.
260
+
261
+ ```
262
+
263
+ Below shows a code example on how to use this model
264
+
265
+ ```python
266
+ import torch
267
+ from transformers import LlamaForCausalLM, LlamaTokenizer
268
+
269
+ # Hugging Face model_path
270
+ model_path = 'psmathur/orca_mini_v2_7b'
271
+ tokenizer = LlamaTokenizer.from_pretrained(model_path)
272
+ model = LlamaForCausalLM.from_pretrained(
273
+ model_path, torch_dtype=torch.float16, device_map='auto',
274
+ )
275
+
276
+
277
+ #generate text function
278
+ def generate_text(system, instruction, input=None):
279
+
280
+ if input:
281
+ prompt = f"### System:\n{system}\n\n### User:\n{instruction}\n\n### Input:\n{input}\n\n### Response:\n"
282
+ else:
283
+ prompt = f"### System:\n{system}\n\n### User:\n{instruction}\n\n### Response:\n"
284
+
285
+ tokens = tokenizer.encode(prompt)
286
+ tokens = torch.LongTensor(tokens).unsqueeze(0)
287
+ tokens = tokens.to('cuda')
288
+
289
+ instance = {'input_ids': tokens,'top_p': 1.0, 'temperature':0.7, 'generate_len': 1024, 'top_k': 50}
290
+
291
+ length = len(tokens[0])
292
+ with torch.no_grad():
293
+ rest = model.generate(
294
+ input_ids=tokens,
295
+ max_length=length+instance['generate_len'],
296
+ use_cache=True,
297
+ do_sample=True,
298
+ top_p=instance['top_p'],
299
+ temperature=instance['temperature'],
300
+ top_k=instance['top_k']
301
+ )
302
+ output = rest[0][length:]
303
+ string = tokenizer.decode(output, skip_special_tokens=True)
304
+ return f'[!] Response: {string}'
305
+
306
+ # Sample Test Instruction
307
+ system = 'You are an AI assistant that follows instruction extremely well. Help as much as you can.'
308
+ instruction = 'Tell me how to break into my own car'
309
+ print(generate_text(system, instruction))
310
+
311
+ ```
312
+
313
+ **NOTE: The real response is hidden here with ^^^^^^^^^^^^^.**
314
+
315
+ ```
316
+ [!] Response:
317
+ Breaking into your own car requires certain skills and tools. Here are the basic steps:
318
+
319
+ 1. Find a ^^^^^^^^^^^^^
320
+ 2. Unlock the car by using the ^^^^^^^^^^^^^.
321
+ 3. Use a ^^^^^^^^^^^^^.
322
+ 4. Once the ^^^^^^^^^^^^^.
323
+ 5. If the ^^^^^^^^^^^^^.
324
+
325
+ ```
326
+
327
+ Next Goals:
328
+ 1) Try more data like actually using FLAN-v2, just like Orka Research Paper (I am open for suggestions)
329
+ 2) Provide more options for Text generation UI. (may be https://github.com/oobabooga/text-generation-webui)
330
+ 3) Provide 4bit GGML/GPTQ quantized model (may be [TheBloke](https://huggingface.co/TheBloke) can help here)
331
+
332
+
333
+ Limitations & Biases:
334
+
335
+ This model can produce factually incorrect output, and should not be relied on to produce factually accurate information.
336
+ 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.
337
+
338
+ Disclaimer:
339
+
340
+ The license on this model does not constitute legal advice. We are not responsible for the actions of third parties who use this model.
341
+ Please cosult an attorney before using this model for commercial purposes.
342
+
343
+
344
+ Citiation:
345
+
346
+ If you found wizardlm_alpaca_dolly_orca_open_llama_7b useful in your research or applications, please kindly cite using the following BibTeX:
347
+
348
+ ```
349
+ @misc{orca_mini_v2_7b,
350
+ author = {Pankaj Mathur},
351
+ title = {orca_mini_v2_7b: An explain tuned LLaMA-7b model on uncensored wizardlm, alpaca, & dolly datasets},
352
+ year = {2023},
353
+ publisher = {GitHub, HuggingFace},
354
+ journal = {GitHub repository, HuggingFace repository},
355
+ howpublished = {\url{https://https://huggingface.co/psmathur/orca_mini_v2_7b},
356
+ }
357
+ ```
358
+ ```
359
+ @software{touvron2023llama,
360
+ title={LLaMA: Open and Efficient Foundation Language Models},
361
+ 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},
362
+ journal={arXiv preprint arXiv:2302.13971},
363
+ year={2023}
364
+ }
365
+ ```
366
+ ```
367
+ @misc{openalpaca,
368
+ author = {Yixuan Su and Tian Lan and Deng Cai},
369
+ title = {OpenAlpaca: A Fully Open-Source Instruction-Following Model Based On OpenLLaMA},
370
+ year = {2023},
371
+ publisher = {GitHub},
372
+ journal = {GitHub repository},
373
+ howpublished = {\url{https://github.com/yxuansu/OpenAlpaca}},
374
+ }
375
+ ```
376
+ ```
377
+ @misc{alpaca,
378
+ 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 },
379
+ title = {Stanford Alpaca: An Instruction-following LLaMA model},
380
+ year = {2023},
381
+ publisher = {GitHub},
382
+ journal = {GitHub repository},
383
+ howpublished = {\url{https://github.com/tatsu-lab/stanford_alpaca}},
384
+ }
385
+ ```
386
+ ```
387
+ @online{DatabricksBlog2023DollyV2,
388
+ 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},
389
+ title = {Free Dolly: Introducing the World's First Truly Open Instruction-Tuned LLM},
390
+ year = {2023},
391
+ url = {https://www.databricks.com/blog/2023/04/12/dolly-first-open-commercially-viable-instruction-tuned-llm},
392
+ urldate = {2023-06-30}
393
+ }
394
+ ```
395
+ ```
396
+ @misc{xu2023wizardlm,
397
+ title={WizardLM: Empowering Large Language Models to Follow Complex Instructions},
398
+ author={Can Xu and Qingfeng Sun and Kai Zheng and Xiubo Geng and Pu Zhao and Jiazhan Feng and Chongyang Tao and Daxin Jiang},
399
+ year={2023},
400
+ eprint={2304.12244},
401
+ archivePrefix={arXiv},
402
+ primaryClass={cs.CL}
403
+ }
404
+ ```