TheBloke commited on
Commit
0c6ba90
1 Parent(s): 130f5c5

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +409 -0
README.md ADDED
@@ -0,0 +1,409 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: cyberagent/calm2-7b-chat
3
+ inference: false
4
+ language:
5
+ - ja
6
+ - en
7
+ license: apache-2.0
8
+ model_creator: CyberAgent
9
+ model_name: Calm2 7B Chat
10
+ model_type: llama
11
+ prompt_template: 'USER: {prompt}
12
+
13
+ ASSISTANT:
14
+
15
+ '
16
+ quantized_by: TheBloke
17
+ tags:
18
+ - japanese
19
+ - causal-lm
20
+ ---
21
+ <!-- markdownlint-disable MD041 -->
22
+
23
+ <!-- header start -->
24
+ <!-- 200823 -->
25
+ <div style="width: auto; margin-left: auto; margin-right: auto">
26
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
27
+ </div>
28
+ <div style="display: flex; justify-content: space-between; width: 100%;">
29
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
30
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
31
+ </div>
32
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
33
+ <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>
34
+ </div>
35
+ </div>
36
+ <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>
37
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
38
+ <!-- header end -->
39
+
40
+ # Calm2 7B Chat - AWQ
41
+ - Model creator: [CyberAgent](https://huggingface.co/cyberagent)
42
+ - Original model: [Calm2 7B Chat](https://huggingface.co/cyberagent/calm2-7b-chat)
43
+
44
+ <!-- description start -->
45
+ ## Description
46
+
47
+ This repo contains AWQ model files for [CyberAgent's Calm2 7B Chat](https://huggingface.co/cyberagent/calm2-7b-chat).
48
+
49
+ These files were quantised using hardware kindly provided by [Massed Compute](https://massedcompute.com/).
50
+
51
+
52
+ ### About AWQ
53
+
54
+ 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.
55
+
56
+ It is supported by:
57
+
58
+ - [Text Generation Webui](https://github.com/oobabooga/text-generation-webui) - using Loader: AutoAWQ
59
+ - [vLLM](https://github.com/vllm-project/vllm) - Llama and Mistral models only
60
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference)
61
+ - [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) - for use from Python code
62
+
63
+ <!-- description end -->
64
+ <!-- repositories-available start -->
65
+ ## Repositories available
66
+
67
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/calm2-7B-chat-AWQ)
68
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/calm2-7B-chat-GPTQ)
69
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/calm2-7B-chat-GGUF)
70
+ * [CyberAgent's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/cyberagent/calm2-7b-chat)
71
+ <!-- repositories-available end -->
72
+
73
+ <!-- prompt-template start -->
74
+ ## Prompt template: User-Assistant
75
+
76
+ ```
77
+ USER: {prompt}
78
+ ASSISTANT:
79
+
80
+ ```
81
+
82
+ <!-- prompt-template end -->
83
+ <!-- licensing start -->
84
+ ## Licensing
85
+
86
+ The creator of the source model has listed its license as `apache-2.0`, and this quantization has therefore used that same license.
87
+
88
+ As this model is based on Llama 2, it is also subject to the Meta Llama 2 license terms, and the license files for that are additionally included. It should therefore be considered as being claimed to be licensed under both licenses. I contacted Hugging Face for clarification on dual licensing but they do not yet have an official position. Should this change, or should Meta provide any feedback on this situation, I will update this section accordingly.
89
+
90
+ In the meantime, any questions regarding licensing, and in particular how these two licenses might interact, should be directed to the original model repository: [CyberAgent's Calm2 7B Chat](https://huggingface.co/cyberagent/calm2-7b-chat).
91
+ <!-- licensing end -->
92
+ <!-- README_AWQ.md-provided-files start -->
93
+ ## Provided files, and AWQ parameters
94
+
95
+ 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.
96
+
97
+ Models are released as sharded safetensors files.
98
+
99
+ | Branch | Bits | GS | AWQ Dataset | Seq Len | Size |
100
+ | ------ | ---- | -- | ----------- | ------- | ---- |
101
+ | [main](https://huggingface.co/TheBloke/calm2-7B-chat-AWQ/tree/main) | 4 | 128 | japanese | 4096 | 4.43 GB
102
+
103
+ <!-- README_AWQ.md-provided-files end -->
104
+
105
+ <!-- README_AWQ.md-text-generation-webui start -->
106
+ ## How to easily download and use this model in [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
107
+
108
+ Please make sure you're using the latest version of [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
109
+
110
+ 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.
111
+
112
+ 1. Click the **Model tab**.
113
+ 2. Under **Download custom model or LoRA**, enter `TheBloke/calm2-7B-chat-AWQ`.
114
+ 3. Click **Download**.
115
+ 4. The model will start downloading. Once it's finished it will say "Done".
116
+ 5. In the top left, click the refresh icon next to **Model**.
117
+ 6. In the **Model** dropdown, choose the model you just downloaded: `calm2-7B-chat-AWQ`
118
+ 7. Select **Loader: AutoAWQ**.
119
+ 8. Click Load, and the model will load and is now ready for use.
120
+ 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.
121
+ 10. Once you're ready, click the **Text Generation** tab and enter a prompt to get started!
122
+ <!-- README_AWQ.md-text-generation-webui end -->
123
+
124
+ <!-- README_AWQ.md-use-from-vllm start -->
125
+ ## Multi-user inference server: vLLM
126
+
127
+ Documentation on installing and using vLLM [can be found here](https://vllm.readthedocs.io/en/latest/).
128
+
129
+ - Please ensure you are using vLLM version 0.2 or later.
130
+ - When using vLLM as a server, pass the `--quantization awq` parameter.
131
+
132
+ For example:
133
+
134
+ ```shell
135
+ python3 python -m vllm.entrypoints.api_server --model TheBloke/calm2-7B-chat-AWQ --quantization awq
136
+ ```
137
+
138
+ - When using vLLM from Python code, again set `quantization=awq`.
139
+
140
+ For example:
141
+
142
+ ```python
143
+ from vllm import LLM, SamplingParams
144
+
145
+ prompts = [
146
+ "Tell me about AI",
147
+ "Write a story about llamas",
148
+ "What is 291 - 150?",
149
+ "How much wood would a woodchuck chuck if a woodchuck could chuck wood?",
150
+ ]
151
+ prompt_template=f'''USER: {prompt}
152
+ ASSISTANT:
153
+ '''
154
+
155
+ prompts = [prompt_template.format(prompt=prompt) for prompt in prompts]
156
+
157
+ sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
158
+
159
+ llm = LLM(model="TheBloke/calm2-7B-chat-AWQ", quantization="awq", dtype="auto")
160
+
161
+ outputs = llm.generate(prompts, sampling_params)
162
+
163
+ # Print the outputs.
164
+ for output in outputs:
165
+ prompt = output.prompt
166
+ generated_text = output.outputs[0].text
167
+ print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
168
+ ```
169
+ <!-- README_AWQ.md-use-from-vllm start -->
170
+
171
+ <!-- README_AWQ.md-use-from-tgi start -->
172
+ ## Multi-user inference server: Hugging Face Text Generation Inference (TGI)
173
+
174
+ Use TGI version 1.1.0 or later. The official Docker container is: `ghcr.io/huggingface/text-generation-inference:1.1.0`
175
+
176
+ Example Docker parameters:
177
+
178
+ ```shell
179
+ --model-id TheBloke/calm2-7B-chat-AWQ --port 3000 --quantize awq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
180
+ ```
181
+
182
+ Example Python code for interfacing with TGI (requires [huggingface-hub](https://github.com/huggingface/huggingface_hub) 0.17.0 or later):
183
+
184
+ ```shell
185
+ pip3 install huggingface-hub
186
+ ```
187
+
188
+ ```python
189
+ from huggingface_hub import InferenceClient
190
+
191
+ endpoint_url = "https://your-endpoint-url-here"
192
+
193
+ prompt = "Tell me about AI"
194
+ prompt_template=f'''USER: {prompt}
195
+ ASSISTANT:
196
+ '''
197
+
198
+ client = InferenceClient(endpoint_url)
199
+ response = client.text_generation(prompt,
200
+ max_new_tokens=128,
201
+ do_sample=True,
202
+ temperature=0.7,
203
+ top_p=0.95,
204
+ top_k=40,
205
+ repetition_penalty=1.1)
206
+
207
+ print(f"Model output: ", response)
208
+ ```
209
+ <!-- README_AWQ.md-use-from-tgi end -->
210
+
211
+ <!-- README_AWQ.md-use-from-python start -->
212
+ ## Inference from Python code using AutoAWQ
213
+
214
+ ### Install the AutoAWQ package
215
+
216
+ Requires: [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) 0.1.1 or later.
217
+
218
+ ```shell
219
+ pip3 install autoawq
220
+ ```
221
+
222
+ If you have problems installing [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) using the pre-built wheels, install it from source instead:
223
+
224
+ ```shell
225
+ pip3 uninstall -y autoawq
226
+ git clone https://github.com/casper-hansen/AutoAWQ
227
+ cd AutoAWQ
228
+ pip3 install .
229
+ ```
230
+
231
+ ### AutoAWQ example code
232
+
233
+ ```python
234
+ from awq import AutoAWQForCausalLM
235
+ from transformers import AutoTokenizer
236
+
237
+ model_name_or_path = "TheBloke/calm2-7B-chat-AWQ"
238
+
239
+ # Load tokenizer
240
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=False)
241
+ # Load model
242
+ model = AutoAWQForCausalLM.from_quantized(model_name_or_path, fuse_layers=True,
243
+ trust_remote_code=False, safetensors=True)
244
+
245
+ prompt = "Tell me about AI"
246
+ prompt_template=f'''USER: {prompt}
247
+ ASSISTANT:
248
+ '''
249
+
250
+ print("*** Running model.generate:")
251
+
252
+ token_input = tokenizer(
253
+ prompt_template,
254
+ return_tensors='pt'
255
+ ).input_ids.cuda()
256
+
257
+ # Generate output
258
+ generation_output = model.generate(
259
+ token_input,
260
+ do_sample=True,
261
+ temperature=0.7,
262
+ top_p=0.95,
263
+ top_k=40,
264
+ max_new_tokens=512
265
+ )
266
+
267
+ # Get the tokens from the output, decode them, print them
268
+ token_output = generation_output[0]
269
+ text_output = tokenizer.decode(token_output)
270
+ print("LLM output: ", text_output)
271
+
272
+ """
273
+ # Inference should be possible with transformers pipeline as well in future
274
+ # But currently this is not yet supported by AutoAWQ (correct as of September 25th 2023)
275
+ from transformers import pipeline
276
+
277
+ print("*** Pipeline:")
278
+ pipe = pipeline(
279
+ "text-generation",
280
+ model=model,
281
+ tokenizer=tokenizer,
282
+ max_new_tokens=512,
283
+ do_sample=True,
284
+ temperature=0.7,
285
+ top_p=0.95,
286
+ top_k=40,
287
+ repetition_penalty=1.1
288
+ )
289
+
290
+ print(pipe(prompt_template)[0]['generated_text'])
291
+ """
292
+ ```
293
+ <!-- README_AWQ.md-use-from-python end -->
294
+
295
+ <!-- README_AWQ.md-compatibility start -->
296
+ ## Compatibility
297
+
298
+ The files provided are tested to work with:
299
+
300
+ - [text-generation-webui](https://github.com/oobabooga/text-generation-webui) using `Loader: AutoAWQ`.
301
+ - [vLLM](https://github.com/vllm-project/vllm) version 0.2.0 and later.
302
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference) version 1.1.0 and later.
303
+ - [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) version 0.1.1 and later.
304
+
305
+ <!-- README_AWQ.md-compatibility end -->
306
+
307
+ <!-- footer start -->
308
+ <!-- 200823 -->
309
+ ## Discord
310
+
311
+ For further support, and discussions on these models and AI in general, join us at:
312
+
313
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
314
+
315
+ ## Thanks, and how to contribute
316
+
317
+ Thanks to the [chirper.ai](https://chirper.ai) team!
318
+
319
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
320
+
321
+ 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.
322
+
323
+ 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.
324
+
325
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
326
+
327
+ * Patreon: https://patreon.com/TheBlokeAI
328
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
329
+
330
+ **Special thanks to**: Aemon Algiz.
331
+
332
+ **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
333
+
334
+
335
+ Thank you to all my generous patrons and donaters!
336
+
337
+ And thank you again to a16z for their generous grant.
338
+
339
+ <!-- footer end -->
340
+
341
+ # Original model card: CyberAgent's Calm2 7B Chat
342
+
343
+ # CyberAgentLM2-7B-Chat (CALM2-7B-Chat)
344
+
345
+ ## Model Description
346
+
347
+ CyberAgentLM2-Chat is a fine-tuned model of [CyberAgentLM2](https://huggingface.co/cyberagent/calm2-7b) for dialogue use cases.
348
+
349
+ ## Requirements
350
+ - transformers >= 4.34.1
351
+ - accelerate
352
+
353
+ ## Usage
354
+
355
+ ```python
356
+ import transformers
357
+ from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
358
+
359
+ assert transformers.__version__ >= "4.34.1"
360
+
361
+ model = AutoModelForCausalLM.from_pretrained("cyberagent/calm2-7b-chat", device_map="auto", torch_dtype="auto")
362
+ tokenizer = AutoTokenizer.from_pretrained("cyberagent/calm2-7b-chat")
363
+ streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
364
+
365
+ prompt = """USER: AIによって私達の暮らしはどのように変わりますか?
366
+ ASSISTANT: """
367
+
368
+ token_ids = tokenizer.encode(prompt, return_tensors="pt")
369
+ output_ids = model.generate(
370
+ input_ids=token_ids.to(model.device),
371
+ max_new_tokens=300,
372
+ do_sample=True,
373
+ temperature=0.8,
374
+ streamer=streamer,
375
+ )
376
+ ```
377
+
378
+ ## Chat Template
379
+ ```
380
+ USER: {user_message1}
381
+ ASSISTANT: {assistant_message1}<|endoftext|>
382
+ USER: {user_message2}
383
+ ASSISTANT: {assistant_message2}<|endoftext|>
384
+ USER: {user_message3}
385
+ ASSISTANT: {assistant_message3}<|endoftext|>
386
+ ```
387
+
388
+ ## Model Details
389
+
390
+ * **Model size**: 7B
391
+ * **Context length**: 32768
392
+ * **Model type**: Transformer-based Language Model
393
+ * **Language(s)**: Japanese, English
394
+ * **Developed by**: [CyberAgent, Inc.](https://www.cyberagent.co.jp/)
395
+ * **License**: Apache-2.0
396
+
397
+ ## Author
398
+
399
+ [Ryosuke Ishigami](https://huggingface.co/rishigami)
400
+
401
+ ## Citations
402
+ ```tex
403
+ @article{touvron2023llama,
404
+ title={LLaMA: Open and Efficient Foundation Language Models},
405
+ 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},
406
+ journal={arXiv preprint arXiv:2302.13971},
407
+ year={2023}
408
+ }
409
+ ```