TheBloke commited on
Commit
a9df98e
1 Parent(s): c59bc07

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +406 -0
README.md ADDED
@@ -0,0 +1,406 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: bkai-foundation-models/vietnamese-llama2-7b-40GB
3
+ datasets:
4
+ - vietgpt/wikipedia_vi
5
+ - wikipedia
6
+ - pg19
7
+ - mc4
8
+ inference: false
9
+ language:
10
+ - vi
11
+ - en
12
+ license: other
13
+ model_creator: BKAI-HUST Foundation Models Lab
14
+ model_name: Vietnamese Llama2 7B 40GB
15
+ model_type: llama
16
+ prompt_template: '{prompt}
17
+
18
+ '
19
+ quantized_by: TheBloke
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
+ # Vietnamese Llama2 7B 40GB - AWQ
41
+ - Model creator: [BKAI-HUST Foundation Models Lab](https://huggingface.co/bkai-foundation-models)
42
+ - Original model: [Vietnamese Llama2 7B 40GB](https://huggingface.co/bkai-foundation-models/vietnamese-llama2-7b-40GB)
43
+
44
+ <!-- description start -->
45
+ ## Description
46
+
47
+ This repo contains AWQ model files for [BKAI-HUST Foundation Models Lab's Vietnamese Llama2 7B 40GB](https://huggingface.co/bkai-foundation-models/vietnamese-llama2-7b-40GB).
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/vietnamese-llama2-7B-40GB-AWQ)
68
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/vietnamese-llama2-7B-40GB-GPTQ)
69
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/vietnamese-llama2-7B-40GB-GGUF)
70
+ * [BKAI-HUST Foundation Models Lab's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/bkai-foundation-models/vietnamese-llama2-7b-40GB)
71
+ <!-- repositories-available end -->
72
+
73
+ <!-- prompt-template start -->
74
+ ## Prompt template: None
75
+
76
+ ```
77
+ {prompt}
78
+
79
+ ```
80
+
81
+ <!-- prompt-template end -->
82
+ <!-- licensing start -->
83
+ ## Licensing
84
+
85
+ The creator of the source model has listed its license as `other`, and this quantization has therefore used that same license.
86
+
87
+ 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.
88
+
89
+ In the meantime, any questions regarding licensing, and in particular how these two licenses might interact, should be directed to the original model repository: [BKAI-HUST Foundation Models Lab's Vietnamese Llama2 7B 40GB](https://huggingface.co/bkai-foundation-models/vietnamese-llama2-7b-40GB).
90
+ <!-- licensing end -->
91
+ <!-- README_AWQ.md-provided-files start -->
92
+ ## Provided files, and AWQ parameters
93
+
94
+ 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.
95
+
96
+ Models are released as sharded safetensors files.
97
+
98
+ | Branch | Bits | GS | AWQ Dataset | Seq Len | Size |
99
+ | ------ | ---- | -- | ----------- | ------- | ---- |
100
+ | [main](https://huggingface.co/TheBloke/vietnamese-llama2-7B-40GB-AWQ/tree/main) | 4 | 128 | vietnamese | 2048 | 4.12 GB
101
+
102
+ <!-- README_AWQ.md-provided-files end -->
103
+
104
+ <!-- README_AWQ.md-text-generation-webui start -->
105
+ ## How to easily download and use this model in [text-generation-webui](https://github.com/oobabooga/text-generation-webui)
106
+
107
+ Please make sure you're using the latest version of [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
108
+
109
+ 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.
110
+
111
+ 1. Click the **Model tab**.
112
+ 2. Under **Download custom model or LoRA**, enter `TheBloke/vietnamese-llama2-7B-40GB-AWQ`.
113
+ 3. Click **Download**.
114
+ 4. The model will start downloading. Once it's finished it will say "Done".
115
+ 5. In the top left, click the refresh icon next to **Model**.
116
+ 6. In the **Model** dropdown, choose the model you just downloaded: `vietnamese-llama2-7B-40GB-AWQ`
117
+ 7. Select **Loader: AutoAWQ**.
118
+ 8. Click Load, and the model will load and is now ready for use.
119
+ 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.
120
+ 10. Once you're ready, click the **Text Generation** tab and enter a prompt to get started!
121
+ <!-- README_AWQ.md-text-generation-webui end -->
122
+
123
+ <!-- README_AWQ.md-use-from-vllm start -->
124
+ ## Multi-user inference server: vLLM
125
+
126
+ Documentation on installing and using vLLM [can be found here](https://vllm.readthedocs.io/en/latest/).
127
+
128
+ - Please ensure you are using vLLM version 0.2 or later.
129
+ - When using vLLM as a server, pass the `--quantization awq` parameter.
130
+
131
+ For example:
132
+
133
+ ```shell
134
+ python3 python -m vllm.entrypoints.api_server --model TheBloke/vietnamese-llama2-7B-40GB-AWQ --quantization awq
135
+ ```
136
+
137
+ - When using vLLM from Python code, again set `quantization=awq`.
138
+
139
+ For example:
140
+
141
+ ```python
142
+ from vllm import LLM, SamplingParams
143
+
144
+ prompts = [
145
+ "Tell me about AI",
146
+ "Write a story about llamas",
147
+ "What is 291 - 150?",
148
+ "How much wood would a woodchuck chuck if a woodchuck could chuck wood?",
149
+ ]
150
+ prompt_template=f'''{prompt}
151
+ '''
152
+
153
+ prompts = [prompt_template.format(prompt=prompt) for prompt in prompts]
154
+
155
+ sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
156
+
157
+ llm = LLM(model="TheBloke/vietnamese-llama2-7B-40GB-AWQ", quantization="awq", dtype="auto")
158
+
159
+ outputs = llm.generate(prompts, sampling_params)
160
+
161
+ # Print the outputs.
162
+ for output in outputs:
163
+ prompt = output.prompt
164
+ generated_text = output.outputs[0].text
165
+ print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
166
+ ```
167
+ <!-- README_AWQ.md-use-from-vllm start -->
168
+
169
+ <!-- README_AWQ.md-use-from-tgi start -->
170
+ ## Multi-user inference server: Hugging Face Text Generation Inference (TGI)
171
+
172
+ Use TGI version 1.1.0 or later. The official Docker container is: `ghcr.io/huggingface/text-generation-inference:1.1.0`
173
+
174
+ Example Docker parameters:
175
+
176
+ ```shell
177
+ --model-id TheBloke/vietnamese-llama2-7B-40GB-AWQ --port 3000 --quantize awq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
178
+ ```
179
+
180
+ Example Python code for interfacing with TGI (requires [huggingface-hub](https://github.com/huggingface/huggingface_hub) 0.17.0 or later):
181
+
182
+ ```shell
183
+ pip3 install huggingface-hub
184
+ ```
185
+
186
+ ```python
187
+ from huggingface_hub import InferenceClient
188
+
189
+ endpoint_url = "https://your-endpoint-url-here"
190
+
191
+ prompt = "Tell me about AI"
192
+ prompt_template=f'''{prompt}
193
+ '''
194
+
195
+ client = InferenceClient(endpoint_url)
196
+ response = client.text_generation(prompt,
197
+ max_new_tokens=128,
198
+ do_sample=True,
199
+ temperature=0.7,
200
+ top_p=0.95,
201
+ top_k=40,
202
+ repetition_penalty=1.1)
203
+
204
+ print(f"Model output: ", response)
205
+ ```
206
+ <!-- README_AWQ.md-use-from-tgi end -->
207
+
208
+ <!-- README_AWQ.md-use-from-python start -->
209
+ ## Inference from Python code using AutoAWQ
210
+
211
+ ### Install the AutoAWQ package
212
+
213
+ Requires: [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) 0.1.1 or later.
214
+
215
+ ```shell
216
+ pip3 install autoawq
217
+ ```
218
+
219
+ If you have problems installing [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) using the pre-built wheels, install it from source instead:
220
+
221
+ ```shell
222
+ pip3 uninstall -y autoawq
223
+ git clone https://github.com/casper-hansen/AutoAWQ
224
+ cd AutoAWQ
225
+ pip3 install .
226
+ ```
227
+
228
+ ### AutoAWQ example code
229
+
230
+ ```python
231
+ from awq import AutoAWQForCausalLM
232
+ from transformers import AutoTokenizer
233
+
234
+ model_name_or_path = "TheBloke/vietnamese-llama2-7B-40GB-AWQ"
235
+
236
+ # Load tokenizer
237
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=False)
238
+ # Load model
239
+ model = AutoAWQForCausalLM.from_quantized(model_name_or_path, fuse_layers=True,
240
+ trust_remote_code=False, safetensors=True)
241
+
242
+ prompt = "Tell me about AI"
243
+ prompt_template=f'''{prompt}
244
+ '''
245
+
246
+ print("*** Running model.generate:")
247
+
248
+ token_input = tokenizer(
249
+ prompt_template,
250
+ return_tensors='pt'
251
+ ).input_ids.cuda()
252
+
253
+ # Generate output
254
+ generation_output = model.generate(
255
+ token_input,
256
+ do_sample=True,
257
+ temperature=0.7,
258
+ top_p=0.95,
259
+ top_k=40,
260
+ max_new_tokens=512
261
+ )
262
+
263
+ # Get the tokens from the output, decode them, print them
264
+ token_output = generation_output[0]
265
+ text_output = tokenizer.decode(token_output)
266
+ print("LLM output: ", text_output)
267
+
268
+ """
269
+ # Inference should be possible with transformers pipeline as well in future
270
+ # But currently this is not yet supported by AutoAWQ (correct as of September 25th 2023)
271
+ from transformers import pipeline
272
+
273
+ print("*** Pipeline:")
274
+ pipe = pipeline(
275
+ "text-generation",
276
+ model=model,
277
+ tokenizer=tokenizer,
278
+ max_new_tokens=512,
279
+ do_sample=True,
280
+ temperature=0.7,
281
+ top_p=0.95,
282
+ top_k=40,
283
+ repetition_penalty=1.1
284
+ )
285
+
286
+ print(pipe(prompt_template)[0]['generated_text'])
287
+ """
288
+ ```
289
+ <!-- README_AWQ.md-use-from-python end -->
290
+
291
+ <!-- README_AWQ.md-compatibility start -->
292
+ ## Compatibility
293
+
294
+ The files provided are tested to work with:
295
+
296
+ - [text-generation-webui](https://github.com/oobabooga/text-generation-webui) using `Loader: AutoAWQ`.
297
+ - [vLLM](https://github.com/vllm-project/vllm) version 0.2.0 and later.
298
+ - [Hugging Face Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference) version 1.1.0 and later.
299
+ - [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) version 0.1.1 and later.
300
+
301
+ <!-- README_AWQ.md-compatibility end -->
302
+
303
+ <!-- footer start -->
304
+ <!-- 200823 -->
305
+ ## Discord
306
+
307
+ For further support, and discussions on these models and AI in general, join us at:
308
+
309
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
310
+
311
+ ## Thanks, and how to contribute
312
+
313
+ Thanks to the [chirper.ai](https://chirper.ai) team!
314
+
315
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
316
+
317
+ 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.
318
+
319
+ 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.
320
+
321
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
322
+
323
+ * Patreon: https://patreon.com/TheBlokeAI
324
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
325
+
326
+ **Special thanks to**: Aemon Algiz.
327
+
328
+ **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
329
+
330
+
331
+ Thank you to all my generous patrons and donaters!
332
+
333
+ And thank you again to a16z for their generous grant.
334
+
335
+ <!-- footer end -->
336
+
337
+ # Original model card: BKAI-HUST Foundation Models Lab's Vietnamese Llama2 7B 40GB
338
+
339
+
340
+ We employed [SentencePiece](https://github.com/google/sentencepiece) to retrain a Vietnamese tokenizer with a vocabulary size of 20K. No Vietnamese word segmentation was used. We then merged this vocabulary with the original one of Llama2, removing duplicate tokens.
341
+ The new tokenizer significantly improves when encoding Vietnamese text, reducing the number of tokens by 50% compared to ChatGPT and approximately 70% compared to the original Llama2.
342
+
343
+ We conducted a single-epoch continual pretraining, also known as incremental pretraining, using the Llama2-chat 7B model on a mixed dataset totaling 40.5 GB, comprised of:
344
+ - 19 GB [NewsCorpus](https://github.com/binhvq/news-corpus)
345
+ - 1.1 GB Vietnamese Wikipedia
346
+ - 1.6 GB [Vietnamese books](https://www.kaggle.com/datasets/iambestfeeder/10000-vietnamese-books)
347
+ - 4.5 GB Vietnamese legal documents (crawled from thuvienphapluat and processed by ourselves)
348
+ - 2.1 GB Vietnamese legal text (from [C4-vi](https://huggingface.co/datasets/c4))
349
+ - 1.1 GB English Books (sub-sampled from [pg19](https://huggingface.co/datasets/pg19))
350
+ - 1.1 GB English Wikipedia (sub-sampled from 20220301.en wikipedia)
351
+ - 10 GB English Text (sub-sampled from [C4-en](https://huggingface.co/datasets/c4))
352
+
353
+ We trained the model on a DGX A100 system, utilizing four GPU A100 in 10 days (about 1000 GPU hours).
354
+
355
+ Hyperparameters are set as follows:
356
+ - Training Regime: BFloat16 mixed precision
357
+ - Lora Config:
358
+
359
+ ```
360
+ {
361
+ "base_model_name_or_path": "meta-llama/Llama-2-7b-chat-hf",
362
+ "bias": "none",
363
+ "enable_lora": null,
364
+ "fan_in_fan_out": false,
365
+ "inference_mode": true,
366
+ "lora_alpha": 32.0,
367
+ "lora_dropout": 0.05,
368
+ "merge_weights": false,
369
+ "modules_to_save": [
370
+ "embed_tokens",
371
+ "lm_head"
372
+ ],
373
+ "peft_type": "LORA",
374
+ "r": 8,
375
+ "target_modules": [
376
+ "q_proj",
377
+ "v_proj",
378
+ "k_proj",
379
+ "o_proj",
380
+ "gate_proj",
381
+ "down_proj",
382
+ "up_proj"
383
+ ],
384
+ "task_type": "CAUSAL_LM"
385
+ }
386
+
387
+ ```
388
+
389
+ We also provide the [LoRA part](https://huggingface.co/bkai-foundation-models/vietnamese-llama2-7b-40GB/tree/main/pt_lora_model) so that you can integrate it with the original Llama2-chat-7b by yourself.
390
+
391
+ Please note that **this model requires further supervised fine-tuning (SFT)** to be used in practice!
392
+
393
+ Usage and other considerations: We refer to the [Llama 2](https://github.com/facebookresearch/llama)
394
+
395
+ Training loss:
396
+ <img src="figure/training_loss.png" alt="Training Loss Curve"/>
397
+
398
+ **Disclaimer**
399
+
400
+ This project is built upon Meta's Llama-2 model. It is essential to strictly adhere to the open-source license agreement of Llama-2 when using this model. If you incorporate third-party code, please ensure compliance with the relevant open-source license agreements.
401
+ It's important to note that the content generated by the model may be influenced by various factors, such as calculation methods, random elements, and potential inaccuracies in quantification. Consequently, this project does not offer any guarantees regarding the accuracy of the model's outputs, and it disclaims any responsibility for consequences resulting from the use of the model's resources and its output.
402
+ For those employing the models from this project for commercial purposes, developers must adhere to local laws and regulations to ensure the compliance of the model's output content. This project is not accountable for any products or services derived from such usage.
403
+
404
+ **Acknowledgments**
405
+
406
+ We extend our gratitude to PHPC - Phenikaa University and NVIDIA for their generous provision of computing resources for model training. Our appreciation also goes out to binhvq and the other authors for their diligent efforts in collecting and preparing the Vietnamese text corpus.