TheBloke commited on
Commit
0e964f4
1 Parent(s): ed3b055

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +398 -0
README.md ADDED
@@ -0,0 +1,398 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: BAAI/AquilaChat2-34B-16K
3
+ inference: false
4
+ license: other
5
+ model_creator: Beijing Academy of Artificial Intelligence
6
+ model_name: Aquilachat2 34B 16K
7
+ model_type: aquila
8
+ prompt_template: 'System: A chat between a curious human and an artificial intelligence
9
+ assistant. The assistant gives helpful, detailed, and polite answers to the human''s
10
+ questions.
11
+
12
+ Human: {prompt}
13
+
14
+ Assistant:
15
+
16
+ '
17
+ quantized_by: TheBloke
18
+ ---
19
+ <!-- markdownlint-disable MD041 -->
20
+
21
+ <!-- header start -->
22
+ <!-- 200823 -->
23
+ <div style="width: auto; margin-left: auto; margin-right: auto">
24
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
25
+ </div>
26
+ <div style="display: flex; justify-content: space-between; width: 100%;">
27
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
28
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
29
+ </div>
30
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
31
+ <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>
32
+ </div>
33
+ </div>
34
+ <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>
35
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
36
+ <!-- header end -->
37
+
38
+ # Aquilachat2 34B 16K - AWQ
39
+ - Model creator: [Beijing Academy of Artificial Intelligence](https://huggingface.co/BAAI)
40
+ - Original model: [Aquilachat2 34B 16K](https://huggingface.co/BAAI/AquilaChat2-34B-16K)
41
+
42
+ <!-- description start -->
43
+ ## Description
44
+
45
+ This repo contains AWQ model files for [Beijing Academy of Artificial Intelligence's Aquilachat2 34B 16K](https://huggingface.co/BAAI/AquilaChat2-34B-16K).
46
+
47
+ These files were quantised using hardware kindly provided by [Massed Compute](https://massedcompute.com/).
48
+
49
+
50
+ ### About AWQ
51
+
52
+ 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.
53
+
54
+ It is supported by:
55
+
56
+ - [Text Generation Webui](https://github.com/oobabooga/text-generation-webui) - using Loader: AutoAWQ
57
+ - [vLLM](https://github.com/vllm-project/vllm) - Llama and Mistral models only
58
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference)
59
+ - [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) - for use from Python code
60
+
61
+ <!-- description end -->
62
+ <!-- repositories-available start -->
63
+ ## Repositories available
64
+
65
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/AquilaChat2-34B-16K-AWQ)
66
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/AquilaChat2-34B-16K-GPTQ)
67
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/AquilaChat2-34B-16K-GGUF)
68
+ * [Beijing Academy of Artificial Intelligence's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/BAAI/AquilaChat2-34B-16K)
69
+ <!-- repositories-available end -->
70
+
71
+ <!-- prompt-template start -->
72
+ ## Prompt template: AquilaChat
73
+
74
+ ```
75
+ System: A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.
76
+ Human: {prompt}
77
+ Assistant:
78
+
79
+ ```
80
+
81
+ <!-- prompt-template end -->
82
+
83
+
84
+ <!-- README_AWQ.md-provided-files start -->
85
+ ## Provided files, and AWQ parameters
86
+
87
+ For my first release of AWQ models, I am releasing 128g models only. I will consider adding 32g as well if there is interest, and once I have done perplexity and evaluation comparisons, but at this time 32g models are still not fully tested with AutoAWQ and vLLM.
88
+
89
+ Models are released as sharded safetensors files.
90
+
91
+ | Branch | Bits | GS | AWQ Dataset | Seq Len | Size |
92
+ | ------ | ---- | -- | ----------- | ------- | ---- |
93
+ | [main](https://huggingface.co/TheBloke/AquilaChat2-34B-16K-AWQ/tree/main) | 4 | 128 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-v1/test) | 4096 | 19.33 GB
94
+
95
+ <!-- README_AWQ.md-provided-files end -->
96
+
97
+ <!-- README_AWQ.md-text-generation-webui start -->
98
+ ## How to easily download and use this model in [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
99
+
100
+ Please make sure you're using the latest version of [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
101
+
102
+ 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.
103
+
104
+ 1. Click the **Model tab**.
105
+ 2. Under **Download custom model or LoRA**, enter `TheBloke/AquilaChat2-34B-16K-AWQ`.
106
+ 3. Click **Download**.
107
+ 4. The model will start downloading. Once it's finished it will say "Done".
108
+ 5. In the top left, click the refresh icon next to **Model**.
109
+ 6. In the **Model** dropdown, choose the model you just downloaded: `AquilaChat2-34B-16K-AWQ`
110
+ 7. Select **Loader: AutoAWQ**.
111
+ 8. Click Load, and the model will load and is now ready for use.
112
+ 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.
113
+ 10. Once you're ready, click the **Text Generation** tab and enter a prompt to get started!
114
+ <!-- README_AWQ.md-text-generation-webui end -->
115
+
116
+ <!-- README_AWQ.md-use-from-vllm start -->
117
+ ## Multi-user inference server: vLLM
118
+
119
+ Documentation on installing and using vLLM [can be found here](https://vllm.readthedocs.io/en/latest/).
120
+
121
+ - Please ensure you are using vLLM version 0.2 or later.
122
+ - When using vLLM as a server, pass the `--quantization awq` parameter.
123
+
124
+ For example:
125
+
126
+ ```shell
127
+ python3 python -m vllm.entrypoints.api_server --model TheBloke/AquilaChat2-34B-16K-AWQ --quantization awq
128
+ ```
129
+
130
+ - When using vLLM from Python code, again set `quantization=awq`.
131
+
132
+ For example:
133
+
134
+ ```python
135
+ from vllm import LLM, SamplingParams
136
+
137
+ prompts = [
138
+ "Tell me about AI",
139
+ "Write a story about llamas",
140
+ "What is 291 - 150?",
141
+ "How much wood would a woodchuck chuck if a woodchuck could chuck wood?",
142
+ ]
143
+ prompt_template=f'''System: A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.
144
+ Human: {prompt}
145
+ Assistant:
146
+ '''
147
+
148
+ prompts = [prompt_template.format(prompt=prompt) for prompt in prompts]
149
+
150
+ sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
151
+
152
+ llm = LLM(model="TheBloke/AquilaChat2-34B-16K-AWQ", quantization="awq", dtype="auto")
153
+
154
+ outputs = llm.generate(prompts, sampling_params)
155
+
156
+ # Print the outputs.
157
+ for output in outputs:
158
+ prompt = output.prompt
159
+ generated_text = output.outputs[0].text
160
+ print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
161
+ ```
162
+ <!-- README_AWQ.md-use-from-vllm start -->
163
+
164
+ <!-- README_AWQ.md-use-from-tgi start -->
165
+ ## Multi-user inference server: Hugging Face Text Generation Inference (TGI)
166
+
167
+ Use TGI version 1.1.0 or later. The official Docker container is: `ghcr.io/huggingface/text-generation-inference:1.1.0`
168
+
169
+ Example Docker parameters:
170
+
171
+ ```shell
172
+ --model-id TheBloke/AquilaChat2-34B-16K-AWQ --port 3000 --quantize awq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
173
+ ```
174
+
175
+ Example Python code for interfacing with TGI (requires [huggingface-hub](https://github.com/huggingface/huggingface_hub) 0.17.0 or later):
176
+
177
+ ```shell
178
+ pip3 install huggingface-hub
179
+ ```
180
+
181
+ ```python
182
+ from huggingface_hub import InferenceClient
183
+
184
+ endpoint_url = "https://your-endpoint-url-here"
185
+
186
+ prompt = "Tell me about AI"
187
+ prompt_template=f'''System: A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.
188
+ Human: {prompt}
189
+ Assistant:
190
+ '''
191
+
192
+ client = InferenceClient(endpoint_url)
193
+ response = client.text_generation(prompt,
194
+ max_new_tokens=128,
195
+ do_sample=True,
196
+ temperature=0.7,
197
+ top_p=0.95,
198
+ top_k=40,
199
+ repetition_penalty=1.1)
200
+
201
+ print(f"Model output: ", response)
202
+ ```
203
+ <!-- README_AWQ.md-use-from-tgi end -->
204
+
205
+ <!-- README_AWQ.md-use-from-python start -->
206
+ ## Inference from Python code using AutoAWQ
207
+
208
+ ### Install the AutoAWQ package
209
+
210
+ Requires: [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) 0.1.1 or later.
211
+
212
+ ```shell
213
+ pip3 install autoawq
214
+ ```
215
+
216
+ If you have problems installing [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) using the pre-built wheels, install it from source instead:
217
+
218
+ ```shell
219
+ pip3 uninstall -y autoawq
220
+ git clone https://github.com/casper-hansen/AutoAWQ
221
+ cd AutoAWQ
222
+ pip3 install .
223
+ ```
224
+
225
+ ### AutoAWQ example code
226
+
227
+ ```python
228
+ from awq import AutoAWQForCausalLM
229
+ from transformers import AutoTokenizer
230
+
231
+ model_name_or_path = "TheBloke/AquilaChat2-34B-16K-AWQ"
232
+
233
+ # Load tokenizer
234
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=True)
235
+ # Load model
236
+ model = AutoAWQForCausalLM.from_quantized(model_name_or_path, fuse_layers=True,
237
+ trust_remote_code=True, safetensors=True)
238
+
239
+ prompt = "Tell me about AI"
240
+ prompt_template=f'''System: A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.
241
+ Human: {prompt}
242
+ Assistant:
243
+ '''
244
+
245
+ print("*** Running model.generate:")
246
+
247
+ token_input = tokenizer(
248
+ prompt_template,
249
+ return_tensors='pt'
250
+ ).input_ids.cuda()
251
+
252
+ # Generate output
253
+ generation_output = model.generate(
254
+ token_input,
255
+ do_sample=True,
256
+ temperature=0.7,
257
+ top_p=0.95,
258
+ top_k=40,
259
+ max_new_tokens=512
260
+ )
261
+
262
+ # Get the tokens from the output, decode them, print them
263
+ token_output = generation_output[0]
264
+ text_output = tokenizer.decode(token_output)
265
+ print("LLM output: ", text_output)
266
+
267
+ """
268
+ # Inference should be possible with transformers pipeline as well in future
269
+ # But currently this is not yet supported by AutoAWQ (correct as of September 25th 2023)
270
+ from transformers import pipeline
271
+
272
+ print("*** Pipeline:")
273
+ pipe = pipeline(
274
+ "text-generation",
275
+ model=model,
276
+ tokenizer=tokenizer,
277
+ max_new_tokens=512,
278
+ do_sample=True,
279
+ temperature=0.7,
280
+ top_p=0.95,
281
+ top_k=40,
282
+ repetition_penalty=1.1
283
+ )
284
+
285
+ print(pipe(prompt_template)[0]['generated_text'])
286
+ """
287
+ ```
288
+ <!-- README_AWQ.md-use-from-python end -->
289
+
290
+ <!-- README_AWQ.md-compatibility start -->
291
+ ## Compatibility
292
+
293
+ The files provided are tested to work with:
294
+
295
+ - [text-generation-webui](https://github.com/oobabooga/text-generation-webui) using `Loader: AutoAWQ`.
296
+ - [vLLM](https://github.com/vllm-project/vllm) version 0.2.0 and later.
297
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference) version 1.1.0 and later.
298
+ - [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) version 0.1.1 and later.
299
+
300
+ <!-- README_AWQ.md-compatibility end -->
301
+
302
+ <!-- footer start -->
303
+ <!-- 200823 -->
304
+ ## Discord
305
+
306
+ For further support, and discussions on these models and AI in general, join us at:
307
+
308
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
309
+
310
+ ## Thanks, and how to contribute
311
+
312
+ Thanks to the [chirper.ai](https://chirper.ai) team!
313
+
314
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
315
+
316
+ 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.
317
+
318
+ 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.
319
+
320
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
321
+
322
+ * Patreon: https://patreon.com/TheBlokeAI
323
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
324
+
325
+ **Special thanks to**: Aemon Algiz.
326
+
327
+ **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
328
+
329
+
330
+ Thank you to all my generous patrons and donaters!
331
+
332
+ And thank you again to a16z for their generous grant.
333
+
334
+ <!-- footer end -->
335
+
336
+ # Original model card: Beijing Academy of Artificial Intelligence's Aquilachat2 34B 16K
337
+
338
+
339
+
340
+ ![Aquila_logo](./log.jpeg)
341
+
342
+
343
+ <h4 align="center">
344
+ <p>
345
+ <b>English</b> |
346
+ <a href="https://huggingface.co/BAAI/AquilaChat2-34B-16K/blob/main/README_zh.md">简体中文</a>
347
+ </p>
348
+ </h4>
349
+
350
+
351
+ <p align="center">
352
+ <a href="https://github.com/FlagAI-Open/Aquila2" target="_blank">Github</a> • <a href="https://github.com/FlagAI-Open/Aquila2/blob/main/assets/wechat-qrcode.jpg" target="_blank">WeChat</a> <br>
353
+ </p>
354
+
355
+
356
+ We opensource our **Aquila2** series, now including **Aquila2**, the base language models, namely **Aquila2-7B** and **Aquila2-34B**, as well as **AquilaChat2**, the chat models, namely **AquilaChat2-7B** and **AquilaChat2-34B**, as well as the long-text chat models, namely **AquilaChat2-7B-16k** and **AquilaChat2-34B-16k**
357
+
358
+
359
+ 2023.10.25 🔥 **AquilaChat2-34B-16K v1.2** is based on the previous **AquilaChat2-34B-16K**. The AquilaChat2-34B-16K-V1.2 has significantly improved long-text synthesis capabilities compared to the V1 version,
360
+ approaching the level of GPT-3.5-16K. Additionally, the V1.2 version incorporates more conventional instruction fine-tuning corpora, enhancing its performance in non-long-text scenarios compared to the V1 version.
361
+
362
+ The additional details of the Aquila model will be presented in the official technical report. Please stay tuned for updates on official channels.
363
+
364
+
365
+ ## Quick Start AquilaChat2-34B-16K(Chat model)
366
+
367
+ ### 1. Inference
368
+
369
+ ```python
370
+ from transformers import AutoTokenizer, AutoModelForCausalLM
371
+ import torch
372
+
373
+ device = torch.device("cuda:0")
374
+ model_info = "BAAI/AquilaChat2-34B-16k"
375
+ tokenizer = AutoTokenizer.from_pretrained(model_info, trust_remote_code=True)
376
+ quantization_config=BitsAndBytesConfig(
377
+ load_in_4bit=True,
378
+ bnb_4bit_use_double_quant=True,
379
+ bnb_4bit_quant_type="nf4",
380
+ bnb_4bit_compute_dtype=torch.bfloat16,
381
+ )
382
+ model = AutoModelForCausalLM.from_pretrained(model_info, trust_remote_code=True, torch_dtype=torch.bfloat16,
383
+ # quantization_config=quantization_config, # Uncomment this line for 4bit quantization
384
+ )
385
+ model.eval()
386
+ model.to(device)
387
+ text = "请给出10个要到北京旅游的理由。"
388
+ from predict import predict
389
+ out = predict(model, text, tokenizer=tokenizer, max_gen_len=200, top_p=0.9,
390
+ seed=123, topk=15, temperature=1.0, sft=True, device=device,
391
+ model_name="AquilaChat2-34B-16K")
392
+ print(out)
393
+ ```
394
+
395
+
396
+ ## License
397
+
398
+ Aquila2 series open-source model is licensed under [ BAAI Aquila Model Licence Agreement](https://huggingface.co/BAAI/AquilaChat2-34B-16K/blob/main/BAAI-Aquila-Model-License%20-Agreement.pdf)