TheBloke commited on
Commit
2835c52
1 Parent(s): 8e5da6f

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +370 -0
README.md ADDED
@@ -0,0 +1,370 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: https://huggingface.co/Phind/Phind-CodeLlama-34B-v2
3
+ inference: false
4
+ license: llama2
5
+ model-index:
6
+ - name: Phind-CodeLlama-34B-v1
7
+ results:
8
+ - dataset:
9
+ name: HumanEval
10
+ type: openai_humaneval
11
+ metrics:
12
+ - name: pass@1
13
+ type: pass@1
14
+ value: 73.8%
15
+ verified: false
16
+ task:
17
+ type: text-generation
18
+ model_creator: Phind
19
+ model_name: CodeLlama 34B v2
20
+ model_type: llama
21
+ prompt_template: '### System Prompt
22
+
23
+ {system_message}
24
+
25
+
26
+ ### User Message
27
+
28
+ {prompt}
29
+
30
+
31
+ ### Assistant
32
+
33
+ '
34
+ quantized_by: TheBloke
35
+ tags:
36
+ - code llama
37
+ ---
38
+
39
+ <!-- header start -->
40
+ <!-- 200823 -->
41
+ <div style="width: auto; margin-left: auto; margin-right: auto">
42
+ <img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
43
+ </div>
44
+ <div style="display: flex; justify-content: space-between; width: 100%;">
45
+ <div style="display: flex; flex-direction: column; align-items: flex-start;">
46
+ <p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
47
+ </div>
48
+ <div style="display: flex; flex-direction: column; align-items: flex-end;">
49
+ <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>
50
+ </div>
51
+ </div>
52
+ <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>
53
+ <hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
54
+ <!-- header end -->
55
+
56
+ # CodeLlama 34B v2 - AWQ
57
+ - Model creator: [Phind](https://huggingface.co/Phind)
58
+ - Original model: [CodeLlama 34B v2](https://huggingface.co/Phind/Phind-CodeLlama-34B-v2)
59
+
60
+ <!-- description start -->
61
+ ## Description
62
+
63
+ This repo contains AWQ model files for [Phind's CodeLlama 34B v2](https://huggingface.co/Phind/Phind-CodeLlama-34B-v2).
64
+
65
+
66
+ ### About AWQ
67
+
68
+ 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.
69
+
70
+ 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.
71
+ <!-- description end -->
72
+ <!-- repositories-available start -->
73
+ ## Repositories available
74
+
75
+ * [AWQ model(s) for GPU inference.](https://huggingface.co/TheBloke/Phind-CodeLlama-34B-v2-AWQ)
76
+ * [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/Phind-CodeLlama-34B-v2-GPTQ)
77
+ * [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/Phind-CodeLlama-34B-v2-GGUF)
78
+ * [Phind's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/Phind/Phind-CodeLlama-34B-v2)
79
+ <!-- repositories-available end -->
80
+
81
+ <!-- prompt-template start -->
82
+ ## Prompt template: Phind
83
+
84
+ ```
85
+ ### System Prompt
86
+ {system_message}
87
+
88
+ ### User Message
89
+ {prompt}
90
+
91
+ ### Assistant
92
+
93
+ ```
94
+
95
+ <!-- prompt-template end -->
96
+
97
+
98
+ <!-- README_AWQ.md-provided-files start -->
99
+ ## Provided files and AWQ parameters
100
+
101
+ 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.
102
+
103
+ Models are released as sharded safetensors files.
104
+
105
+ | Branch | Bits | GS | AWQ Dataset | Seq Len | Size |
106
+ | ------ | ---- | -- | ----------- | ------- | ---- |
107
+ | [main](https://huggingface.co/TheBloke/Phind-CodeLlama-34B-v2-AWQ/tree/main) | 4 | 128 | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 4096 | 18.31 GB
108
+
109
+ <!-- README_AWQ.md-provided-files end -->
110
+
111
+ <!-- README_AWQ.md-use-from-vllm start -->
112
+ ## Serving this model from vLLM
113
+
114
+ Documentation on installing and using vLLM [can be found here](https://vllm.readthedocs.io/en/latest/).
115
+
116
+ - When using vLLM as a server, pass the `--quantization awq` parameter, for example:
117
+
118
+ ```shell
119
+ python3 python -m vllm.entrypoints.api_server --model TheBloke/Phind-CodeLlama-34B-v2-AWQ --quantization awq
120
+ ```
121
+
122
+ When using vLLM from Python code, pass the `quantization=awq` parameter, for example:
123
+
124
+ ```python
125
+ from vllm import LLM, SamplingParams
126
+
127
+ prompts = [
128
+ "Hello, my name is",
129
+ "The president of the United States is",
130
+ "The capital of France is",
131
+ "The future of AI is",
132
+ ]
133
+ sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
134
+
135
+ llm = LLM(model="TheBloke/Phind-CodeLlama-34B-v2-AWQ", quantization="awq")
136
+
137
+ outputs = llm.generate(prompts, sampling_params)
138
+
139
+ # Print the outputs.
140
+ for output in outputs:
141
+ prompt = output.prompt
142
+ generated_text = output.outputs[0].text
143
+ print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
144
+ ```
145
+ <!-- README_AWQ.md-use-from-vllm start -->
146
+
147
+ <!-- README_AWQ.md-use-from-python start -->
148
+ ## How to use this AWQ model from Python code
149
+
150
+ ### Install the necessary packages
151
+
152
+ Requires: [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) 0.0.2 or later
153
+
154
+ ```shell
155
+ pip3 install autoawq
156
+ ```
157
+
158
+ If you have problems installing [AutoAWQ](https://github.com/casper-hansen/AutoAWQ) using the pre-built wheels, install it from source instead:
159
+
160
+ ```shell
161
+ pip3 uninstall -y autoawq
162
+ git clone https://github.com/casper-hansen/AutoAWQ
163
+ cd AutoAWQ
164
+ pip3 install .
165
+ ```
166
+
167
+ ### You can then try the following example code
168
+
169
+ ```python
170
+ from awq import AutoAWQForCausalLM
171
+ from transformers import AutoTokenizer
172
+
173
+ model_name_or_path = "TheBloke/Phind-CodeLlama-34B-v2-AWQ"
174
+
175
+ # Load model
176
+ model = AutoAWQForCausalLM.from_quantized(model_name_or_path, fuse_layers=True,
177
+ trust_remote_code=False, safetensors=True)
178
+ tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=False)
179
+
180
+ prompt = "Tell me about AI"
181
+ prompt_template=f'''### System Prompt
182
+ {system_message}
183
+
184
+ ### User Message
185
+ {prompt}
186
+
187
+ ### Assistant
188
+
189
+ '''
190
+
191
+ print("\n\n*** Generate:")
192
+
193
+ tokens = tokenizer(
194
+ prompt_template,
195
+ return_tensors='pt'
196
+ ).input_ids.cuda()
197
+
198
+ # Generate output
199
+ generation_output = model.generate(
200
+ tokens,
201
+ do_sample=True,
202
+ temperature=0.7,
203
+ top_p=0.95,
204
+ top_k=40,
205
+ max_new_tokens=512
206
+ )
207
+
208
+ print("Output: ", tokenizer.decode(generation_output[0]))
209
+
210
+ # Inference can also be done using transformers' pipeline
211
+ from transformers import pipeline
212
+
213
+ print("*** Pipeline:")
214
+ pipe = pipeline(
215
+ "text-generation",
216
+ model=model,
217
+ tokenizer=tokenizer,
218
+ max_new_tokens=512,
219
+ do_sample=True,
220
+ temperature=0.7,
221
+ top_p=0.95,
222
+ top_k=40,
223
+ repetition_penalty=1.1
224
+ )
225
+
226
+ print(pipe(prompt_template)[0]['generated_text'])
227
+ ```
228
+ <!-- README_AWQ.md-use-from-python end -->
229
+
230
+ <!-- README_AWQ.md-compatibility start -->
231
+ ## Compatibility
232
+
233
+ The files provided are tested to work with [AutoAWQ](https://github.com/casper-hansen/AutoAWQ), and [vLLM](https://github.com/vllm-project/vllm).
234
+
235
+ [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).
236
+ <!-- README_AWQ.md-compatibility end -->
237
+
238
+ <!-- footer start -->
239
+ <!-- 200823 -->
240
+ ## Discord
241
+
242
+ For further support, and discussions on these models and AI in general, join us at:
243
+
244
+ [TheBloke AI's Discord server](https://discord.gg/theblokeai)
245
+
246
+ ## Thanks, and how to contribute
247
+
248
+ Thanks to the [chirper.ai](https://chirper.ai) team!
249
+
250
+ Thanks to Clay from [gpus.llm-utils.org](llm-utils)!
251
+
252
+ 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.
253
+
254
+ 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.
255
+
256
+ Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
257
+
258
+ * Patreon: https://patreon.com/TheBlokeAI
259
+ * Ko-Fi: https://ko-fi.com/TheBlokeAI
260
+
261
+ **Special thanks to**: Aemon Algiz.
262
+
263
+ **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
264
+
265
+
266
+ Thank you to all my generous patrons and donaters!
267
+
268
+ And thank you again to a16z for their generous grant.
269
+
270
+ <!-- footer end -->
271
+
272
+ # Original model card: Phind's CodeLlama 34B v2
273
+
274
+
275
+ # **Phind-CodeLlama-34B-v2**
276
+ We've fine-tuned Phind-CodeLlama-34B-v1 on an additional 1.5B tokens high-quality programming-related data, achieving **73.8% pass@1** on HumanEval. It's the current state-of-the-art amongst open-source models.
277
+
278
+ Furthermore, this model is **instruction-tuned** on the Alpaca/Vicuna format to be steerable and easy-to-use.
279
+
280
+ More details can be found on our [blog post](https://www.phind.com/blog/code-llama-beats-gpt4).
281
+
282
+ ## Model Details
283
+ This model is fine-tuned from Phind-CodeLlama-34B-v1 and achieves **73.8% pass@1** on HumanEval.
284
+
285
+ Phind-CodeLlama-34B-v2 is **multi-lingual** and is proficient in Python, C/C++, TypeScript, Java, and more.
286
+
287
+ ## Dataset Details
288
+ We fined-tuned on a proprietary dataset of 1.5B tokens of high quality programming problems and solutions. This dataset consists of instruction-answer pairs instead of code completion examples, making it structurally different from HumanEval. LoRA was not used -- both models are a native finetune. We used DeepSpeed ZeRO 3 and Flash Attention 2 to train these models in 15 hours on 32 A100-80GB GPUs. We used a sequence length of 4096 tokens.
289
+
290
+ ## How to Get Started with the Model
291
+
292
+ Make sure to install Transformers from the main git branch:
293
+
294
+ ```bash
295
+ pip install git+https://github.com/huggingface/transformers.git
296
+ ```
297
+
298
+ ## How to Prompt the Model
299
+ This model accepts the Alpaca/Vicuna instruction format.
300
+
301
+ For example:
302
+
303
+ ```
304
+ ### System Prompt
305
+ You are an intelligent programming assistant.
306
+
307
+ ### User Message
308
+ Implement a linked list in C++
309
+
310
+ ### Assistant
311
+ ...
312
+ ```
313
+
314
+ ## How to reproduce HumanEval Results
315
+
316
+ To reproduce our results:
317
+
318
+ ```python
319
+
320
+ from transformers import AutoTokenizer, LlamaForCausalLM
321
+ from human_eval.data import write_jsonl, read_problems
322
+ from tqdm import tqdm
323
+
324
+ # initialize the model
325
+
326
+ model_path = "Phind/Phind-CodeLlama-34B-v2"
327
+ model = LlamaForCausalLM.from_pretrained(model_path, device_map="auto")
328
+ tokenizer = AutoTokenizer.from_pretrained(model_path)
329
+
330
+ # HumanEval helper
331
+
332
+ def generate_one_completion(prompt: str):
333
+ tokenizer.pad_token = tokenizer.eos_token
334
+ inputs = tokenizer(prompt, return_tensors="pt", truncation=True, max_length=4096)
335
+
336
+ # Generate
337
+ generate_ids = model.generate(inputs.input_ids.to("cuda"), max_new_tokens=384, do_sample=True, top_p=0.75, top_k=40, temperature=0.1)
338
+ completion = tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
339
+ completion = completion.replace(prompt, "").split("\n\n\n")[0]
340
+
341
+ return completion
342
+
343
+ # perform HumanEval
344
+ problems = read_problems()
345
+
346
+ num_samples_per_task = 1
347
+ samples = [
348
+ dict(task_id=task_id, completion=generate_one_completion(problems[task_id]["prompt"]))
349
+ for task_id in tqdm(problems)
350
+ for _ in range(num_samples_per_task)
351
+ ]
352
+ write_jsonl("samples.jsonl", samples)
353
+
354
+ # run `evaluate_functional_correctness samples.jsonl` in your HumanEval code sandbox
355
+ ```
356
+
357
+ ## Bias, Risks, and Limitations
358
+
359
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
360
+ This model has undergone very limited testing. Additional safety testing should be performed before any real-world deployments.
361
+
362
+
363
+ ## Training details
364
+
365
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
366
+
367
+ - **Hardware Type:** 32x A100-80GB
368
+ - **Hours used:** 480 GPU-hours
369
+ - **Cloud Provider:** AWS
370
+ - **Compute Region:** us-east-1