TheBloke commited on
Commit
1bbb0f0
1 Parent(s): f48412c

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +364 -0
README.md ADDED
@@ -0,0 +1,364 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: PY007/TinyLlama-1.1B-intermediate-step-480k-1T
3
+ datasets:
4
+ - cerebras/SlimPajama-627B
5
+ - bigcode/starcoderdata
6
+ inference: false
7
+ language:
8
+ - en
9
+ license: apache-2.0
10
+ model_creator: Zhang Peiyuan
11
+ model_name: TinyLlama 1.1B Intermediate Step 480K 1T
12
+ model_type: tinyllama
13
+ prompt_template: '<|im_start|>system
14
+
15
+ {system_message}<|im_end|>
16
+
17
+ <|im_start|>user
18
+
19
+ {prompt}<|im_end|>
20
+
21
+ <|im_start|>assistant
22
+
23
+ '
24
+ quantized_by: TheBloke
25
+ ---
26
+
27
+ <!-- header start -->
28
+ <!-- 200823 -->
29
+ <div style="width: auto; margin-left: auto; margin-right: auto">
30
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
31
+ </div>
32
+ <div style="display: flex; justify-content: space-between; width: 100%;">
33
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
34
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
35
+ </div>
36
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
37
+ <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>
38
+ </div>
39
+ </div>
40
+ <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>
41
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
42
+ <!-- header end -->
43
+
44
+ # TinyLlama 1.1B Intermediate Step 480K 1T - AWQ
45
+ - Model creator: [Zhang Peiyuan](https://huggingface.co/PY007)
46
+ - Original model: [TinyLlama 1.1B Intermediate Step 480K 1T](https://huggingface.co/PY007/TinyLlama-1.1B-intermediate-step-480k-1T)
47
+
48
+ <!-- description start -->
49
+ ## Description
50
+
51
+ This repo contains AWQ model files for [Zhang Peiyuan's TinyLlama 1.1B Intermediate Step 480K 1T](https://huggingface.co/PY007/TinyLlama-1.1B-intermediate-step-480k-1T).
52
+
53
+
54
+ ### About AWQ
55
+
56
+ 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.
57
+
58
+ It is also now supported by continuous batching server [vLLM](https://github.com/vllm-project/vllm), allowing use of Llama AWQ models for high-throughput concurrent inference in multi-user server scenarios.
59
+
60
+ As of September 25th 2023, preliminary Llama-only AWQ support has also been added to [Huggingface Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference).
61
+
62
+ Note that, at the time of writing, overall throughput is still lower than running vLLM or TGI with unquantised models, however using AWQ enables using much smaller GPUs which can lead to easier deployment and overall cost savings. For example, a 70B model can be run on 1 x 48GB GPU instead of 2 x 80GB.
63
+ <!-- description end -->
64
+ <!-- repositories-available start -->
65
+ ## Repositories available
66
+
67
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/TinyLlama-1.1B-intermediate-step-480k-1T-AWQ)
68
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/TinyLlama-1.1B-intermediate-step-480k-1T-GPTQ)
69
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/TinyLlama-1.1B-intermediate-step-480k-1T-GGUF)
70
+ * [Zhang Peiyuan's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/PY007/TinyLlama-1.1B-intermediate-step-480k-1T)
71
+ <!-- repositories-available end -->
72
+
73
+ <!-- prompt-template start -->
74
+ ## Prompt template: ChatML
75
+
76
+ ```
77
+ <|im_start|>system
78
+ {system_message}<|im_end|>
79
+ <|im_start|>user
80
+ {prompt}<|im_end|>
81
+ <|im_start|>assistant
82
+
83
+ ```
84
+
85
+ <!-- prompt-template end -->
86
+
87
+
88
+ <!-- README_AWQ.md-provided-files start -->
89
+ ## Provided files, and AWQ parameters
90
+
91
+ 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.
92
+
93
+ Models are released as sharded safetensors files.
94
+
95
+ | Branch | Bits | GS | AWQ Dataset | Seq Len | Size |
96
+ | ------ | ---- | -- | ----------- | ------- | ---- |
97
+ | [main](https://huggingface.co/TheBloke/TinyLlama-1.1B-intermediate-step-480k-1T-AWQ/tree/main) | 4 | 128 | [wikitext](https://huggingface.co/datasets/wikitext/viewer/wikitext-2-v1/test) | 2048 | 0.77 GB
98
+
99
+ <!-- README_AWQ.md-provided-files end -->
100
+
101
+ <!-- README_AWQ.md-use-from-vllm start -->
102
+ ## Serving this model from vLLM
103
+
104
+ Documentation on installing and using vLLM [can be found here](https://vllm.readthedocs.io/en/latest/).
105
+
106
+ Note: at the time of writing, vLLM has not yet done a new release with AWQ support.
107
+
108
+ If you try the vLLM examples below and get an error about `quantization` being unrecognised, or other AWQ-related issues, please install vLLM from Github source.
109
+
110
+ - When using vLLM as a server, pass the `--quantization awq` parameter, for example:
111
+
112
+ ```shell
113
+ python3 python -m vllm.entrypoints.api_server --model TheBloke/TinyLlama-1.1B-intermediate-step-480k-1T-AWQ --quantization awq --dtype half
114
+ ```
115
+
116
+ When using vLLM from Python code, pass the `quantization=awq` parameter, for example:
117
+
118
+ ```python
119
+ from vllm import LLM, SamplingParams
120
+
121
+ prompts = [
122
+ "Hello, my name is",
123
+ "The president of the United States is",
124
+ "The capital of France is",
125
+ "The future of AI is",
126
+ ]
127
+ sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
128
+
129
+ llm = LLM(model="TheBloke/TinyLlama-1.1B-intermediate-step-480k-1T-AWQ", quantization="awq", dtype="half")
130
+
131
+ outputs = llm.generate(prompts, sampling_params)
132
+
133
+ # Print the outputs.
134
+ for output in outputs:
135
+ prompt = output.prompt
136
+ generated_text = output.outputs[0].text
137
+ print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
138
+ ```
139
+ <!-- README_AWQ.md-use-from-vllm start -->
140
+
141
+ <!-- README_AWQ.md-use-from-tgi start -->
142
+ ## Serving this model from Text Generation Inference (TGI)
143
+
144
+ Use TGI version 1.1.0 or later. The official Docker container is: `ghcr.io/huggingface/text-generation-inference:1.1.0`
145
+
146
+ Example Docker parameters:
147
+
148
+ ```shell
149
+ --model-id TheBloke/TinyLlama-1.1B-intermediate-step-480k-1T-AWQ --port 3000 --quantize awq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
150
+ ```
151
+
152
+ Example Python code for interfacing with TGI (requires huggingface-hub 0.17.0 or later):
153
+
154
+ ```shell
155
+ pip3 install huggingface-hub
156
+ ```
157
+
158
+ ```python
159
+ from huggingface_hub import InferenceClient
160
+
161
+ endpoint_url = "https://your-endpoint-url-here"
162
+
163
+ prompt = "Tell me about AI"
164
+ prompt_template=f'''<|im_start|>system
165
+ {system_message}<|im_end|>
166
+ <|im_start|>user
167
+ {prompt}<|im_end|>
168
+ <|im_start|>assistant
169
+
170
+ '''
171
+
172
+ client = InferenceClient(endpoint_url)
173
+ response = client.text_generation(prompt,
174
+ max_new_tokens=128,
175
+ do_sample=True,
176
+ temperature=0.7,
177
+ top_p=0.95,
178
+ top_k=40,
179
+ repetition_penalty=1.1)
180
+
181
+ print(f"Model output: {response}")
182
+ ```
183
+ <!-- README_AWQ.md-use-from-tgi end -->
184
+
185
+ <!-- README_AWQ.md-use-from-python start -->
186
+ ## How to use this AWQ model from Python code
187
+
188
+ ### Install the necessary packages
189
+
190
+ Requires: [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) 0.1.1 or later
191
+
192
+ ```shell
193
+ pip3 install autoawq
194
+ ```
195
+
196
+ If you have problems installing [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) using the pre-built wheels, install it from source instead:
197
+
198
+ ```shell
199
+ pip3 uninstall -y autoawq
200
+ git clone https://github.com/casper-hansen/AutoAWQ
201
+ cd AutoAWQ
202
+ pip3 install .
203
+ ```
204
+
205
+ ### You can then try the following example code
206
+
207
+ ```python
208
+ from awq import AutoAWQForCausalLM
209
+ from transformers import AutoTokenizer
210
+
211
+ model_name_or_path = "TheBloke/TinyLlama-1.1B-intermediate-step-480k-1T-AWQ"
212
+
213
+ # Load model
214
+ model = AutoAWQForCausalLM.from_quantized(model_name_or_path, fuse_layers=True,
215
+ trust_remote_code=False, safetensors=True)
216
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=False)
217
+
218
+ prompt = "Tell me about AI"
219
+ prompt_template=f'''<|im_start|>system
220
+ {system_message}<|im_end|>
221
+ <|im_start|>user
222
+ {prompt}<|im_end|>
223
+ <|im_start|>assistant
224
+
225
+ '''
226
+
227
+ print("\n\n*** Generate:")
228
+
229
+ tokens = tokenizer(
230
+ prompt_template,
231
+ return_tensors='pt'
232
+ ).input_ids.cuda()
233
+
234
+ # Generate output
235
+ generation_output = model.generate(
236
+ tokens,
237
+ do_sample=True,
238
+ temperature=0.7,
239
+ top_p=0.95,
240
+ top_k=40,
241
+ max_new_tokens=512
242
+ )
243
+
244
+ print("Output: ", tokenizer.decode(generation_output[0]))
245
+
246
+ """
247
+ # Inference should be possible with transformers pipeline as well in future
248
+ # But currently this is not yet supported by AutoAWQ (correct as of September 25th 2023)
249
+ from transformers import pipeline
250
+
251
+ print("*** Pipeline:")
252
+ pipe = pipeline(
253
+ "text-generation",
254
+ model=model,
255
+ tokenizer=tokenizer,
256
+ max_new_tokens=512,
257
+ do_sample=True,
258
+ temperature=0.7,
259
+ top_p=0.95,
260
+ top_k=40,
261
+ repetition_penalty=1.1
262
+ )
263
+
264
+ print(pipe(prompt_template)[0]['generated_text'])
265
+ """
266
+ ```
267
+ <!-- README_AWQ.md-use-from-python end -->
268
+
269
+ <!-- README_AWQ.md-compatibility start -->
270
+ ## Compatibility
271
+
272
+ The files provided are tested to work with:
273
+
274
+ - [AutoAWQ](https://github.com/casper-hansen/AutoAWQ)
275
+ - [vLLM](https://github.com/vllm-project/vllm)
276
+ - [Huggingface Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference)
277
+
278
+ TGI merged AWQ support on September 25th, 2023: [TGI PR #1054](https://github.com/huggingface/text-generation-inference/pull/1054). Use the `:latest` Docker container until the next TGI release is made.
279
+
280
+ <!-- README_AWQ.md-compatibility end -->
281
+
282
+ <!-- footer start -->
283
+ <!-- 200823 -->
284
+ ## Discord
285
+
286
+ For further support, and discussions on these models and AI in general, join us at:
287
+
288
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
289
+
290
+ ## Thanks, and how to contribute
291
+
292
+ Thanks to the [chirper.ai](https://chirper.ai) team!
293
+
294
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
295
+
296
+ 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.
297
+
298
+ 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.
299
+
300
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
301
+
302
+ * Patreon: https://patreon.com/TheBlokeAI
303
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
304
+
305
+ **Special thanks to**: Aemon Algiz.
306
+
307
+ **Patreon special mentions**: Pierre Kircher, Stanislav Ovsiannikov, Michael Levine, Eugene Pentland, Andrey, 준교 김, Randy H, Fred von Graf, Artur Olbinski, Caitlyn Gatomon, terasurfer, Jeff Scroggin, James Bentley, Vadim, Gabriel Puliatti, Harry Royden McLaughlin, Sean Connelly, Dan Guido, Edmond Seymore, Alicia Loh, subjectnull, AzureBlack, Manuel Alberto Morcote, Thomas Belote, Lone Striker, Chris Smitley, Vitor Caleffi, Johann-Peter Hartmann, Clay Pascal, biorpg, Brandon Frisco, sidney chen, transmissions 11, Pedro Madruga, jinyuan sun, Ajan Kanaga, Emad Mostaque, Trenton Dambrowitz, Jonathan Leane, Iucharbius, usrbinkat, vamX, George Stoitzev, Luke Pendergrass, theTransient, Olakabola, Swaroop Kallakuri, Cap'n Zoog, Brandon Phillips, Michael Dempsey, Nikolai Manek, danny, Matthew Berman, Gabriel Tamborski, alfie_i, Raymond Fosdick, Tom X Nguyen, Raven Klaugh, LangChain4j, Magnesian, Illia Dulskyi, David Ziegler, Mano Prime, Luis Javier Navarrete Lozano, Erik Bjäreholt, 阿明, Nathan Dryer, Alex, Rainer Wilmers, zynix, TL, Joseph William Delisle, John Villwock, Nathan LeClaire, Willem Michiel, Joguhyik, GodLy, OG, Alps Aficionado, Jeffrey Morgan, ReadyPlayerEmma, Tiffany J. Kim, Sebastain Graf, Spencer Kim, Michael Davis, webtim, Talal Aujan, knownsqashed, John Detwiler, Imad Khwaja, Deo Leter, Jerry Meng, Elijah Stavena, Rooh Singh, Pieter, SuperWojo, Alexandros Triantafyllidis, Stephen Murray, Ai Maven, ya boyyy, Enrico Ros, Ken Nordquist, Deep Realms, Nicholas, Spiking Neurons AB, Elle, Will Dee, Jack West, RoA, Luke @flexchar, Viktor Bowallius, Derek Yates, Subspace Studios, jjj, Toran Billups, Asp the Wyvern, Fen Risland, Ilya, NimbleBox.ai, Chadd, Nitin Borwankar, Emre, Mandus, Leonard Tan, Kalila, K, Trailburnt, S_X, Cory Kujawski
308
+
309
+
310
+ Thank you to all my generous patrons and donaters!
311
+
312
+ And thank you again to a16z for their generous grant.
313
+
314
+ <!-- footer end -->
315
+
316
+ # Original model card: Zhang Peiyuan's TinyLlama 1.1B Intermediate Step 480K 1T
317
+
318
+ <div align="center">
319
+
320
+ # TinyLlama-1.1B
321
+ </div>
322
+
323
+ https://github.com/jzhang38/TinyLlama
324
+
325
+ The TinyLlama project aims to **pretrain** a **1.1B Llama model on 3 trillion tokens**. With some proper optimization, we can achieve this within a span of "just" 90 days using 16 A100-40G GPUs 🚀🚀. The training has started on 2023-09-01.
326
+
327
+ <div align="center">
328
+ <img src="./TinyLlama_logo.png" width="300"/>
329
+ </div>
330
+
331
+ We adopted exactly the same architecture and tokenizer as Llama 2. This means TinyLlama can be plugged and played in many open-source projects built upon Llama. Besides, TinyLlama is compact with only 1.1B parameters. This compactness allows it to cater to a multitude of applications demanding a restricted computation and memory footprint.
332
+
333
+ #### This Model
334
+ This is an intermediate checkpoint with 480K steps and 1007B tokens.
335
+
336
+
337
+ #### How to use
338
+ You will need the transformers>=4.31
339
+ Do check the [TinyLlama](https://github.com/jzhang38/TinyLlama) github page for more information.
340
+ ```python
341
+ from transformers import AutoTokenizer
342
+ import transformers
343
+ import torch
344
+ model = "PY007/TinyLlama-1.1B-intermediate-step-240k-503b"
345
+ tokenizer = AutoTokenizer.from_pretrained(model)
346
+ pipeline = transformers.pipeline(
347
+ "text-generation",
348
+ model=model,
349
+ torch_dtype=torch.float16,
350
+ device_map="auto",
351
+ )
352
+
353
+ sequences = pipeline(
354
+ 'The TinyLlama project aims to pretrain a 1.1B Llama model on 3 trillion tokens. With some proper optimization, we can achieve this within a span of "just" 90 days using 16 A100-40G GPUs 🚀🚀. The training has started on 2023-09-01.',
355
+ do_sample=True,
356
+ top_k=10,
357
+ num_return_sequences=1,
358
+ repetition_penalty=1.5,
359
+ eos_token_id=tokenizer.eos_token_id,
360
+ max_length=500,
361
+ )
362
+ for seq in sequences:
363
+ print(f"Result: {seq['generated_text']}")
364
+ ```