TheBloke commited on
Commit
7d9b71e
1 Parent(s): 50e9c1b

Initial GPTQ model commit

Browse files
Files changed (1) hide show
  1. README.md +383 -0
README.md ADDED
@@ -0,0 +1,383 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ datasets:
3
+ - OpenAssistant/oasst1
4
+ inference: false
5
+ language:
6
+ - en
7
+ library_name: transformers
8
+ license: apache-2.0
9
+ model_type: falcon
10
+ tags:
11
+ - gpt
12
+ - llm
13
+ - large language model
14
+ - h2o-llmstudio
15
+ thumbnail: https://h2o.ai/etc.clientlibs/h2o/clientlibs/clientlib-site/resources/images/favicon.ico
16
+ ---
17
+
18
+ <!-- header start -->
19
+ <div style="width: 100%;">
20
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
21
+ </div>
22
+ <div style="display: flex; justify-content: space-between; width: 100%;">
23
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
24
+ <p><a href="https://discord.gg/theblokeai">Chat & support: my new Discord server</a></p>
25
+ </div>
26
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
27
+ <p><a href="https://www.patreon.com/TheBlokeAI">Want to contribute? TheBloke's Patreon page</a></p>
28
+ </div>
29
+ </div>
30
+ <!-- header end -->
31
+
32
+ # H2O's GM OASST1 Falcon 7B v3 GPTQ
33
+
34
+ These files are GPTQ model files for [H2O's GM OASST1 Falcon 7B v3](https://huggingface.co/h2oai/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3).
35
+
36
+ Multiple GPTQ parameter permutations are provided; see Provided Files below for details of the options provided, their parameters, and the software used to create them.
37
+
38
+ These models were quantised using hardware kindly provided by [Latitude.sh](https://www.latitude.sh/accelerate).
39
+
40
+ ## Repositories available
41
+
42
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3-GPTQ)
43
+ * [2, 3, 4, 5, 6 and 8-bit GGML models for CPU+GPU inference](https://huggingface.co/TheBloke/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3-GGML)
44
+ * [Unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/h2oai/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3)
45
+
46
+ ## Prompt template: H2O
47
+
48
+ ```
49
+ <|prompt|>{prompt}<|endoftext|><|answer|>
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) | File Size | ExLlama Compatible? | Made With | Description |
59
+ | ------ | ---- | ---------- | -------------------- | --------- | ------------------- | --------- | ----------- |
60
+ | main | 4 | 128 | False | 4.63 GB | False | 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 | 4 | 32 | True | 5.02 GB | False | 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 | 4 | 64 | True | 4.76 GB | False | 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 | 4 | 128 | True | 4.63 GB | False | AutoGPTQ | 4-bit, with Act Order and group size. 128g uses even less VRAM, but with slightly lower accuracy. Poor AutoGPTQ CUDA speed. |
64
+ | gptq-8bit--1g-actorder_True | 8 | None | True | 7.82 GB | False | AutoGPTQ | 8-bit, with Act Order. No group size, to lower VRAM requirements and to improve AutoGPTQ speed. |
65
+ | gptq-8bit-128g-actorder_False | 8 | 128 | False | 7.97 GB | False | AutoGPTQ | 8-bit, with group size 128g for higher inference quality and without Act Order to improve AutoGPTQ 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/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3-GPTQ:gptq-4bit-32g-actorder_True`
70
+ - With Git, you can clone a branch with:
71
+ ```
72
+ git clone --branch gptq-4bit-32g-actorder_True https://huggingface.co/TheBloke/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3-GPTQ`
73
+ ```
74
+ - In Python Transformers code, the branch is the `revision` parameter; see below.
75
+
76
+ ## How to easily download and use this model in [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
77
+
78
+ Please make sure you're using the latest version of [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
79
+
80
+ It is strongly recommended to use the text-generation-webui one-click-installers unless you know how to make a manual install.
81
+
82
+ 1. Click the **Model tab**.
83
+ 2. Under **Download custom model or LoRA**, enter `TheBloke/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3-GPTQ`.
84
+ - To download from a specific branch, enter for example `TheBloke/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3-GPTQ:gptq-4bit-32g-actorder_True`
85
+ - see Provided Files above for the list of branches for each option.
86
+ 3. Click **Download**.
87
+ 4. The model will start downloading. Once it's finished it will say "Done"
88
+ 5. In the top left, click the refresh icon next to **Model**.
89
+ 6. In the **Model** dropdown, choose the model you just downloaded: `h2ogpt-gm-oasst1-en-2048-falcon-7b-v3-GPTQ`
90
+ 7. The model will automatically load, and is now ready for use!
91
+ 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.
92
+ * Note that you do not need to set GPTQ parameters any more. These are set automatically from the file `quantize_config.json`.
93
+ 9. Once you're ready, click the **Text Generation tab** and enter a prompt to get started!
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
+
103
+ ```python
104
+ from transformers import AutoTokenizer, pipeline, logging
105
+ from auto_gptq import AutoGPTQForCausalLM, BaseQuantizeConfig
106
+
107
+ model_name_or_path = "TheBloke/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3-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=True,
118
+ device="cuda:0",
119
+ use_triton=use_triton,
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=True,
130
+ device="cuda:0",
131
+ quantize_config=None)
132
+ """
133
+
134
+ prompt = "Tell me about AI"
135
+ prompt_template=f'''<|prompt|>{prompt}<|endoftext|><|answer|>
136
+ '''
137
+
138
+ print("\n\n*** Generate:")
139
+
140
+ input_ids = tokenizer(prompt_template, return_tensors='pt').input_ids.cuda()
141
+ output = model.generate(inputs=input_ids, temperature=0.7, max_new_tokens=512)
142
+ print(tokenizer.decode(output[0]))
143
+
144
+ # Inference can also be done using transformers' pipeline
145
+
146
+ # Prevent printing spurious transformers error when using pipeline with AutoGPTQ
147
+ logging.set_verbosity(logging.CRITICAL)
148
+
149
+ print("*** Pipeline:")
150
+ pipe = pipeline(
151
+ "text-generation",
152
+ model=model,
153
+ tokenizer=tokenizer,
154
+ max_new_tokens=512,
155
+ temperature=0.7,
156
+ top_p=0.95,
157
+ repetition_penalty=1.15
158
+ )
159
+
160
+ print(pipe(prompt_template)[0]['generated_text'])
161
+ ```
162
+
163
+ ## Compatibility
164
+
165
+ The files provided will work with AutoGPTQ (CUDA and Triton modes), GPTQ-for-LLaMa (only CUDA has been tested), and Occ4m's GPTQ-for-LLaMa fork.
166
+
167
+ ExLlama works with Llama models in 4-bit. Please see the Provided Files table above for per-file compatibility.
168
+
169
+ <!-- footer start -->
170
+ ## Discord
171
+
172
+ For further support, and discussions on these models and AI in general, join us at:
173
+
174
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
175
+
176
+ ## Thanks, and how to contribute.
177
+
178
+ Thanks to the [chirper.ai](https://chirper.ai) team!
179
+
180
+ 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.
181
+
182
+ 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.
183
+
184
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
185
+
186
+ * Patreon: https://patreon.com/TheBlokeAI
187
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
188
+
189
+ **Special thanks to**: Luke from CarbonQuill, Aemon Algiz.
190
+
191
+ **Patreon special mentions**: Space Cruiser, Nikolai Manek, Sam, Chris McCloskey, Rishabh Srivastava, Kalila, Spiking Neurons AB, Khalefa Al-Ahmad, WelcomeToTheClub, Chadd, Lone Striker, Viktor Bowallius, Edmond Seymore, Ai Maven, Chris Smitley, Dave, Alexandros Triantafyllidis, Luke @flexchar, Elle, ya boyyy, Talal Aujan, Alex , Jonathan Leane, Deep Realms, Randy H, subjectnull, Preetika Verma, Joseph William Delisle, Michael Levine, chris gileta, K, Oscar Rangel, LangChain4j, Trenton Dambrowitz, Eugene Pentland, Johann-Peter Hartmann, Femi Adebogun, Illia Dulskyi, senxiiz, Daniel P. Andersen, Sean Connelly, Artur Olbinski, RoA, Mano Prime, Derek Yates, Raven Klaugh, David Flickinger, Willem Michiel, Pieter, Willian Hasse, vamX, Luke Pendergrass, webtim, Ghost , Rainer Wilmers, Nathan LeClaire, Will Dee, Cory Kujawski, John Detwiler, Fred von Graf, biorpg, Iucharbius , Imad Khwaja, Pierre Kircher, terasurfer , Asp the Wyvern, John Villwock, theTransient, zynix , Gabriel Tamborski, Fen Risland, Gabriel Puliatti, Matthew Berman, Pyrater, SuperWojo, Stephen Murray, Karl Bernard, Ajan Kanaga, Greatston Gnanesh, Junyu Yang.
192
+
193
+ Thank you to all my generous patrons and donaters!
194
+
195
+ <!-- footer end -->
196
+
197
+ # Original model card: H2O's GM OASST1 Falcon 7B v3
198
+
199
+ # Model Card
200
+ ## Summary
201
+
202
+ This model was trained using [H2O LLM Studio](https://github.com/h2oai/h2o-llmstudio).
203
+ - Base model: [tiiuae/falcon-7b](https://huggingface.co/tiiuae/falcon-7b)
204
+ - Dataset preparation: [OpenAssistant/oasst1](https://github.com/h2oai/h2o-llmstudio/blob/1935d84d9caafed3ee686ad2733eb02d2abfce57/app_utils/utils.py#LL1896C5-L1896C28) personalized
205
+
206
+
207
+ ## Usage
208
+
209
+ To use the model with the `transformers` library on a machine with GPUs, first make sure you have the `transformers`, `accelerate`, `torch` and `einops` libraries installed.
210
+
211
+ ```bash
212
+ pip install transformers==4.29.2
213
+ pip install accelerate==0.19.0
214
+ pip install torch==2.0.0
215
+ pip install einops==0.6.1
216
+ ```
217
+
218
+ ```python
219
+ import torch
220
+ from transformers import AutoTokenizer, pipeline
221
+
222
+
223
+ tokenizer = AutoTokenizer.from_pretrained(
224
+ "h2oai/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3",
225
+ use_fast=False,
226
+ padding_side="left",
227
+ trust_remote_code=True,
228
+ )
229
+
230
+ generate_text = pipeline(
231
+ model="h2oai/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3",
232
+ tokenizer=tokenizer,
233
+ torch_dtype=torch.float16,
234
+ trust_remote_code=True,
235
+ use_fast=False,
236
+ device_map={"": "cuda:0"},
237
+ )
238
+
239
+ res = generate_text(
240
+ "Why is drinking water so healthy?",
241
+ min_new_tokens=2,
242
+ max_new_tokens=1024,
243
+ do_sample=False,
244
+ num_beams=1,
245
+ temperature=float(0.3),
246
+ repetition_penalty=float(1.2),
247
+ renormalize_logits=True
248
+ )
249
+ print(res[0]["generated_text"])
250
+ ```
251
+
252
+ You can print a sample prompt after the preprocessing step to see how it is feed to the tokenizer:
253
+
254
+ ```python
255
+ print(generate_text.preprocess("Why is drinking water so healthy?")["prompt_text"])
256
+ ```
257
+
258
+ ```bash
259
+ <|prompt|>Why is drinking water so healthy?<|endoftext|><|answer|>
260
+ ```
261
+
262
+ Alternatively, you can download [h2oai_pipeline.py](h2oai_pipeline.py), store it alongside your notebook, and construct the pipeline yourself from the loaded model and tokenizer:
263
+
264
+
265
+ ```python
266
+ import torch
267
+ from h2oai_pipeline import H2OTextGenerationPipeline
268
+ from transformers import AutoModelForCausalLM, AutoTokenizer
269
+
270
+ tokenizer = AutoTokenizer.from_pretrained(
271
+ "h2oai/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3",
272
+ use_fast=False,
273
+ padding_side="left",
274
+ trust_remote_code=True,
275
+ )
276
+ model = AutoModelForCausalLM.from_pretrained(
277
+ "h2oai/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3",
278
+ torch_dtype=torch.float16,
279
+ device_map={"": "cuda:0"},
280
+ trust_remote_code=True,
281
+ )
282
+ generate_text = H2OTextGenerationPipeline(model=model, tokenizer=tokenizer)
283
+
284
+ res = generate_text(
285
+ "Why is drinking water so healthy?",
286
+ min_new_tokens=2,
287
+ max_new_tokens=1024,
288
+ do_sample=False,
289
+ num_beams=1,
290
+ temperature=float(0.3),
291
+ repetition_penalty=float(1.2),
292
+ renormalize_logits=True
293
+ )
294
+ print(res[0]["generated_text"])
295
+ ```
296
+
297
+
298
+ You may also construct the pipeline from the loaded model and tokenizer yourself and consider the preprocessing steps:
299
+
300
+ ```python
301
+ from transformers import AutoModelForCausalLM, AutoTokenizer
302
+
303
+ model_name = "h2oai/h2ogpt-gm-oasst1-en-2048-falcon-7b-v3" # either local folder or huggingface model name
304
+ # Important: The prompt needs to be in the same format the model was trained with.
305
+ # You can find an example prompt in the experiment logs.
306
+ prompt = "<|prompt|>How are you?<|endoftext|><|answer|>"
307
+
308
+ tokenizer = AutoTokenizer.from_pretrained(
309
+ model_name,
310
+ use_fast=False,
311
+ trust_remote_code=True,
312
+ )
313
+ model = AutoModelForCausalLM.from_pretrained(
314
+ model_name,
315
+ torch_dtype=torch.float16,
316
+ device_map={"": "cuda:0"},
317
+ trust_remote_code=True,
318
+ )
319
+ model.cuda().eval()
320
+ inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).to("cuda")
321
+
322
+ # generate configuration can be modified to your needs
323
+ tokens = model.generate(
324
+ **inputs,
325
+ min_new_tokens=2,
326
+ max_new_tokens=1024,
327
+ do_sample=False,
328
+ num_beams=1,
329
+ temperature=float(0.3),
330
+ repetition_penalty=float(1.2),
331
+ renormalize_logits=True
332
+ )[0]
333
+
334
+ tokens = tokens[inputs["input_ids"].shape[1]:]
335
+ answer = tokenizer.decode(tokens, skip_special_tokens=True)
336
+ print(answer)
337
+ ```
338
+
339
+ ## Model Architecture
340
+
341
+ ```
342
+ RWForCausalLM(
343
+ (transformer): RWModel(
344
+ (word_embeddings): Embedding(65024, 4544)
345
+ (h): ModuleList(
346
+ (0-31): 32 x DecoderLayer(
347
+ (input_layernorm): LayerNorm((4544,), eps=1e-05, elementwise_affine=True)
348
+ (self_attention): Attention(
349
+ (maybe_rotary): RotaryEmbedding()
350
+ (query_key_value): Linear(in_features=4544, out_features=4672, bias=False)
351
+ (dense): Linear(in_features=4544, out_features=4544, bias=False)
352
+ (attention_dropout): Dropout(p=0.0, inplace=False)
353
+ )
354
+ (mlp): MLP(
355
+ (dense_h_to_4h): Linear(in_features=4544, out_features=18176, bias=False)
356
+ (act): GELU(approximate='none')
357
+ (dense_4h_to_h): Linear(in_features=18176, out_features=4544, bias=False)
358
+ )
359
+ )
360
+ )
361
+ (ln_f): LayerNorm((4544,), eps=1e-05, elementwise_affine=True)
362
+ )
363
+ (lm_head): Linear(in_features=4544, out_features=65024, bias=False)
364
+ )
365
+ ```
366
+
367
+ ## Model Configuration
368
+
369
+ This model was trained using H2O LLM Studio and with the configuration in [cfg.yaml](cfg.yaml). Visit [H2O LLM Studio](https://github.com/h2oai/h2o-llmstudio) to learn how to train your own large language models.
370
+
371
+
372
+ ## Disclaimer
373
+
374
+ Please read this disclaimer carefully before using the large language model provided in this repository. Your use of the model signifies your agreement to the following terms and conditions.
375
+
376
+ - Biases and Offensiveness: The large language model is trained on a diverse range of internet text data, which may contain biased, racist, offensive, or otherwise inappropriate content. By using this model, you acknowledge and accept that the generated content may sometimes exhibit biases or produce content that is offensive or inappropriate. The developers of this repository do not endorse, support, or promote any such content or viewpoints.
377
+ - Limitations: The large language model is an AI-based tool and not a human. It may produce incorrect, nonsensical, or irrelevant responses. It is the user's responsibility to critically evaluate the generated content and use it at their discretion.
378
+ - Use at Your Own Risk: Users of this large language model must assume full responsibility for any consequences that may arise from their use of the tool. The developers and contributors of this repository shall not be held liable for any damages, losses, or harm resulting from the use or misuse of the provided model.
379
+ - Ethical Considerations: Users are encouraged to use the large language model responsibly and ethically. By using this model, you agree not to use it for purposes that promote hate speech, discrimination, harassment, or any form of illegal or harmful activities.
380
+ - Reporting Issues: If you encounter any biased, offensive, or otherwise inappropriate content generated by the large language model, please report it to the repository maintainers through the provided channels. Your feedback will help improve the model and mitigate potential issues.
381
+ - Changes to this Disclaimer: The developers of this repository reserve the right to modify or update this disclaimer at any time without prior notice. It is the user's responsibility to periodically review the disclaimer to stay informed about any changes.
382
+
383
+ By using the large language model provided in this repository, you agree to accept and comply with the terms and conditions outlined in this disclaimer. If you do not agree with any part of this disclaimer, you should refrain from using the model and any content generated by it.