TheBloke commited on
Commit
c0248ed
1 Parent(s): 8d29003

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +310 -0
README.md ADDED
@@ -0,0 +1,310 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: https://huggingface.co/deepse/CodeUp-Llama-2-13b-chat-hf
3
+ inference: false
4
+ language:
5
+ - en
6
+ license: openrail++
7
+ model_creator: DeepSE
8
+ model_name: CodeUp Llama 2 13B Chat HF
9
+ model_type: llama
10
+ prompt_template: 'Below is an instruction that describes a task. Write a response
11
+ that appropriately completes the request.
12
+
13
+
14
+ ### Instruction:
15
+
16
+ {prompt}
17
+
18
+
19
+ ### Response:
20
+
21
+ '
22
+ quantized_by: TheBloke
23
+ tags:
24
+ - text-to-code
25
+ - multilingual-code-generation
26
+ ---
27
+
28
+ <!-- header start -->
29
+ <!-- 200823 -->
30
+ <div style="width: auto; margin-left: auto; margin-right: auto">
31
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
32
+ </div>
33
+ <div style="display: flex; justify-content: space-between; width: 100%;">
34
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
35
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
36
+ </div>
37
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
38
+ <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>
39
+ </div>
40
+ </div>
41
+ <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>
42
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
43
+ <!-- header end -->
44
+
45
+ # CodeUp Llama 2 13B Chat HF - AWQ
46
+ - Model creator: [DeepSE](https://huggingface.co/deepse)
47
+ - Original model: [CodeUp Llama 2 13B Chat HF](https://huggingface.co/deepse/CodeUp-Llama-2-13b-chat-hf)
48
+
49
+ <!-- description start -->
50
+ ## Description
51
+
52
+ This repo contains AWQ model files for [DeepSE's CodeUp Llama 2 13B Chat HF](https://huggingface.co/deepse/CodeUp-Llama-2-13b-chat-hf).
53
+
54
+
55
+ ### About AWQ
56
+
57
+ 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.
58
+
59
+ It is also now supported by continuous batching server [vLLM](https://github.com/vllm-project/vllm), allowing use of AWQ models for high-throughput concurrent inference in multi-user server scenarios. Note that, at the time of writing, overall throughput is still lower than running vLLM 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.
60
+ <!-- description end -->
61
+ <!-- repositories-available start -->
62
+ ## Repositories available
63
+
64
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/CodeUp-Llama-2-13B-Chat-HF-AWQ)
65
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/CodeUp-Llama-2-13B-Chat-HF-GPTQ)
66
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/CodeUp-Llama-2-13B-Chat-HF-GGUF)
67
+ * [DeepSE's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/deepse/CodeUp-Llama-2-13b-chat-hf)
68
+ <!-- repositories-available end -->
69
+
70
+ <!-- prompt-template start -->
71
+ ## Prompt template: Alpaca
72
+
73
+ ```
74
+ Below is an instruction that describes a task. Write a response that appropriately completes the request.
75
+
76
+ ### Instruction:
77
+ {prompt}
78
+
79
+ ### Response:
80
+
81
+ ```
82
+
83
+ <!-- prompt-template end -->
84
+ <!-- licensing start -->
85
+ ## Licensing
86
+
87
+ The creator of the source model has listed its license as `openrail++`, and this quantization has therefore used that same license.
88
+
89
+ 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.
90
+
91
+ In the meantime, any questions regarding licensing, and in particular how these two licenses might interact, should be directed to the original model repository: [DeepSE's CodeUp Llama 2 13B Chat HF](https://huggingface.co/deepse/CodeUp-Llama-2-13b-chat-hf).
92
+ <!-- licensing end -->
93
+ <!-- README_AWQ.md-provided-files start -->
94
+ ## Provided files and AWQ parameters
95
+
96
+ 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.
97
+
98
+ Models are released as sharded safetensors files.
99
+
100
+ | Branch | Bits | GS | AWQ Dataset | Seq Len | Size |
101
+ | ------ | ---- | -- | ----------- | ------- | ---- |
102
+ | [main](https://huggingface.co/TheBloke/CodeUp-Llama-2-13B-Chat-HF-AWQ/tree/main) | 4 | 128 | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 4096 | 7.25 GB
103
+
104
+ <!-- README_AWQ.md-provided-files end -->
105
+
106
+ <!-- README_AWQ.md-use-from-vllm start -->
107
+ ## Serving this model from vLLM
108
+
109
+ Documentation on installing and using vLLM [can be found here](https://vllm.readthedocs.io/en/latest/).
110
+
111
+ - When using vLLM as a server, pass the `--quantization awq` parameter, for example:
112
+
113
+ ```shell
114
+ python3 python -m vllm.entrypoints.api_server --model TheBloke/CodeUp-Llama-2-13B-Chat-HF-AWQ --quantization awq
115
+ ```
116
+
117
+ When using vLLM from Python code, pass the `quantization=awq` parameter, for example:
118
+
119
+ ```python
120
+ from vllm import LLM, SamplingParams
121
+
122
+ prompts = [
123
+ "Hello, my name is",
124
+ "The president of the United States is",
125
+ "The capital of France is",
126
+ "The future of AI is",
127
+ ]
128
+ sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
129
+
130
+ llm = LLM(model="TheBloke/CodeUp-Llama-2-13B-Chat-HF-AWQ", quantization="awq")
131
+
132
+ outputs = llm.generate(prompts, sampling_params)
133
+
134
+ # Print the outputs.
135
+ for output in outputs:
136
+ prompt = output.prompt
137
+ generated_text = output.outputs[0].text
138
+ print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
139
+ ```
140
+ <!-- README_AWQ.md-use-from-vllm start -->
141
+
142
+ <!-- README_AWQ.md-use-from-python start -->
143
+ ## How to use this AWQ model from Python code
144
+
145
+ ### Install the necessary packages
146
+
147
+ Requires: [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) 0.0.2 or later
148
+
149
+ ```shell
150
+ pip3 install autoawq
151
+ ```
152
+
153
+ If you have problems installing [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) using the pre-built wheels, install it from source instead:
154
+
155
+ ```shell
156
+ pip3 uninstall -y autoawq
157
+ git clone https://github.com/casper-hansen/AutoAWQ
158
+ cd AutoAWQ
159
+ pip3 install .
160
+ ```
161
+
162
+ ### You can then try the following example code
163
+
164
+ ```python
165
+ from awq import AutoAWQForCausalLM
166
+ from transformers import AutoTokenizer
167
+
168
+ model_name_or_path = "TheBloke/CodeUp-Llama-2-13B-Chat-HF-AWQ"
169
+
170
+ # Load model
171
+ model = AutoAWQForCausalLM.from_quantized(model_name_or_path, fuse_layers=True,
172
+ trust_remote_code=False, safetensors=True)
173
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=False)
174
+
175
+ prompt = "Tell me about AI"
176
+ prompt_template=f'''Below is an instruction that describes a task. Write a response that appropriately completes the request.
177
+
178
+ ### Instruction:
179
+ {prompt}
180
+
181
+ ### Response:
182
+
183
+ '''
184
+
185
+ print("\n\n*** Generate:")
186
+
187
+ tokens = tokenizer(
188
+ prompt_template,
189
+ return_tensors='pt'
190
+ ).input_ids.cuda()
191
+
192
+ # Generate output
193
+ generation_output = model.generate(
194
+ tokens,
195
+ do_sample=True,
196
+ temperature=0.7,
197
+ top_p=0.95,
198
+ top_k=40,
199
+ max_new_tokens=512
200
+ )
201
+
202
+ print("Output: ", tokenizer.decode(generation_output[0]))
203
+
204
+ # Inference can also be done using transformers' pipeline
205
+ from transformers import pipeline
206
+
207
+ print("*** Pipeline:")
208
+ pipe = pipeline(
209
+ "text-generation",
210
+ model=model,
211
+ tokenizer=tokenizer,
212
+ max_new_tokens=512,
213
+ do_sample=True,
214
+ temperature=0.7,
215
+ top_p=0.95,
216
+ top_k=40,
217
+ repetition_penalty=1.1
218
+ )
219
+
220
+ print(pipe(prompt_template)[0]['generated_text'])
221
+ ```
222
+ <!-- README_AWQ.md-use-from-python end -->
223
+
224
+ <!-- README_AWQ.md-compatibility start -->
225
+ ## Compatibility
226
+
227
+ The files provided are tested to work with [AutoAWQ](https://github.com/casper-hansen/AutoAWQ), and [vLLM](https://github.com/vllm-project/vllm).
228
+
229
+ [Huggingface Text Generation Inference (TGI)](https://github.com/huggingface/text-generation-inference) is not yet compatible with AWQ, but a PR is open which should bring support soon: [TGI PR #781](https://github.com/huggingface/text-generation-inference/issues/781).
230
+ <!-- README_AWQ.md-compatibility end -->
231
+
232
+ <!-- footer start -->
233
+ <!-- 200823 -->
234
+ ## Discord
235
+
236
+ For further support, and discussions on these models and AI in general, join us at:
237
+
238
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
239
+
240
+ ## Thanks, and how to contribute
241
+
242
+ Thanks to the [chirper.ai](https://chirper.ai) team!
243
+
244
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
245
+
246
+ 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.
247
+
248
+ 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.
249
+
250
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
251
+
252
+ * Patreon: https://patreon.com/TheBlokeAI
253
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
254
+
255
+ **Special thanks to**: Aemon Algiz.
256
+
257
+ **Patreon special mentions**: Alicia Loh, Stephen Murray, K, Ajan Kanaga, RoA, Magnesian, Deo Leter, Olakabola, Eugene Pentland, zynix, Deep Realms, Raymond Fosdick, Elijah Stavena, Iucharbius, Erik Bjäreholt, Luis Javier Navarrete Lozano, Nicholas, theTransient, John Detwiler, alfie_i, knownsqashed, Mano Prime, Willem Michiel, Enrico Ros, LangChain4j, OG, Michael Dempsey, Pierre Kircher, Pedro Madruga, James Bentley, Thomas Belote, Luke @flexchar, Leonard Tan, Johann-Peter Hartmann, Illia Dulskyi, Fen Risland, Chadd, S_X, Jeff Scroggin, Ken Nordquist, Sean Connelly, Artur Olbinski, Swaroop Kallakuri, Jack West, Ai Maven, David Ziegler, Russ Johnson, transmissions 11, John Villwock, Alps Aficionado, Clay Pascal, Viktor Bowallius, Subspace Studios, Rainer Wilmers, Trenton Dambrowitz, vamX, Michael Levine, 준교 김, Brandon Frisco, Kalila, Trailburnt, Randy H, Talal Aujan, Nathan Dryer, Vadim, 阿明, ReadyPlayerEmma, Tiffany J. Kim, George Stoitzev, Spencer Kim, Jerry Meng, Gabriel Tamborski, Cory Kujawski, Jeffrey Morgan, Spiking Neurons AB, Edmond Seymore, Alexandros Triantafyllidis, Lone Striker, Cap'n Zoog, Nikolai Manek, danny, ya boyyy, Derek Yates, usrbinkat, Mandus, TL, Nathan LeClaire, subjectnull, Imad Khwaja, webtim, Raven Klaugh, Asp the Wyvern, Gabriel Puliatti, Caitlyn Gatomon, Joseph William Delisle, Jonathan Leane, Luke Pendergrass, SuperWojo, Sebastain Graf, Will Dee, Fred von Graf, Andrey, Dan Guido, Daniel P. Andersen, Nitin Borwankar, Elle, Vitor Caleffi, biorpg, jjj, NimbleBox.ai, Pieter, Matthew Berman, terasurfer, Michael Davis, Alex, Stanislav Ovsiannikov
258
+
259
+
260
+ Thank you to all my generous patrons and donaters!
261
+
262
+ And thank you again to a16z for their generous grant.
263
+
264
+ <!-- footer end -->
265
+
266
+ # Original model card: DeepSE's CodeUp Llama 2 13B Chat HF
267
+
268
+
269
+ <!-- <p align="center" width="70%">
270
+ <img src="assets/Logo.jpg" alt="HKUST CodeUp" style="width: 50%; min-width: 250px; display: block; margin: auto;">
271
+ </p> -->
272
+ ![HKUST CodeUp](assets/Logo.jpg)
273
+ # CodeUp: A Multilingual Code Generation Llama2 Model with Parameter-Efficient Instruction-Tuning on a Single RTX 3090
274
+
275
+ ## Description
276
+ In recent years, large language models (LLMs) have shown exceptional capabilities in a wide range of applications due to their fantastic emergence ability. To align with human preference, instruction-tuning and reinforcement learning from human feedback (RLHF) are proposed for Chat-based LLMs (e.g., ChatGPT, GPT-4). However, these LLMs (except for Codex) primarily focus on the general domain and are not specifically designed for the code domain. Although Codex provides an alternative choice, it is a closed-source model developed by OpenAI. Hence, it is imperative to develop open-source instruction-following LLMs for the code domain.
277
+ However, the large-scale number of LLMs' parameters ($\ge$7B) and training datasets require a vast amount of computational resources, which significantly impedes the development of training and inference on consumer hardware.
278
+
279
+ To handle these challenges, in this project, we adopt the latest powerful foundation model `Llama 2` and construct high-quality instruction-following data for code generation tasks, and propose an instruction-following multilingual code generation Llama2 model. Meanwhile, to make it fit an academic budget and consumer hardware (e.g., a single RTX 3090) based on `Alpaca-LoRA`, we equip `CodeUp` with the advanced parameter-efficient fine-tuning (PEFT) methods (e.g., [LoRA](https://arxiv.org/abs/2106.09685)) which enable efficient adaptation of pre-trained language models (PLMs, also known as foundation model) to various downstream applications without fine-tuning the entire model's parameters. The overall training recipe is as follows.
280
+
281
+ ![Training Framework](assets/Framework.jpg)
282
+
283
+
284
+ ## NL2Code Data Release
285
+ Recently, it has attracted significant attention to exploiting much larger and more powerful LLMs (e.g., ChatGPT, GPT-4) to self-generate instruction-following data by delicate prompt design. However, many approaches primarily focus on the general domain and lack code-specific domain considerations. To this end, [Code Alpaca](https://github.com/sahil280114/codealpaca) follows the previous Self-Instruct paper [3] and [Stanford Alpaca repo](https://github.com/tatsu-lab/stanford_alpaca) with some code-related modifications to conduct 20K instruction-following data `data/code_alpaca_20k.json` for code generation tasks. This `JSON` file following `alpaca_data.json` format is a list of dictionaries; each dictionary contains the following fields:
286
+
287
+ - `instruction`: `str`, describes the task the model should perform. Each of the 20K instructions is unique.
288
+ - `input`: `str`, optional context or input for the task. For example, when the instruction is "Amend the following SQL query to select distinct elements", the input is the SQL query. Around 40% of the examples have an input.
289
+ - `output`: `str`, the answer to the instruction as generated by `text-davinci-003`.
290
+
291
+ ### High-quality Data Filter
292
+ However, after carefully checking the LLMs-self-generated data, we observe three critical problems that may hinder LLMs' instruction learning due to ambiguous and irrelevant noise. That is
293
+
294
+ 1. When `instruction` doesn't specify the programming language (PL) of implementation, the `output` appears with diverse options, e.g., Python, C++, and JavaScript.
295
+ 2. It is ambiguous to identify which programming language `output` is implemented by.
296
+ 3. Both `instruction` and `output` are irrelevant to the code-specific domain.
297
+
298
+ Hence, we filter the ambiguous and irrelevant data by rigorous design to obtain high-quality instruction data. Specifically, to solve 1) we set Python as the default PL of implementation and use [Guesslang](https://guesslang.readthedocs.io/en/latest/) package to detect the PL of a given source code in `output`. If the Python is detected, this prompt is retained. Otherwise, it will be filtered. 2) and 3) In these cases, we delete these prompts. After that, about 5K low-quality instruction data is filtered. To supplement the high-quality instruction data, we further integrate the `data/new_codealpaca.json` data (about 4.5K) under the above filter rules.
299
+
300
+ This way, we gain the 19K high-quality instruction data of code generation. The following is the instruction number distribution of each PL with Radar visualization before and after filtering.
301
+
302
+ <!-- | Raw Data (20K + 4K)| Filtered Data (19K) |
303
+ | -- | -- |
304
+ | <center><img src="assets/PL_Raw.png" width="100%"></center> | <center><img src="assets/PL_Clean.png" width="92%"></center> | -->
305
+
306
+ ![PL Data Filtering)](assets/PL_Filter.jpg)
307
+
308
+
309
+ ## Training & Inference
310
+ Detailed instructions can be found at [https://github.com/juyongjiang/CodeUp](https://github.com/juyongjiang/CodeUp).