Canstralian commited on
Commit
f25b4a8
Β·
verified Β·
1 Parent(s): a021dd4

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +373 -364
README.md CHANGED
@@ -1,364 +1,373 @@
1
- # WizardCoder: Empowering Code Large Language Models with Evol-Instruct
2
-
3
- [![Code License](https://img.shields.io/badge/Code%20License-Apache_2.0-green.svg)](CODE_LICENSE)
4
- [![Data License](https://img.shields.io/badge/Data%20License-CC%20By%20NC%204.0-red.svg)](DATA_LICENSE)
5
- <!-- [![Model Weight License](https://img.shields.io/badge/Model%20Weights%20License-bigscience%20OpenRAIL%20M%20v1-yellow)](MODEL_WEIGHTS_LICENSE) -->
6
- [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/release/python-390/)
7
-
8
- To develop our WizardCoder model, we begin by adapting the Evol-Instruct method specifically for coding tasks. This involves tailoring the prompt to the domain of code-related instructions. Subsequently, we fine-tune the Code LLMs, StarCoder or Code LLama, utilizing the newly created instruction-following training set.
9
-
10
- ## News
11
-
12
- - πŸ”₯πŸ”₯πŸ”₯[2023/08/26] We released **WizardCoder-Python-34B-V1.0** , which achieves the **73.2 pass@1** and surpasses **GPT4 (2023/03/15)**, **ChatGPT-3.5**, and **Claude2** on the [HumanEval Benchmarks](https://github.com/openai/human-eval).
13
- - [2023/06/16] We released **WizardCoder-15B-V1.0** , which achieves the **57.3 pass@1** and surpasses **Claude-Plus (+6.8)**, **Bard (+15.3)** and **InstructCodeT5+ (+22.3)** on the [HumanEval Benchmarks](https://github.com/openai/human-eval).
14
-
15
- ❗Note: There are two HumanEval results of GPT4 and ChatGPT-3.5. The 67.0 and 48.1 are reported by the official GPT4 Report (2023/03/15) of [OpenAI](https://arxiv.org/abs/2303.08774). The 82.0 and 72.5 are tested by ourselves with the latest API (2023/08/26).
16
-
17
-
18
- | Model | Checkpoint | Paper | HumanEval | MBPP | Demo | License |
19
- | ----- |------| ---- |------|-------| ----- | ----- |
20
- | WizardCoder-Python-34B-V1.0 | πŸ€— <a href="https://huggingface.co/WizardLM/WizardCoder-Python-34B-V1.0" target="_blank">HF Link</a> | πŸ“ƒ <a href="https://arxiv.org/abs/2306.08568" target="_blank">[WizardCoder]</a> | 73.2 | 61.2 | [Demo](http://47.103.63.15:50085/) | <a href="https://ai.meta.com/resources/models-and-libraries/llama-downloads/" target="_blank">Llama2</a> |
21
- | WizardCoder-15B-V1.0 | πŸ€— <a href="https://huggingface.co/WizardLM/WizardCoder-15B-V1.0" target="_blank">HF Link</a> | πŸ“ƒ <a href="https://arxiv.org/abs/2306.08568" target="_blank">[WizardCoder]</a> | 59.8 |50.6 | -- | <a href="https://huggingface.co/spaces/bigcode/bigcode-model-license-agreement" target="_blank">OpenRAIL-M</a> |
22
-
23
- - &#x1F4E3; Please refer to our Twitter account https://twitter.com/WizardLM_AI and HuggingFace Repo https://huggingface.co/WizardLM . We will use them to announce any new release at the 1st time.
24
-
25
- ## Comparing WizardCoder-Python-34B-V1.0 with Other LLMs.
26
-
27
- πŸ”₯ The following figure shows that our **WizardCoder-Python-34B-V1.0 attains the second position in this benchmark**, surpassing GPT4 (2023/03/15, 73.2 vs. 67.0), ChatGPT-3.5 (73.2 vs. 72.5) and Claude2 (73.2 vs. 71.2).
28
-
29
- <p align="center" width="100%">
30
- <a ><img src="imgs/compare_sota.png" alt="WizardCoder" style="width: 96%; min-width: 300px; display: block; margin: auto;"></a>
31
- </p>
32
-
33
- ❗❗❗**Note: This performance is 100% reproducible! If you cannot reproduce it, please follow the steps in [Evaluation](#evaluation).**
34
-
35
- ❗Note: There are two HumanEval results of GPT4 and ChatGPT-3.5. The 67.0 and 48.1 are reported by the official GPT4 Report (2023/03/15) of [OpenAI](https://arxiv.org/abs/2303.08774). The 82.0 and 72.5 are tested by ourselves with the latest API (2023/08/26).
36
-
37
- ## Comparing WizardCoder-15B-V1.0 with the Closed-Source Models.
38
-
39
- πŸ”₯ The following figure shows that our **WizardCoder attains the third position in this benchmark**, surpassing Claude-Plus (59.8 vs. 53.0) and Bard (59.8 vs. 44.5). Notably, our model exhibits a substantially smaller size compared to these models.
40
-
41
- <p align="center" width="100%">
42
- <a ><img src="imgs/pass1.png" alt="WizardCoder" style="width: 86%; min-width: 300px; display: block; margin: auto;"></a>
43
- </p>
44
-
45
- ❗❗❗**Note: This performance is 100% reproducible! If you cannot reproduce it, please follow the steps in [Evaluation](#evaluation).**
46
-
47
- ❗**Note: In this study, we copy the scores for HumanEval and HumanEval+ from the [LLM-Humaneval-Benchmarks](https://github.com/my-other-github-account/llm-humaneval-benchmarks). Notably, all the mentioned models generate code solutions for each problem utilizing a **single attempt**, and the resulting pass rate percentage is reported. Our **WizardCoder** generates answers using greedy decoding and tests with the same [code](https://github.com/evalplus/evalplus).**
48
-
49
- ## Comparing WizardCoder-15B-V1.0 with the Open-Source Models.
50
-
51
- The following table clearly demonstrates that our **WizardCoder** exhibits a substantial performance advantage over all the open-source models. ❗**If you are confused with the different scores of our model (57.3 and 59.8), please check the Notes.**
52
-
53
-
54
- | Model | HumanEval Pass@1 | MBPP Pass@1 |
55
- |------------------|------------------|-------------|
56
- | CodeGen-16B-Multi| 18.3 |20.9 |
57
- | CodeGeeX | 22.9 |24.4 |
58
- | LLaMA-33B | 21.7 |30.2 |
59
- | LLaMA-65B | 23.7 |37.7 |
60
- | PaLM-540B | 26.2 |36.8 |
61
- | PaLM-Coder-540B | 36.0 |47.0 |
62
- | PaLM 2-S | 37.6 |50.0 |
63
- | CodeGen-16B-Mono | 29.3 |35.3 |
64
- | Code-Cushman-001 | 33.5 |45.9 |
65
- | StarCoder-15B | 33.6 |43.6* |
66
- | InstructCodeT5+ | 35.0 |-- |
67
- | WizardLM-30B 1.0| 37.8 |-- |
68
- | WizardCoder-15B 1.0 | **57.3** |**51.8** |
69
-
70
- ❗**Note: The reproduced result of StarCoder on MBPP.**
71
-
72
- ❗**Note: The above table conducts a comprehensive comparison of our **WizardCoder** with other models on the HumanEval and MBPP benchmarks. We adhere to the approach outlined in previous studies by generating **20 samples** for each problem to estimate the pass@1 score and evaluate with the same [code](https://github.com/openai/human-eval/tree/master). The scores of GPT4 and GPT3.5 reported by [OpenAI](https://openai.com/research/gpt-4) are 67.0 and 48.1 (maybe these are the early version GPT4&3.5).**
73
-
74
- ## Call for Feedbacks
75
- We welcome everyone to use your professional and difficult instructions to evaluate WizardCoder, and show us examples of poor performance and your suggestions in the [issue discussion](https://github.com/nlpxucan/WizardLM/issues) area. We are focusing on improving the Evol-Instruct now and hope to relieve existing weaknesses and issues in the the next version of WizardCoder. After that, we will open the code and pipeline of up-to-date Evol-Instruct algorithm and work with you together to improve it.
76
-
77
- ## Unofficial Video Introductions
78
- Thanks to the enthusiastic friends, their video introductions are more lively and interesting.
79
- 1. [WizardCoder AI Is The NEW ChatGPT's Coding TWIN!](https://www.youtube.com/watch?v=XjsyHrmd3Xo)
80
-
81
- ## Contents
82
-
83
- 1. [Online Demo](#online-demo)
84
-
85
- 2. [Fine-tuning](#fine-tuning)
86
-
87
- 3. [Inference](#inference)
88
-
89
- 4. [Evaluation](#evaluation)
90
-
91
- 5. [Citation](#citation)
92
-
93
- 6. [Disclaimer](#disclaimer)
94
-
95
- ## Online Demo
96
-
97
- We will provide our latest models for you to try for as long as possible. If you find a link is not working, please try another one. At the same time, please try as many **real-world** and **challenging** code-related problems that you encounter in your work and life as possible. We will continue to evolve our models with your feedbacks.
98
-
99
- [Demo Link](https://e5eaf7d09cc1521c.gradio.app/) (We adopt the greedy decoding now.)
100
-
101
- ## Fine-tuning
102
-
103
- We fine-tune WizardCoder using the modified code `train.py` from [Llama-X](https://github.com/AetherCortex/Llama-X).
104
- We fine-tune StarCoder-15B with the following hyperparameters:
105
-
106
- | Hyperparameter | StarCoder-15B |
107
- |----------------|---------------|
108
- | Batch size | 512 |
109
- | Learning rate | 2e-5 |
110
- | Epochs | 3 |
111
- | Max length | 2048 |
112
- | Warmup step | 30 |
113
- | LR scheduler | cosine |
114
-
115
- To reproduce our fine-tuning of WizardCoder, please follow the following steps:
116
- 1. According to the instructions of [Llama-X](https://github.com/AetherCortex/Llama-X), install the environment, download the training code, and deploy. (Note: `deepspeed==0.9.2` and `transformers==4.29.2`)
117
- 2. Replace the `train.py` with the `train_wizardcoder.py` in our repo (`src/train_wizardcoder.py`)
118
- 3. Login Huggingface:
119
- ```bash
120
- huggingface-cli login
121
- ```
122
- 4. Execute the following training command:
123
- ```bash
124
- deepspeed train_wizardcoder.py \
125
- --model_name_or_path "bigcode/starcoder" \
126
- --data_path "/your/path/to/code_instruction_data.json" \
127
- --output_dir "/your/path/to/ckpt" \
128
- --num_train_epochs 3 \
129
- --model_max_length 2048 \
130
- --per_device_train_batch_size 16 \
131
- --per_device_eval_batch_size 1 \
132
- --gradient_accumulation_steps 4 \
133
- --evaluation_strategy "no" \
134
- --save_strategy "steps" \
135
- --save_steps 50 \
136
- --save_total_limit 2 \
137
- --learning_rate 2e-5 \
138
- --warmup_steps 30 \
139
- --logging_steps 2 \
140
- --lr_scheduler_type "cosine" \
141
- --report_to "tensorboard" \
142
- --gradient_checkpointing True \
143
- --deepspeed configs/deepspeed_config.json \
144
- --fp16 True
145
- ```
146
-
147
- ## Inference
148
-
149
- We provide the decoding script for WizardCoder, which reads a input file and generates corresponding responses for each sample, and finally consolidates them into an output file.
150
-
151
- You can specify `base_model`, `input_data_path` and `output_data_path` in `src\inference_wizardcoder.py` to set the decoding model, path of input file and path of output file.
152
-
153
- ```bash
154
- pip install jsonlines
155
- ```
156
-
157
- The decoding command is:
158
- ```
159
- python src\inference_wizardcoder.py \
160
- --base_model "/your/path/to/ckpt" \
161
- --input_data_path "/your/path/to/input/data.jsonl" \
162
- --output_data_path "/your/path/to/output/result.jsonl"
163
- ```
164
-
165
- The format of `data.jsonl` should be:
166
- ```
167
- {"idx": 11, "Instruction": "Write a Python code to count 1 to 10."}
168
- {"idx": 12, "Instruction": "Write a Java code to sum 1 to 10."}
169
- ```
170
-
171
- The prompt for our WizardCoder in `src\inference_wizardcoder.py` is:
172
- ```
173
- Below is an instruction that describes a task. Write a response that appropriately completes the request.
174
-
175
- ### Instruction:
176
- {instruction}
177
-
178
- ### Response:
179
- ```
180
-
181
- ## Evaluation
182
-
183
- ### HumanEval
184
-
185
- 1. According to the instructions of [HumanEval](https://github.com/openai/human-eval), install the environment.
186
- 2. Run the following scripts to generate the answer.
187
-
188
- - (1) For WizardCoder-15B-V1.0 (base on StarCoder)
189
- ```bash
190
- model="/path/to/your/model"
191
- temp=0.2
192
- max_len=2048
193
- pred_num=200
194
- num_seqs_per_iter=2
195
-
196
- output_path=preds/T${temp}_N${pred_num}
197
-
198
- mkdir -p ${output_path}
199
- echo 'Output path: '$output_path
200
- echo 'Model to eval: '$model
201
-
202
- # 164 problems, 21 per GPU if GPU=8
203
- index=0
204
- gpu_num=8
205
- for ((i = 0; i < $gpu_num; i++)); do
206
- start_index=$((i * 21))
207
- end_index=$(((i + 1) * 21))
208
-
209
- gpu=$((i))
210
- echo 'Running process #' ${i} 'from' $start_index 'to' $end_index 'on GPU' ${gpu}
211
- ((index++))
212
- (
213
- CUDA_VISIBLE_DEVICES=$gpu python humaneval_gen.py --model ${model} \
214
- --start_index ${start_index} --end_index ${end_index} --temperature ${temp} \
215
- --num_seqs_per_iter ${num_seqs_per_iter} --N ${pred_num} --max_len ${max_len} --output_path ${output_path}
216
- ) &
217
- if (($index % $gpu_num == 0)); then wait; fi
218
- done
219
- ```
220
-
221
- - (2) For WizardCoder-Python-34B-V1.0 (base on CodeLLama)
222
-
223
- ```bash
224
- pip install vllm # This can acclerate the inference process a lot.
225
- pip install transformers==4.31.0
226
-
227
- model="/path/to/your/model"
228
- temp=0.2
229
- max_len=2048
230
- pred_num=200
231
- num_seqs_per_iter=2
232
-
233
- output_path=preds/T${temp}_N${pred_num}
234
-
235
- mkdir -p ${output_path}
236
- echo 'Output path: '$output_path
237
- echo 'Model to eval: '$model
238
-
239
- CUDA_VISIBLE_DEVICES=0,1,2,3 python humaneval_gen_vllm.py --model ${model} \
240
- --start_index 0 --end_index 164 --temperature ${temp} \
241
- --num_seqs_per_iter ${num_seqs_per_iter} --N ${pred_num} --max_len ${max_len} --output_path ${output_path} --num_gpus 4
242
- ```
243
-
244
- 3. Run the post processing code `src/process_humaneval.py` to collect the code completions from all answer files.
245
- ```bash
246
- output_path=preds/T${temp}_N${pred_num}
247
-
248
- echo 'Output path: '$output_path
249
- python process_humaneval.py --path ${output_path} --out_path ${output_path}.jsonl --add_prompt
250
-
251
- evaluate_functional_correctness ${output_path}.jsonl
252
- ```
253
-
254
- ### How to Reproduce the 59.8 Pass@1 on HumanEval with Greedy Decoding?
255
-
256
- ❗❗❗**This performance is 100% reproducible!**
257
-
258
- Run the following script to generate the answer with greedy decoding. Then follow the above steps 2 and 3 to get the evaluation result.
259
-
260
- ❗We also provide the generated codes in `data/humaneval.59.8.gen.zip`
261
-
262
- ```bash
263
- model="WizardLM/WizardCoder-15B-V1.0"
264
- temp=0.0
265
- max_len=2048
266
- pred_num=1
267
- num_seqs_per_iter=1
268
-
269
- output_path=preds/T${temp}_N${pred_num}_WizardCoder_Greedy_Decode
270
-
271
- mkdir -p ${output_path}
272
- echo 'Output path: '$output_path
273
- echo 'Model to eval: '$model
274
-
275
- # 164 problems, 21 per GPU if GPU=8
276
- index=0
277
- gpu_num=8
278
- for ((i = 0; i < $gpu_num; i++)); do
279
- start_index=$((i * 21))
280
- end_index=$(((i + 1) * 21))
281
-
282
- gpu=$((i))
283
- echo 'Running process #' ${i} 'from' $start_index 'to' $end_index 'on GPU' ${gpu}
284
- ((index++))
285
- (
286
- CUDA_VISIBLE_DEVICES=$gpu python humaneval_gen.py --model ${model} \
287
- --start_index ${start_index} --end_index ${end_index} --temperature ${temp} \
288
- --num_seqs_per_iter ${num_seqs_per_iter} --N ${pred_num} --max_len ${max_len} --output_path ${output_path} --greedy_decode
289
- ) &
290
- if (($index % $gpu_num == 0)); then wait; fi
291
- done
292
- ```
293
-
294
- ### MBPP
295
-
296
- 1. Run the following script to generate the answer.
297
- ```bash
298
- model="/path/to/your/model"
299
- temp=0.2
300
- max_len=2048
301
- pred_num=200
302
- num_seqs_per_iter=2
303
-
304
- output_path=preds/MBPP_T${temp}_N${pred_num}
305
- mbpp_path=data/mbpp.test.jsonl # we provide this file in data/mbpp.test.zip
306
-
307
- mkdir -p ${output_path}
308
- echo 'Output path: '$output_path
309
- echo 'Model to eval: '$model
310
-
311
- # 500 problems, 63 per GPU if GPU=8
312
- index=0
313
- gpu_num=8
314
- for ((i = 0; i < $gpu_num; i++)); do
315
- start_index=$((i * 50))
316
- end_index=$(((i + 1) * 50))
317
-
318
- gpu=$((i))
319
- echo 'Running process #' ${i} 'from' $start_index 'to' $end_index 'on GPU' ${gpu}
320
- ((index++))
321
- (
322
- CUDA_VISIBLE_DEVICES=$gpu python mbpp_gen.py --model ${model} \
323
- --start_index ${start_index} --end_index ${end_index} --temperature ${temp} \
324
- --num_seqs_per_iter ${num_seqs_per_iter} --N ${pred_num} --max_len ${max_len} --output_path ${output_path} --mbpp_path ${mbpp_path}
325
- ) &
326
- if (($index % $gpu_num == 0)); then wait; fi
327
- done
328
- ```
329
-
330
- 3. Run the post processing code `src/process_mbpp.py` to collect the code completions from all answer files.
331
- ```bash
332
- output_path=preds/MBPP_T${temp}_N${pred_num}
333
- mbpp_path=data/mbpp.test.jsonl # we provide this file in data/mbpp.test.zip
334
-
335
- echo 'Output path: '$output_path
336
- python process_mbpp.py --path ${output_path} --out_path ${output_path}.jsonl --mbpp_path ${mbpp_path} --add_prompt
337
- ```
338
-
339
- 4. Evaluate the `MBPP_T${temp}_N${pred_num}.jsonl` with [bigcode-evaluation-harness](https://github.com/bigcode-project/bigcode-evaluation-harness).
340
-
341
- Acknowledgement: The evaluation code `humaneval_gen.py`, `mbpp_gen.py` and bash scripts are modified from the great works of [CodeT5](https://github.com/salesforce/CodeT5).
342
-
343
- ## Citation
344
-
345
- Please cite the repo if you use the data or code in this repo.
346
-
347
- ```
348
- @misc{luo2023wizardcoder,
349
- title={WizardCoder: Empowering Code Large Language Models with Evol-Instruct},
350
- author={Ziyang Luo and Can Xu and Pu Zhao and Qingfeng Sun and Xiubo Geng and Wenxiang Hu and Chongyang Tao and Jing Ma and Qingwei Lin and Daxin Jiang},
351
- year={2023},
352
- eprint={2306.08568},
353
- archivePrefix={arXiv},
354
- primaryClass={cs.CL}
355
- }
356
- ```
357
- ## Disclaimer
358
-
359
- WizardCoder model follows the same license as StarCoder. The content produced by any version of WizardCoder is influenced by uncontrollable variables such as randomness, and therefore, the accuracy of the output cannot be guaranteed by this project. This project does not accept any legal liability for the content of the model output, nor does it assume responsibility for any losses incurred due to the use of associated resources and output results.
360
-
361
- ## Star History
362
-
363
- [![Star History Chart](https://api.star-history.com/svg?repos=nlpxucan/WizardLM&type=Timeline)](https://star-history.com/#nlpxucan/WizardLM&Timeline)
364
-
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ title: WizardLM
4
+ sdk: streamlit
5
+ emoji: πŸƒ
6
+ colorFrom: red
7
+ colorTo: purple
8
+ ---
9
+
10
+
11
+ # WizardCoder: Empowering Code Large Language Models with Evol-Instruct
12
+
13
+ [![Code License](https://img.shields.io/badge/Code%20License-Apache_2.0-green.svg)](CODE_LICENSE)
14
+ [![Data License](https://img.shields.io/badge/Data%20License-CC%20By%20NC%204.0-red.svg)](DATA_LICENSE)
15
+ <!-- [![Model Weight License](https://img.shields.io/badge/Model%20Weights%20License-bigscience%20OpenRAIL%20M%20v1-yellow)](MODEL_WEIGHTS_LICENSE) -->
16
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/release/python-390/)
17
+
18
+ To develop our WizardCoder model, we begin by adapting the Evol-Instruct method specifically for coding tasks. This involves tailoring the prompt to the domain of code-related instructions. Subsequently, we fine-tune the Code LLMs, StarCoder or Code LLama, utilizing the newly created instruction-following training set.
19
+
20
+ ## News
21
+
22
+ - πŸ”₯πŸ”₯πŸ”₯[2023/08/26] We released **WizardCoder-Python-34B-V1.0** , which achieves the **73.2 pass@1** and surpasses **GPT4 (2023/03/15)**, **ChatGPT-3.5**, and **Claude2** on the [HumanEval Benchmarks](https://github.com/openai/human-eval).
23
+ - [2023/06/16] We released **WizardCoder-15B-V1.0** , which achieves the **57.3 pass@1** and surpasses **Claude-Plus (+6.8)**, **Bard (+15.3)** and **InstructCodeT5+ (+22.3)** on the [HumanEval Benchmarks](https://github.com/openai/human-eval).
24
+
25
+ ❗Note: There are two HumanEval results of GPT4 and ChatGPT-3.5. The 67.0 and 48.1 are reported by the official GPT4 Report (2023/03/15) of [OpenAI](https://arxiv.org/abs/2303.08774). The 82.0 and 72.5 are tested by ourselves with the latest API (2023/08/26).
26
+
27
+
28
+ | Model | Checkpoint | Paper | HumanEval | MBPP | Demo | License |
29
+ | ----- |------| ---- |------|-------| ----- | ----- |
30
+ | WizardCoder-Python-34B-V1.0 | πŸ€— <a href="https://huggingface.co/WizardLM/WizardCoder-Python-34B-V1.0" target="_blank">HF Link</a> | πŸ“ƒ <a href="https://arxiv.org/abs/2306.08568" target="_blank">[WizardCoder]</a> | 73.2 | 61.2 | [Demo](http://47.103.63.15:50085/) | <a href="https://ai.meta.com/resources/models-and-libraries/llama-downloads/" target="_blank">Llama2</a> |
31
+ | WizardCoder-15B-V1.0 | πŸ€— <a href="https://huggingface.co/WizardLM/WizardCoder-15B-V1.0" target="_blank">HF Link</a> | πŸ“ƒ <a href="https://arxiv.org/abs/2306.08568" target="_blank">[WizardCoder]</a> | 59.8 |50.6 | -- | <a href="https://huggingface.co/spaces/bigcode/bigcode-model-license-agreement" target="_blank">OpenRAIL-M</a> |
32
+
33
+ - &#x1F4E3; Please refer to our Twitter account https://twitter.com/WizardLM_AI and HuggingFace Repo https://huggingface.co/WizardLM . We will use them to announce any new release at the 1st time.
34
+
35
+ ## Comparing WizardCoder-Python-34B-V1.0 with Other LLMs.
36
+
37
+ πŸ”₯ The following figure shows that our **WizardCoder-Python-34B-V1.0 attains the second position in this benchmark**, surpassing GPT4 (2023/03/15, 73.2 vs. 67.0), ChatGPT-3.5 (73.2 vs. 72.5) and Claude2 (73.2 vs. 71.2).
38
+
39
+ <p align="center" width="100%">
40
+ <a ><img src="imgs/compare_sota.png" alt="WizardCoder" style="width: 96%; min-width: 300px; display: block; margin: auto;"></a>
41
+ </p>
42
+
43
+ ❗❗❗**Note: This performance is 100% reproducible! If you cannot reproduce it, please follow the steps in [Evaluation](#evaluation).**
44
+
45
+ ❗Note: There are two HumanEval results of GPT4 and ChatGPT-3.5. The 67.0 and 48.1 are reported by the official GPT4 Report (2023/03/15) of [OpenAI](https://arxiv.org/abs/2303.08774). The 82.0 and 72.5 are tested by ourselves with the latest API (2023/08/26).
46
+
47
+ ## Comparing WizardCoder-15B-V1.0 with the Closed-Source Models.
48
+
49
+ πŸ”₯ The following figure shows that our **WizardCoder attains the third position in this benchmark**, surpassing Claude-Plus (59.8 vs. 53.0) and Bard (59.8 vs. 44.5). Notably, our model exhibits a substantially smaller size compared to these models.
50
+
51
+ <p align="center" width="100%">
52
+ <a ><img src="imgs/pass1.png" alt="WizardCoder" style="width: 86%; min-width: 300px; display: block; margin: auto;"></a>
53
+ </p>
54
+
55
+ ❗❗❗**Note: This performance is 100% reproducible! If you cannot reproduce it, please follow the steps in [Evaluation](#evaluation).**
56
+
57
+ ❗**Note: In this study, we copy the scores for HumanEval and HumanEval+ from the [LLM-Humaneval-Benchmarks](https://github.com/my-other-github-account/llm-humaneval-benchmarks). Notably, all the mentioned models generate code solutions for each problem utilizing a **single attempt**, and the resulting pass rate percentage is reported. Our **WizardCoder** generates answers using greedy decoding and tests with the same [code](https://github.com/evalplus/evalplus).**
58
+
59
+ ## Comparing WizardCoder-15B-V1.0 with the Open-Source Models.
60
+
61
+ The following table clearly demonstrates that our **WizardCoder** exhibits a substantial performance advantage over all the open-source models. ❗**If you are confused with the different scores of our model (57.3 and 59.8), please check the Notes.**
62
+
63
+
64
+ | Model | HumanEval Pass@1 | MBPP Pass@1 |
65
+ |------------------|------------------|-------------|
66
+ | CodeGen-16B-Multi| 18.3 |20.9 |
67
+ | CodeGeeX | 22.9 |24.4 |
68
+ | LLaMA-33B | 21.7 |30.2 |
69
+ | LLaMA-65B | 23.7 |37.7 |
70
+ | PaLM-540B | 26.2 |36.8 |
71
+ | PaLM-Coder-540B | 36.0 |47.0 |
72
+ | PaLM 2-S | 37.6 |50.0 |
73
+ | CodeGen-16B-Mono | 29.3 |35.3 |
74
+ | Code-Cushman-001 | 33.5 |45.9 |
75
+ | StarCoder-15B | 33.6 |43.6* |
76
+ | InstructCodeT5+ | 35.0 |-- |
77
+ | WizardLM-30B 1.0| 37.8 |-- |
78
+ | WizardCoder-15B 1.0 | **57.3** |**51.8** |
79
+
80
+ ❗**Note: The reproduced result of StarCoder on MBPP.**
81
+
82
+ ❗**Note: The above table conducts a comprehensive comparison of our **WizardCoder** with other models on the HumanEval and MBPP benchmarks. We adhere to the approach outlined in previous studies by generating **20 samples** for each problem to estimate the pass@1 score and evaluate with the same [code](https://github.com/openai/human-eval/tree/master). The scores of GPT4 and GPT3.5 reported by [OpenAI](https://openai.com/research/gpt-4) are 67.0 and 48.1 (maybe these are the early version GPT4&3.5).**
83
+
84
+ ## Call for Feedbacks
85
+ We welcome everyone to use your professional and difficult instructions to evaluate WizardCoder, and show us examples of poor performance and your suggestions in the [issue discussion](https://github.com/nlpxucan/WizardLM/issues) area. We are focusing on improving the Evol-Instruct now and hope to relieve existing weaknesses and issues in the the next version of WizardCoder. After that, we will open the code and pipeline of up-to-date Evol-Instruct algorithm and work with you together to improve it.
86
+
87
+ ## Unofficial Video Introductions
88
+ Thanks to the enthusiastic friends, their video introductions are more lively and interesting.
89
+ 1. [WizardCoder AI Is The NEW ChatGPT's Coding TWIN!](https://www.youtube.com/watch?v=XjsyHrmd3Xo)
90
+
91
+ ## Contents
92
+
93
+ 1. [Online Demo](#online-demo)
94
+
95
+ 2. [Fine-tuning](#fine-tuning)
96
+
97
+ 3. [Inference](#inference)
98
+
99
+ 4. [Evaluation](#evaluation)
100
+
101
+ 5. [Citation](#citation)
102
+
103
+ 6. [Disclaimer](#disclaimer)
104
+
105
+ ## Online Demo
106
+
107
+ We will provide our latest models for you to try for as long as possible. If you find a link is not working, please try another one. At the same time, please try as many **real-world** and **challenging** code-related problems that you encounter in your work and life as possible. We will continue to evolve our models with your feedbacks.
108
+
109
+ [Demo Link](https://e5eaf7d09cc1521c.gradio.app/) (We adopt the greedy decoding now.)
110
+
111
+ ## Fine-tuning
112
+
113
+ We fine-tune WizardCoder using the modified code `train.py` from [Llama-X](https://github.com/AetherCortex/Llama-X).
114
+ We fine-tune StarCoder-15B with the following hyperparameters:
115
+
116
+ | Hyperparameter | StarCoder-15B |
117
+ |----------------|---------------|
118
+ | Batch size | 512 |
119
+ | Learning rate | 2e-5 |
120
+ | Epochs | 3 |
121
+ | Max length | 2048 |
122
+ | Warmup step | 30 |
123
+ | LR scheduler | cosine |
124
+
125
+ To reproduce our fine-tuning of WizardCoder, please follow the following steps:
126
+ 1. According to the instructions of [Llama-X](https://github.com/AetherCortex/Llama-X), install the environment, download the training code, and deploy. (Note: `deepspeed==0.9.2` and `transformers==4.29.2`)
127
+ 2. Replace the `train.py` with the `train_wizardcoder.py` in our repo (`src/train_wizardcoder.py`)
128
+ 3. Login Huggingface:
129
+ ```bash
130
+ huggingface-cli login
131
+ ```
132
+ 4. Execute the following training command:
133
+ ```bash
134
+ deepspeed train_wizardcoder.py \
135
+ --model_name_or_path "bigcode/starcoder" \
136
+ --data_path "/your/path/to/code_instruction_data.json" \
137
+ --output_dir "/your/path/to/ckpt" \
138
+ --num_train_epochs 3 \
139
+ --model_max_length 2048 \
140
+ --per_device_train_batch_size 16 \
141
+ --per_device_eval_batch_size 1 \
142
+ --gradient_accumulation_steps 4 \
143
+ --evaluation_strategy "no" \
144
+ --save_strategy "steps" \
145
+ --save_steps 50 \
146
+ --save_total_limit 2 \
147
+ --learning_rate 2e-5 \
148
+ --warmup_steps 30 \
149
+ --logging_steps 2 \
150
+ --lr_scheduler_type "cosine" \
151
+ --report_to "tensorboard" \
152
+ --gradient_checkpointing True \
153
+ --deepspeed configs/deepspeed_config.json \
154
+ --fp16 True
155
+ ```
156
+
157
+ ## Inference
158
+
159
+ We provide the decoding script for WizardCoder, which reads a input file and generates corresponding responses for each sample, and finally consolidates them into an output file.
160
+
161
+ You can specify `base_model`, `input_data_path` and `output_data_path` in `src\inference_wizardcoder.py` to set the decoding model, path of input file and path of output file.
162
+
163
+ ```bash
164
+ pip install jsonlines
165
+ ```
166
+
167
+ The decoding command is:
168
+ ```
169
+ python src\inference_wizardcoder.py \
170
+ --base_model "/your/path/to/ckpt" \
171
+ --input_data_path "/your/path/to/input/data.jsonl" \
172
+ --output_data_path "/your/path/to/output/result.jsonl"
173
+ ```
174
+
175
+ The format of `data.jsonl` should be:
176
+ ```
177
+ {"idx": 11, "Instruction": "Write a Python code to count 1 to 10."}
178
+ {"idx": 12, "Instruction": "Write a Java code to sum 1 to 10."}
179
+ ```
180
+
181
+ The prompt for our WizardCoder in `src\inference_wizardcoder.py` is:
182
+ ```
183
+ Below is an instruction that describes a task. Write a response that appropriately completes the request.
184
+
185
+ ### Instruction:
186
+ {instruction}
187
+
188
+ ### Response:
189
+ ```
190
+
191
+ ## Evaluation
192
+
193
+ ### HumanEval
194
+
195
+ 1. According to the instructions of [HumanEval](https://github.com/openai/human-eval), install the environment.
196
+ 2. Run the following scripts to generate the answer.
197
+
198
+ - (1) For WizardCoder-15B-V1.0 (base on StarCoder)
199
+ ```bash
200
+ model="/path/to/your/model"
201
+ temp=0.2
202
+ max_len=2048
203
+ pred_num=200
204
+ num_seqs_per_iter=2
205
+
206
+ output_path=preds/T${temp}_N${pred_num}
207
+
208
+ mkdir -p ${output_path}
209
+ echo 'Output path: '$output_path
210
+ echo 'Model to eval: '$model
211
+
212
+ # 164 problems, 21 per GPU if GPU=8
213
+ index=0
214
+ gpu_num=8
215
+ for ((i = 0; i < $gpu_num; i++)); do
216
+ start_index=$((i * 21))
217
+ end_index=$(((i + 1) * 21))
218
+
219
+ gpu=$((i))
220
+ echo 'Running process #' ${i} 'from' $start_index 'to' $end_index 'on GPU' ${gpu}
221
+ ((index++))
222
+ (
223
+ CUDA_VISIBLE_DEVICES=$gpu python humaneval_gen.py --model ${model} \
224
+ --start_index ${start_index} --end_index ${end_index} --temperature ${temp} \
225
+ --num_seqs_per_iter ${num_seqs_per_iter} --N ${pred_num} --max_len ${max_len} --output_path ${output_path}
226
+ ) &
227
+ if (($index % $gpu_num == 0)); then wait; fi
228
+ done
229
+ ```
230
+
231
+ - (2) For WizardCoder-Python-34B-V1.0 (base on CodeLLama)
232
+
233
+ ```bash
234
+ pip install vllm # This can acclerate the inference process a lot.
235
+ pip install transformers==4.31.0
236
+
237
+ model="/path/to/your/model"
238
+ temp=0.2
239
+ max_len=2048
240
+ pred_num=200
241
+ num_seqs_per_iter=2
242
+
243
+ output_path=preds/T${temp}_N${pred_num}
244
+
245
+ mkdir -p ${output_path}
246
+ echo 'Output path: '$output_path
247
+ echo 'Model to eval: '$model
248
+
249
+ CUDA_VISIBLE_DEVICES=0,1,2,3 python humaneval_gen_vllm.py --model ${model} \
250
+ --start_index 0 --end_index 164 --temperature ${temp} \
251
+ --num_seqs_per_iter ${num_seqs_per_iter} --N ${pred_num} --max_len ${max_len} --output_path ${output_path} --num_gpus 4
252
+ ```
253
+
254
+ 3. Run the post processing code `src/process_humaneval.py` to collect the code completions from all answer files.
255
+ ```bash
256
+ output_path=preds/T${temp}_N${pred_num}
257
+
258
+ echo 'Output path: '$output_path
259
+ python process_humaneval.py --path ${output_path} --out_path ${output_path}.jsonl --add_prompt
260
+
261
+ evaluate_functional_correctness ${output_path}.jsonl
262
+ ```
263
+
264
+ ### How to Reproduce the 59.8 Pass@1 on HumanEval with Greedy Decoding?
265
+
266
+ ❗❗❗**This performance is 100% reproducible!**
267
+
268
+ Run the following script to generate the answer with greedy decoding. Then follow the above steps 2 and 3 to get the evaluation result.
269
+
270
+ ❗We also provide the generated codes in `data/humaneval.59.8.gen.zip`
271
+
272
+ ```bash
273
+ model="WizardLM/WizardCoder-15B-V1.0"
274
+ temp=0.0
275
+ max_len=2048
276
+ pred_num=1
277
+ num_seqs_per_iter=1
278
+
279
+ output_path=preds/T${temp}_N${pred_num}_WizardCoder_Greedy_Decode
280
+
281
+ mkdir -p ${output_path}
282
+ echo 'Output path: '$output_path
283
+ echo 'Model to eval: '$model
284
+
285
+ # 164 problems, 21 per GPU if GPU=8
286
+ index=0
287
+ gpu_num=8
288
+ for ((i = 0; i < $gpu_num; i++)); do
289
+ start_index=$((i * 21))
290
+ end_index=$(((i + 1) * 21))
291
+
292
+ gpu=$((i))
293
+ echo 'Running process #' ${i} 'from' $start_index 'to' $end_index 'on GPU' ${gpu}
294
+ ((index++))
295
+ (
296
+ CUDA_VISIBLE_DEVICES=$gpu python humaneval_gen.py --model ${model} \
297
+ --start_index ${start_index} --end_index ${end_index} --temperature ${temp} \
298
+ --num_seqs_per_iter ${num_seqs_per_iter} --N ${pred_num} --max_len ${max_len} --output_path ${output_path} --greedy_decode
299
+ ) &
300
+ if (($index % $gpu_num == 0)); then wait; fi
301
+ done
302
+ ```
303
+
304
+ ### MBPP
305
+
306
+ 1. Run the following script to generate the answer.
307
+ ```bash
308
+ model="/path/to/your/model"
309
+ temp=0.2
310
+ max_len=2048
311
+ pred_num=200
312
+ num_seqs_per_iter=2
313
+
314
+ output_path=preds/MBPP_T${temp}_N${pred_num}
315
+ mbpp_path=data/mbpp.test.jsonl # we provide this file in data/mbpp.test.zip
316
+
317
+ mkdir -p ${output_path}
318
+ echo 'Output path: '$output_path
319
+ echo 'Model to eval: '$model
320
+
321
+ # 500 problems, 63 per GPU if GPU=8
322
+ index=0
323
+ gpu_num=8
324
+ for ((i = 0; i < $gpu_num; i++)); do
325
+ start_index=$((i * 50))
326
+ end_index=$(((i + 1) * 50))
327
+
328
+ gpu=$((i))
329
+ echo 'Running process #' ${i} 'from' $start_index 'to' $end_index 'on GPU' ${gpu}
330
+ ((index++))
331
+ (
332
+ CUDA_VISIBLE_DEVICES=$gpu python mbpp_gen.py --model ${model} \
333
+ --start_index ${start_index} --end_index ${end_index} --temperature ${temp} \
334
+ --num_seqs_per_iter ${num_seqs_per_iter} --N ${pred_num} --max_len ${max_len} --output_path ${output_path} --mbpp_path ${mbpp_path}
335
+ ) &
336
+ if (($index % $gpu_num == 0)); then wait; fi
337
+ done
338
+ ```
339
+
340
+ 3. Run the post processing code `src/process_mbpp.py` to collect the code completions from all answer files.
341
+ ```bash
342
+ output_path=preds/MBPP_T${temp}_N${pred_num}
343
+ mbpp_path=data/mbpp.test.jsonl # we provide this file in data/mbpp.test.zip
344
+
345
+ echo 'Output path: '$output_path
346
+ python process_mbpp.py --path ${output_path} --out_path ${output_path}.jsonl --mbpp_path ${mbpp_path} --add_prompt
347
+ ```
348
+
349
+ 4. Evaluate the `MBPP_T${temp}_N${pred_num}.jsonl` with [bigcode-evaluation-harness](https://github.com/bigcode-project/bigcode-evaluation-harness).
350
+
351
+ Acknowledgement: The evaluation code `humaneval_gen.py`, `mbpp_gen.py` and bash scripts are modified from the great works of [CodeT5](https://github.com/salesforce/CodeT5).
352
+
353
+ ## Citation
354
+
355
+ Please cite the repo if you use the data or code in this repo.
356
+
357
+ ```
358
+ @misc{luo2023wizardcoder,
359
+ title={WizardCoder: Empowering Code Large Language Models with Evol-Instruct},
360
+ author={Ziyang Luo and Can Xu and Pu Zhao and Qingfeng Sun and Xiubo Geng and Wenxiang Hu and Chongyang Tao and Jing Ma and Qingwei Lin and Daxin Jiang},
361
+ year={2023},
362
+ eprint={2306.08568},
363
+ archivePrefix={arXiv},
364
+ primaryClass={cs.CL}
365
+ }
366
+ ```
367
+ ## Disclaimer
368
+
369
+ WizardCoder model follows the same license as StarCoder. The content produced by any version of WizardCoder is influenced by uncontrollable variables such as randomness, and therefore, the accuracy of the output cannot be guaranteed by this project. This project does not accept any legal liability for the content of the model output, nor does it assume responsibility for any losses incurred due to the use of associated resources and output results.
370
+
371
+ ## Star History
372
+
373
+ [![Star History Chart](https://api.star-history.com/svg?repos=nlpxucan/WizardLM&type=Timeline)](https://star-history.com/#nlpxucan/WizardLM&Timeline)