Znerual commited on
Commit
322105c
•
1 Parent(s): 30a8060

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +281 -0
README.md CHANGED
@@ -1,3 +1,284 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ datasets:
4
+ - cerebras/SlimPajama-627B
5
+ - bigcode/starcoderdata
6
+ language:
7
+ - en
8
+ model_creator: TinyLlama
9
+ model_name: Tinyllama 1.1B Intermediate Step 1431K 3T
10
+ model_type: tinyllama
11
+ prompt_template: '{prompt}'
12
+
13
+ quantized_by: Znerual
14
  ---
15
+ <div align="center">
16
+
17
+
18
+ # Tinyllama 1.1B Intermediate Step 1431K 3T - AWQ
19
+
20
+ ## Description
21
+
22
+ ### About AWQ
23
+
24
+ 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.
25
+
26
+ AWQ models are currently supported on Linux and Windows, with NVidia GPUs only. macOS users: please use GGUF models instead.
27
+
28
+ It is supported by:
29
+
30
+ - [Text Generation Webui](https://github.com/oobabooga/text-generation-webui) - using Loader: AutoAWQ
31
+ - [vLLM](https://github.com/vllm-project/vllm) - version 0.2.2 or later for support for all model types.
32
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference)
33
+ - [Transformers](https://huggingface.co/docs/transformers) version 4.35.0 and later, from any code or client that supports Transformers
34
+ - [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) - for use from Python code
35
+
36
+ <!-- description end -->
37
+ <!-- repositories-available start -->
38
+
39
+ <!-- README_AWQ.md-provided-files end -->
40
+
41
+ <!-- README_AWQ.md-text-generation-webui start -->
42
+ ## How to easily download and use this model in [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
43
+
44
+ Please make sure you're using the latest version of [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
45
+
46
+ 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.
47
+
48
+ 1. Click the **Model tab**.
49
+ 2. Under **Download custom model or LoRA**, enter `Znerual/TinyLlama-1.1B-intermediate-step-1431k-3T-AWQ`.
50
+ 3. Click **Download**.
51
+ 4. The model will start downloading. Once it's finished it will say "Done".
52
+ 5. In the top left, click the refresh icon next to **Model**.
53
+ 6. In the **Model** dropdown, choose the model you just downloaded: `TinyLlama-1.1B-intermediate-step-1431k-3T-AWQ`
54
+ 7. Select **Loader: AutoAWQ**.
55
+ 8. Click Load, and the model will load and is now ready for use.
56
+ 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.
57
+ 10. Once you're ready, click the **Text Generation** tab and enter a prompt to get started!
58
+ <!-- README_AWQ.md-text-generation-webui end -->
59
+
60
+ <!-- README_AWQ.md-use-from-vllm start -->
61
+ ## Multi-user inference server: vLLM
62
+
63
+ Documentation on installing and using vLLM [can be found here](https://vllm.readthedocs.io/en/latest/).
64
+
65
+ - Please ensure you are using vLLM version 0.2 or later.
66
+ - When using vLLM as a server, pass the `--quantization awq` parameter.
67
+
68
+ For example:
69
+
70
+ ```shell
71
+ python3 -m vllm.entrypoints.api_server --model Znerual/TinyLlama-1.1B-intermediate-step-1431k-3T-AWQ --quantization awq --dtype auto
72
+ ```
73
+
74
+ - When using vLLM from Python code, again set `quantization=awq`.
75
+
76
+ For example:
77
+
78
+ ```python
79
+ from vllm import LLM, SamplingParams
80
+
81
+ prompts = [
82
+ "Tell me about AI",
83
+ "Write a story about llamas",
84
+ "What is 291 - 150?",
85
+ "How much wood would a woodchuck chuck if a woodchuck could chuck wood?",
86
+ ]
87
+ prompt_template=f'''[INST] {prompt} [/INST]
88
+ '''
89
+
90
+ prompts = [prompt_template.format(prompt=prompt) for prompt in prompts]
91
+
92
+ sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
93
+
94
+ llm = LLM(model="Znerual/TinyLlama-1.1B-intermediate-step-1431k-3T-AWQ", quantization="awq", dtype="auto")
95
+
96
+ outputs = llm.generate(prompts, sampling_params)
97
+
98
+ # Print the outputs.
99
+ for output in outputs:
100
+ prompt = output.prompt
101
+ generated_text = output.outputs[0].text
102
+ print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
103
+ ```
104
+ <!-- README_AWQ.md-use-from-vllm start -->
105
+
106
+ <!-- README_AWQ.md-use-from-tgi start -->
107
+ ## Multi-user inference server: Hugging Face Text Generation Inference (TGI)
108
+
109
+ Use TGI version 1.1.0 or later. The official Docker container is: `ghcr.io/huggingface/text-generation-inference:1.1.0`
110
+
111
+ Example Docker parameters:
112
+
113
+ ```shell
114
+ --model-id Znerual/TinyLlama-1.1B-intermediate-step-1431k-3T-AWQ --port 3000 --quantize awq --max-input-length 1902 --max-total-tokens 2048 --max-batch-prefill-tokens 2048
115
+ ```
116
+
117
+ Example Python code for interfacing with TGI (requires [huggingface-hub](https://github.com/huggingface/huggingface_hub) 0.17.0 or later):
118
+
119
+ ```shell
120
+ pip3 install huggingface-hub
121
+ ```
122
+
123
+ ```python
124
+ from huggingface_hub import InferenceClient
125
+
126
+ endpoint_url = "https://your-endpoint-url-here"
127
+
128
+ prompt = "Tell me about AI"
129
+ prompt_template=f'''[INST] {prompt} [/INST]
130
+ '''
131
+
132
+ client = InferenceClient(endpoint_url)
133
+ response = client.text_generation(prompt,
134
+ max_new_tokens=128,
135
+ do_sample=True,
136
+ temperature=0.7,
137
+ top_p=0.95,
138
+ top_k=40,
139
+ repetition_penalty=1.1)
140
+
141
+ print(f"Model output: ", response)
142
+ ```
143
+ <!-- README_AWQ.md-use-from-tgi end -->
144
+
145
+ <!-- README_AWQ.md-use-from-python start -->
146
+ ## Inference from Python code using Transformers
147
+
148
+ ### Install the necessary packages
149
+
150
+ - Requires: [Transformers](https://huggingface.co/docs/transformers) 4.35.0 or later.
151
+ - Requires: [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) 0.1.6 or later.
152
+
153
+ ```shell
154
+ pip3 install --upgrade "autoawq>=0.1.6" "transformers>=4.35.0"
155
+ ```
156
+
157
+ Note that if you are using PyTorch 2.0.1, the above AutoAWQ command will automatically upgrade you to PyTorch 2.1.0.
158
+
159
+ If you are using CUDA 11.8 and wish to continue using PyTorch 2.0.1, instead run this command:
160
+
161
+ ```shell
162
+ pip3 install https://github.com/casper-hansen/AutoAWQ/releases/download/v0.1.6/autoawq-0.1.6+cu118-cp310-cp310-linux_x86_64.whl
163
+ ```
164
+
165
+ If you have problems installing [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) using the pre-built wheels, install it from source instead:
166
+
167
+ ```shell
168
+ pip3 uninstall -y autoawq
169
+ git clone https://github.com/casper-hansen/AutoAWQ
170
+ cd AutoAWQ
171
+ pip3 install .
172
+ ```
173
+
174
+ ### Transformers example code (requires Transformers 4.35.0 and later)
175
+
176
+ ```python
177
+ from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
178
+
179
+ model_name_or_path = "Znerual/TinyLlama-1.1B-intermediate-step-1431k-3T-AWQ"
180
+
181
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
182
+ model = AutoModelForCausalLM.from_pretrained(
183
+ model_name_or_path,
184
+ low_cpu_mem_usage=True,
185
+ device_map="cuda:0"
186
+ )
187
+
188
+ # Using the text streamer to stream output one token at a time
189
+ streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
190
+
191
+ prompt = "Tell me about AI"
192
+ prompt_template=f'''[INST] {prompt} [/INST]
193
+ '''
194
+
195
+ # Convert prompt to tokens
196
+ tokens = tokenizer(
197
+ prompt_template,
198
+ return_tensors='pt'
199
+ ).input_ids.cuda()
200
+
201
+ generation_params = {
202
+ "do_sample": True,
203
+ "temperature": 0.7,
204
+ "top_p": 0.95,
205
+ "top_k": 40,
206
+ "max_new_tokens": 512,
207
+ "repetition_penalty": 1.1
208
+ }
209
+
210
+ # Generate streamed output, visible one token at a time
211
+ generation_output = model.generate(
212
+ tokens,
213
+ streamer=streamer,
214
+ **generation_params
215
+ )
216
+
217
+ # Generation without a streamer, which will include the prompt in the output
218
+ generation_output = model.generate(
219
+ tokens,
220
+ **generation_params
221
+ )
222
+
223
+ # Get the tokens from the output, decode them, print them
224
+ token_output = generation_output[0]
225
+ text_output = tokenizer.decode(token_output)
226
+ print("model.generate output: ", text_output)
227
+
228
+ # Inference is also possible via Transformers' pipeline
229
+ from transformers import pipeline
230
+
231
+ pipe = pipeline(
232
+ "text-generation",
233
+ model=model,
234
+ tokenizer=tokenizer,
235
+ **generation_params
236
+ )
237
+
238
+ pipe_output = pipe(prompt_template)[0]['generated_text']
239
+ print("pipeline output: ", pipe_output)
240
+
241
+ ```
242
+ <!-- README_AWQ.md-use-from-python end -->
243
+
244
+ <!-- README_AWQ.md-compatibility start -->
245
+ ## Compatibility
246
+
247
+ The files provided are tested to work with:
248
+
249
+ - [text-generation-webui](https://github.com/oobabooga/text-generation-webui) using `Loader: AutoAWQ`.
250
+ - [vLLM](https://github.com/vllm-project/vllm) version 0.2.0 and later.
251
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference) version 1.1.0 and later.
252
+ - [Transformers](https://huggingface.co/docs/transformers) version 4.35.0 and later.
253
+ - [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) version 0.1.1 and later.
254
+
255
+
256
+ # Original model card: Tinyllama 1.1B
257
+
258
+ </div>
259
+
260
+ https://github.com/jzhang38/TinyLlama
261
+
262
+ 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.
263
+
264
+ <div align="center">
265
+ <img src="./TinyLlama_logo.png" width="300"/>
266
+ </div>
267
+
268
+ 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.
269
+
270
+ #### This Collection
271
+ This collection contains all checkpoints after the 1T fix. Branch name indicates the step and number of tokens seen.
272
+
273
+ #### Eval
274
+
275
+ | Model | Pretrain Tokens | HellaSwag | Obqa | WinoGrande | ARC_c | ARC_e | boolq | piqa | avg |
276
+ |-------------------------------------------|-----------------|-----------|------|------------|-------|-------|-------|------|-----|
277
+ | Pythia-1.0B | 300B | 47.16 | 31.40| 53.43 | 27.05 | 48.99 | 60.83 | 69.21 | 48.30 |
278
+ | TinyLlama-1.1B-intermediate-step-50K-104b | 103B | 43.50 | 29.80| 53.28 | 24.32 | 44.91 | 59.66 | 67.30 | 46.11|
279
+ | TinyLlama-1.1B-intermediate-step-240k-503b| 503B | 49.56 |31.40 |55.80 |26.54 |48.32 |56.91 |69.42 | 48.28 |
280
+ | TinyLlama-1.1B-intermediate-step-480k-1007B | 1007B | 52.54 | 33.40 | 55.96 | 27.82 | 52.36 | 59.54 | 69.91 | 50.22 |
281
+ | TinyLlama-1.1B-intermediate-step-715k-1.5T | 1.5T | 53.68 | 35.20 | 58.33 | 29.18 | 51.89 | 59.08 | 71.65 | 51.29 |
282
+ | TinyLlama-1.1B-intermediate-step-955k-2T | 2T | 54.63 | 33.40 | 56.83 | 28.07 | 54.67 | 63.21 | 70.67 | 51.64 |
283
+ | TinyLlama-1.1B-intermediate-step-1195k-2.5T | 2.5T | 58.96 | 34.40 | 58.72 | 31.91 | 56.78 | 63.21 | 73.07 | 53.86|
284
+ | TinyLlama-1.1B-intermediate-step-1431k-3T | 3T | 59.20 | 36.00 | 59.12 | 30.12 | 55.25 | 57.83 | 73.29 | 52.99|