TheBloke commited on
Commit
ffb60fb
1 Parent(s): 72be3c6

Initial GPTQ model commit

Browse files
Files changed (1) hide show
  1. README.md +40 -118
README.md CHANGED
@@ -49,27 +49,42 @@ Below is an instruction that describes a task. Write a response that appropriate
49
  ### Response:
50
  ```
51
 
52
- ## Provided files
53
 
54
  Multiple quantisation parameters are provided, to allow you to choose the best one for your hardware and requirements.
55
 
56
  Each separate quant is in a different branch. See below for instructions on fetching from different branches.
57
 
58
- | Branch | Bits | Group Size | Act Order (desc_act) | GPTQ Dataset | Size | ExLlama Compat? | Made With | Desc |
59
- | ------ | ---- | ---------- | -------------------- | ------------ | ---- | --------------- | --------- | ---- |
60
- | [main](https://huggingface.co/TheBloke/NewHope-GPTQ/tree/main) | 4 | 128 | No | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 7.26 GB | Yes | AutoGPTQ | Most compatible option. Good inference speed in AutoGPTQ and GPTQ-for-LLaMa. Lower inference quality than other options. |
61
- | [gptq-4bit-32g-actorder_True](https://huggingface.co/TheBloke/NewHope-GPTQ/tree/gptq-4bit-32g-actorder_True) | 4 | 32 | Yes | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 8.00 GB | Yes | AutoGPTQ | 4-bit, with Act Order and group size 32g. Gives highest possible inference quality, with maximum VRAM usage. Poor AutoGPTQ CUDA speed. |
62
- | [gptq-4bit-64g-actorder_True](https://huggingface.co/TheBloke/NewHope-GPTQ/tree/gptq-4bit-64g-actorder_True) | 4 | 64 | Yes | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 7.51 GB | Yes | AutoGPTQ | 4-bit, with Act Order and group size 64g. Uses less VRAM than 32g, but with slightly lower accuracy. Poor AutoGPTQ CUDA speed. |
63
- | [gptq-4bit-128g-actorder_True](https://huggingface.co/TheBloke/NewHope-GPTQ/tree/gptq-4bit-128g-actorder_True) | 4 | 128 | Yes | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 7.26 GB | Yes | AutoGPTQ | 4-bit, with Act Order and group size 128g. Uses even less VRAM than 64g, but with slightly lower accuracy. Poor AutoGPTQ CUDA speed. |
64
- | [gptq-8bit--1g-actorder_True](https://huggingface.co/TheBloke/NewHope-GPTQ/tree/gptq-8bit--1g-actorder_True) | 8 | None | Yes | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 13.36 GB | No | AutoGPTQ | 8-bit, with Act Order. No group size, to lower VRAM requirements and to improve AutoGPTQ speed. |
65
- | [gptq-8bit-128g-actorder_True](https://huggingface.co/TheBloke/NewHope-GPTQ/tree/gptq-8bit-128g-actorder_True) | 8 | 128 | Yes | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 13.65 GB | No | AutoGPTQ | 8-bit, with group size 128g for higher inference quality and with Act Order for even higher accuracy. Poor AutoGPTQ CUDA speed. |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
  ## How to download from branches
68
 
69
  - In text-generation-webui, you can add `:branch` to the end of the download name, eg `TheBloke/NewHope-GPTQ:gptq-4bit-32g-actorder_True`
70
  - With Git, you can clone a branch with:
71
  ```
72
- git clone --branch --single-branch gptq-4bit-32g-actorder_True https://huggingface.co/TheBloke/NewHope-GPTQ
73
  ```
74
  - In Python Transformers code, the branch is the `revision` parameter; see below.
75
 
@@ -94,9 +109,19 @@ It is strongly recommended to use the text-generation-webui one-click-installers
94
 
95
  ## How to use this GPTQ model from Python code
96
 
97
- First make sure you have [AutoGPTQ](https://github.com/PanQiWei/AutoGPTQ) installed:
 
 
 
 
98
 
99
- `GITHUB_ACTIONS=true pip install auto-gptq`
 
 
 
 
 
 
100
 
101
  Then try the following example code:
102
 
@@ -105,14 +130,12 @@ from transformers import AutoTokenizer, pipeline, logging
105
  from auto_gptq import AutoGPTQForCausalLM, BaseQuantizeConfig
106
 
107
  model_name_or_path = "TheBloke/NewHope-GPTQ"
108
- model_basename = "gptq_model-4bit-128g"
109
 
110
  use_triton = False
111
 
112
  tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
113
 
114
  model = AutoGPTQForCausalLM.from_quantized(model_name_or_path,
115
- model_basename=model_basename,
116
  use_safetensors=True,
117
  trust_remote_code=False,
118
  device="cuda:0",
@@ -120,11 +143,11 @@ model = AutoGPTQForCausalLM.from_quantized(model_name_or_path,
120
  quantize_config=None)
121
 
122
  """
123
- To download from a specific branch, use the revision parameter, as in this example:
 
124
 
125
  model = AutoGPTQForCausalLM.from_quantized(model_name_or_path,
126
  revision="gptq-4bit-32g-actorder_True",
127
- model_basename=model_basename,
128
  use_safetensors=True,
129
  trust_remote_code=False,
130
  device="cuda:0",
@@ -202,105 +225,4 @@ Thank you to all my generous patrons and donaters!
202
 
203
  # Original model card: SLAM-group's NewHope
204
 
205
- # NewHope: Harnessing 99% of GPT-4's Programming Capabilities
206
-
207
- We introduce NewHope, a fine-tuned chat model based on llama-2-13b, aiming to provide a strong coding capability. NewHope handle different languages including Python, C++, Java, JavaScript, Go, and more. Preliminary evaluation on HumanEval shows that **NewHope possesses 99% of GPT-4's programming capabilities**.
208
-
209
- **Contact**: SLAM (<ins>S</ins>UFE <ins>L</ins>arge <ins>A</ins>I <ins>M</ins>odel) is a research group at Shanghai University of Finance and Economics.
210
- cui.wanyun@sufe.edu.cn
211
-
212
- **TODO**: We will release more evaluatation results and training details later.
213
-
214
- # Evaluation Results
215
-
216
- We evaluated NewHope on [HumanEval](https://github.com/openai/human-eval) using the official evaluation script by OpenAI. We compared the Pass@1 metric of NewHope with other models. The results of other models are from PapersWithCode.
217
-
218
- | Model | Pass@1 |
219
- | ----- | ------ |
220
- | **GPT-4** | **67.0** |
221
- | **NewHope** | **66.5** |
222
- | PanGu-Coder2 15B | 61.6 |
223
- | WizardCoder 15B | 57.3 |
224
- | phi-1 1.3B | 50.6 |
225
- | GPT-3.5 | 48.1 |
226
- | phi-1-small | 45.0 |
227
- | PaLM-Coder | 36.0 |
228
- | CodeGeeX2-6B | 35.9 |
229
-
230
- # Model Weights
231
-
232
- We have open-sourced the model weights [NewHope](https://huggingface.co/SLAM-group/NewHope).
233
-
234
- We are uploading the model weights. The weights will be available in a few hours.
235
-
236
-
237
- # Usage
238
-
239
- To load the NewHope model using Transformers, use the following code:
240
- ```
241
- import torch
242
- from transformers import LlamaTokenizer, LlamaForCausalLM
243
-
244
- base_model = "SLAM-group/NewHope"
245
- tokenizer = LlamaTokenizer.from_pretrained(base_model)
246
- model = LlamaForCausalLM.from_pretrained(base_model, torch_dtype=torch.float16, device_map="auto")
247
- # model.config.use_cache is default to `False`. For inference: `model.config.use_cache = True`
248
- ```
249
- **Note:** At least Huggingface Transformers **4.31.0** is required to load this model!
250
-
251
- You can ask NewHope to generate code with instructions. We provide a simple example of how NewHope model generates code with the specific prompt:
252
- ```
253
- # Suppose required tokenizer and model have already been loaded
254
-
255
- instruction = "Write a Python function to tell me what the date is today."
256
- prompt = f"<s> ### Instruction:\n{instruction}\n\n### Response:\n"
257
- inputs = tokenizer(prompt, add_special_tokens=False, return_tensors="pt").to("cuda")
258
- output = model.generate(**inputs, do_sample=True, top_p=0.9, max_new_tokens=2048)[0]
259
- decoded_output = tokenizer.decode(output, skip_special_tokens=True).split("### Response:\n")[-1].strip()
260
- print(decoded_output)
261
- ```
262
-
263
- You can also interact with NewHope in a dialog manner with the following prompt:
264
- ```
265
- <s> ### Instruction:\nQ1\n\n### Response:\nA1</s><s> ### Instruction:\nQ2\n\n### Response:\nA2</s>
266
- ```
267
-
268
-
269
- # Evaluation
270
-
271
- ### Local setup
272
- 1. Install HumanEval for evaluation. [Details](https://github.com/openai/human-eval)
273
- 2. Install dependencies
274
-
275
- ```bash
276
- pip install -r requirements.txt
277
- ```
278
-
279
- ---
280
- For HumanEval, we use the following prompt:
281
- ```
282
- example_input = 'def is_odd(number: int) -> bool:\n """ Check whether the given number is odd\n >>> is_odd(3)\n True\n >>> is_odd(6)\n False\n """\n'
283
- example_output = 'def is_odd(number: int) -> bool:\n """ Check whether the given number is odd\n >>> is_odd(3)\n True\n >>> is_odd(6)\n False\n """\n return number % 2 == 1'
284
-
285
- task_in_humaneval = "REPLACE `task_in_humaneval` WITH THE SPECIFIC TASK IN HUMANEVAL DATA"
286
-
287
- prompt = f"<s> ### Instruction:\nComplete the given function below:\n\n{example_input}\n\n### Response:\n{example_output}</s><s> ### Instruction:\nComplete the given function below:\n\n{task_in_human_eval}\n\n### Response:\n"
288
- ```
289
-
290
- To reproduce the results on HumanEval, use the following script:
291
- ```
292
- python complete.py --base_model SLAM-group/NewHope --output_dir output --n_gpu 8
293
- ```
294
- The above script will generate `samples.jsonl` in `output_dir`, which can be directly evaluated by HumanEval. [Evaluation procedure](https://github.com/openai/human-eval). We conducted the experiment with `fp16` on 8xA800, 80GB GPUs, reaching `66.5%` on Pass@1 (v.s. GPT4 `67.0%`).
295
-
296
- # Citation
297
-
298
- ```
299
- @misc{2023newhope,
300
- title={NewHope: Harnessing 99% of GPT-4's Programming Capabilities},
301
- author={Wanyun Cui and Qianle Wang},
302
- howpublished = https://github.com/SLAM-group/newhope,
303
- year={2023}
304
- }
305
- ```
306
-
 
49
  ### Response:
50
  ```
51
 
52
+ ## Provided files and GPTQ parameters
53
 
54
  Multiple quantisation parameters are provided, to allow you to choose the best one for your hardware and requirements.
55
 
56
  Each separate quant is in a different branch. See below for instructions on fetching from different branches.
57
 
58
+ All GPTQ files are made with AutoGPTQ.
59
+
60
+ <details>
61
+ <summary>Explanation of GPTQ parameters</summary>
62
+
63
+ - Bits: The bit size of the quantised model.
64
+ - GS: GPTQ group size. Higher numbers use less VRAM, but have lower quantisation accuracy. "None" is the lowest possible value.
65
+ - Act Order: True or False. Also known as `desc_act`. True results in better quantisation accuracy. Some GPTQ clients have issues with models that use Act Order plus Group Size.
66
+ - Damp %: A GPTQ parameter that affects how samples are processed for quantisation. 0.01 is default, but 0.1 results in slightly better accuracy.
67
+ - GPTQ dataset: The dataset used for quantisation. The dataset used for quantisation can affect the quantisation accuracy. The dataset used for quantisation is not the same as the dataset used to train the model.
68
+ - Sequence Length: The length of the dataset sequences used for quantisation. Ideally this is the same as the model sequence length. For some very long sequence models (16+K), a lower sequence length may have to be used. Note that a lower sequence length does not limit the sequence length of the quantised model. It only affects the quantisation accuracy on longer inference sequences.
69
+ - ExLlama Compatibility: Whether this file can be loaded with ExLlama, which currently only supports Llama models in 4-bit.
70
+
71
+ </details>
72
+
73
+ | Branch | Bits | GS | Act Order | Damp % | GPTQ Dataset | Seq Len | Size | ExLlama | Desc |
74
+ | ------ | ---- | -- | --------- | ------ | ------------ | ------- | ---- | ------- | ---- |
75
+ | [main](https://huggingface.co/TheBloke/NewHope-GPTQ/tree/main) | 4 | 128 | No | 0.1 | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 4096 | 7.26 GB | Yes | Most compatible option. Good inference speed in AutoGPTQ and GPTQ-for-LLaMa. Lower inference quality than other options. |
76
+ | [gptq-4bit-32g-actorder_True](https://huggingface.co/TheBloke/NewHope-GPTQ/tree/gptq-4bit-32g-actorder_True) | 4 | 32 | Yes | 0.1 | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 4096 | 8.00 GB | Yes | 4-bit, with Act Order and group size 32g. Gives highest possible inference quality, with maximum VRAM usage. Poor AutoGPTQ CUDA speed. |
77
+ | [gptq-4bit-64g-actorder_True](https://huggingface.co/TheBloke/NewHope-GPTQ/tree/gptq-4bit-64g-actorder_True) | 4 | 64 | Yes | 0.1 | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 4096 | 7.51 GB | Yes | 4-bit, with Act Order and group size 64g. Uses less VRAM than 32g, but with slightly lower accuracy. Poor AutoGPTQ CUDA speed. |
78
+ | [gptq-4bit-128g-actorder_True](https://huggingface.co/TheBloke/NewHope-GPTQ/tree/gptq-4bit-128g-actorder_True) | 4 | 128 | Yes | 0.1 | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 4096 | 7.26 GB | Yes | 4-bit, with Act Order and group size 128g. Uses even less VRAM than 64g, but with slightly lower accuracy. Poor AutoGPTQ CUDA speed. |
79
+ | [gptq-8bit--1g-actorder_True](https://huggingface.co/TheBloke/NewHope-GPTQ/tree/gptq-8bit--1g-actorder_True) | 8 | None | Yes | 0.1 | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 4096 | 13.36 GB | No | 8-bit, with Act Order. No group size, to lower VRAM requirements and to improve AutoGPTQ speed. |
80
+ | [gptq-8bit-128g-actorder_True](https://huggingface.co/TheBloke/NewHope-GPTQ/tree/gptq-8bit-128g-actorder_True) | 8 | 128 | Yes | 0.1 | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 4096 | 13.65 GB | No | 8-bit, with group size 128g for higher inference quality and with Act Order for even higher accuracy. Poor AutoGPTQ CUDA speed. |
81
 
82
  ## How to download from branches
83
 
84
  - In text-generation-webui, you can add `:branch` to the end of the download name, eg `TheBloke/NewHope-GPTQ:gptq-4bit-32g-actorder_True`
85
  - With Git, you can clone a branch with:
86
  ```
87
+ git clone --single-branch --branch gptq-4bit-32g-actorder_True https://huggingface.co/TheBloke/NewHope-GPTQ
88
  ```
89
  - In Python Transformers code, the branch is the `revision` parameter; see below.
90
 
 
109
 
110
  ## How to use this GPTQ model from Python code
111
 
112
+ First make sure you have [AutoGPTQ](https://github.com/PanQiWei/AutoGPTQ) 0.3.1 or later installed:
113
+
114
+ ```
115
+ pip3 install auto-gptq
116
+ ```
117
 
118
+ If you have problems installing AutoGPTQ, please build from source instead:
119
+ ```
120
+ pip3 uninstall -y auto-gptq
121
+ git clone https://github.com/PanQiWei/AutoGPTQ
122
+ cd AutoGPTQ
123
+ pip3 install .
124
+ ```
125
 
126
  Then try the following example code:
127
 
 
130
  from auto_gptq import AutoGPTQForCausalLM, BaseQuantizeConfig
131
 
132
  model_name_or_path = "TheBloke/NewHope-GPTQ"
 
133
 
134
  use_triton = False
135
 
136
  tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
137
 
138
  model = AutoGPTQForCausalLM.from_quantized(model_name_or_path,
 
139
  use_safetensors=True,
140
  trust_remote_code=False,
141
  device="cuda:0",
 
143
  quantize_config=None)
144
 
145
  """
146
+ # To download from a specific branch, use the revision parameter, as in this example:
147
+ # Note that `revision` requires AutoGPTQ 0.3.1 or later!
148
 
149
  model = AutoGPTQForCausalLM.from_quantized(model_name_or_path,
150
  revision="gptq-4bit-32g-actorder_True",
 
151
  use_safetensors=True,
152
  trust_remote_code=False,
153
  device="cuda:0",
 
225
 
226
  # Original model card: SLAM-group's NewHope
227
 
228
+ No original model card was provided.