LoupGarou commited on
Commit
3e32822
1 Parent(s): 891bab4

Upload 10 files

Browse files
README.md ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: bigcode-openrail-m
3
+ ---
4
+
5
+ This is the Full-Weight of WizardCoder.
6
+
7
+ **Repository**: https://github.com/nlpxucan/WizardLM/tree/main/WizardCoder
8
+
9
+ **Twitter**: https://twitter.com/WizardLM_AI/status/1669109414559911937
10
+
11
+ **Paper**: [WizardCoder: Empowering Code Large Language Models with Evol-Instruct](https://arxiv.org/abs/2306.08568)
12
+
13
+
14
+
15
+
16
+
17
+ # WizardCoder: Empowering Code Large Language Models with Evol-Instruct
18
+
19
+
20
+ 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 LLM, StarCoder, utilizing the newly created instruction-following training set.
21
+
22
+ ## News
23
+
24
+ - 🔥 Our **WizardCoder-15B-v1.0** model achieves the **57.3 pass@1** on the [HumanEval Benchmarks](https://github.com/openai/human-eval), which is **22.3** points higher than the SOTA open-source Code LLMs.
25
+ - 🔥 We released **WizardCoder-15B-v1.0** trained with **78k** evolved code instructions. Please checkout the [Model Weights](https://huggingface.co/WizardLM/WizardCoder-15B-V1.0), and [Paper]().
26
+ - 📣 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.
27
+
28
+
29
+ ## Comparing WizardCoder with the Closed-Source Models.
30
+
31
+
32
+ 🔥 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.
33
+
34
+ <p align="center" width="100%">
35
+ <a ><img src="https://raw.githubusercontent.com/nlpxucan/WizardLM/main/WizardCoder/imgs/pass1.png" alt="WizardCoder" style="width: 86%; min-width: 300px; display: block; margin: auto;"></a>
36
+ </p>
37
+
38
+ ❗**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).**
39
+
40
+ ## Comparing WizardCoder with the Open-Source Models.
41
+
42
+ 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.**
43
+
44
+
45
+ | Model | HumanEval Pass@1 | MBPP Pass@1 |
46
+ |------------------|------------------|-------------|
47
+ | CodeGen-16B-Multi| 18.3 |20.9 |
48
+ | CodeGeeX | 22.9 |24.4 |
49
+ | LLaMA-33B | 21.7 |30.2 |
50
+ | LLaMA-65B | 23.7 |37.7 |
51
+ | PaLM-540B | 26.2 |36.8 |
52
+ | PaLM-Coder-540B | 36.0 |47.0 |
53
+ | PaLM 2-S | 37.6 |50.0 |
54
+ | CodeGen-16B-Mono | 29.3 |35.3 |
55
+ | Code-Cushman-001 | 33.5 |45.9 |
56
+ | StarCoder-15B | 33.6 |43.6* |
57
+ | InstructCodeT5+ | 35.0 |-- |
58
+ | WizardLM-30B 1.0| 37.8 |-- |
59
+ | WizardCoder-15B 1.0 | **57.3** |**51.8** |
60
+
61
+
62
+ ❗**Note: The reproduced result of StarCoder on MBPP.**
63
+
64
+ ❗**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).**
65
+
66
+ ## Call for Feedbacks
67
+ 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.
68
+
69
+
70
+ ## Contents
71
+
72
+ 1. [Online Demo](#online-demo)
73
+
74
+ 2. [Fine-tuning](#fine-tuning)
75
+
76
+ 3. [Inference](#inference)
77
+
78
+ 4. [Evaluation](#evaluation)
79
+
80
+ 5. [Citation](#citation)
81
+
82
+ 6. [Disclaimer](#disclaimer)
83
+
84
+ ## Online Demo
85
+
86
+ 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.
87
+
88
+
89
+
90
+ ## Fine-tuning
91
+
92
+ We fine-tune WizardCoder using the modified code `train.py` from [Llama-X](https://github.com/AetherCortex/Llama-X).
93
+ We fine-tune StarCoder-15B with the following hyperparameters:
94
+
95
+ | Hyperparameter | StarCoder-15B |
96
+ |----------------|---------------|
97
+ | Batch size | 512 |
98
+ | Learning rate | 2e-5 |
99
+ | Epochs | 3 |
100
+ | Max length | 2048 |
101
+ | Warmup step | 30 |
102
+ | LR scheduler | cosine |
103
+
104
+ To reproduce our fine-tuning of WizardCoder, please follow the following steps:
105
+ 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`)
106
+ 2. Replace the `train.py` with the `train_wizardcoder.py` in our repo (`src/train_wizardcoder.py`)
107
+ 3. Login Huggingface:
108
+ ```bash
109
+ huggingface-cli login
110
+ ```
111
+ 4. Execute the following training command:
112
+ ```bash
113
+ deepspeed train_wizardcoder.py \
114
+ --model_name_or_path "bigcode/starcoder" \
115
+ --data_path "/your/path/to/code_instruction_data.json" \
116
+ --output_dir "/your/path/to/ckpt" \
117
+ --num_train_epochs 3 \
118
+ --model_max_length 2048 \
119
+ --per_device_train_batch_size 16 \
120
+ --per_device_eval_batch_size 1 \
121
+ --gradient_accumulation_steps 4 \
122
+ --evaluation_strategy "no" \
123
+ --save_strategy "steps" \
124
+ --save_steps 50 \
125
+ --save_total_limit 2 \
126
+ --learning_rate 2e-5 \
127
+ --warmup_steps 30 \
128
+ --logging_steps 2 \
129
+ --lr_scheduler_type "cosine" \
130
+ --report_to "tensorboard" \
131
+ --gradient_checkpointing True \
132
+ --deepspeed configs/deepspeed_config.json \
133
+ --fp16 True
134
+ ```
135
+
136
+ ## Inference
137
+
138
+ 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.
139
+
140
+ 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.
141
+
142
+ ```bash
143
+ pip install jsonlines
144
+ ```
145
+
146
+ The decoding command is:
147
+ ```
148
+ python src\inference_wizardcoder.py \
149
+ --base_model "/your/path/to/ckpt" \
150
+ --input_data_path "/your/path/to/input/data.jsonl" \
151
+ --output_data_path "/your/path/to/output/result.jsonl"
152
+ ```
153
+
154
+ The format of `data.jsonl` should be:
155
+ ```
156
+ {"idx": 11, "Instruction": "Write a Python code to count 1 to 10."}
157
+ {"idx": 12, "Instruction": "Write a Jave code to sum 1 to 10."}
158
+ ```
159
+
160
+ The prompt for our WizardCoder in `src\inference_wizardcoder.py` is:
161
+ ```
162
+ Below is an instruction that describes a task. Write a response that appropriately completes the request.
163
+
164
+ ### Instruction:
165
+ {instruction}
166
+
167
+ ### Response:
168
+ ```
169
+
170
+ ## Evaluation
171
+
172
+ We provide the evaluation script on HumanEval for WizardCoder.
173
+
174
+ 1. According to the instructions of [HumanEval](https://github.com/openai/human-eval), install the environment.
175
+ 2. Run the following script to generate the answer.
176
+ ```bash
177
+ model="/path/to/your/model"
178
+ temp=0.2
179
+ max_len=2048
180
+ pred_num=200
181
+ num_seqs_per_iter=2
182
+
183
+ output_path=preds/T${temp}_N${pred_num}
184
+
185
+ mkdir -p ${output_path}
186
+ echo 'Output path: '$output_path
187
+ echo 'Model to eval: '$model
188
+
189
+ # 164 problems, 21 per GPU if GPU=8
190
+ index=0
191
+ gpu_num=8
192
+ for ((i = 0; i < $gpu_num; i++)); do
193
+ start_index=$((i * 21))
194
+ end_index=$(((i + 1) * 21))
195
+
196
+ gpu=$((i))
197
+ echo 'Running process #' ${i} 'from' $start_index 'to' $end_index 'on GPU' ${gpu}
198
+ ((index++))
199
+ (
200
+ CUDA_VISIBLE_DEVICES=$gpu python humaneval_gen.py --model ${model} \
201
+ --start_index ${start_index} --end_index ${end_index} --temperature ${temp} \
202
+ --num_seqs_per_iter ${num_seqs_per_iter} --N ${pred_num} --max_len ${max_len} --output_path ${output_path}
203
+ ) &
204
+ if (($index % $gpu_num == 0)); then wait; fi
205
+ done
206
+ ```
207
+ 3. Run the post processing code `src/process_humaneval.py` to collect the code completions from all answer files.
208
+ ```bash
209
+ output_path=preds/T${temp}_N${pred_num}
210
+
211
+ echo 'Output path: '$output_path
212
+ python process_humaneval.py --path ${output_path} --out_path ${output_path}.jsonl --add_prompt
213
+
214
+ evaluate_functional_correctness ${output_path}.jsonl
215
+ ```
216
+
217
+ ## Citation
218
+
219
+ Please cite the repo if you use the data or code in this repo.
220
+
221
+ ```
222
+ @misc{luo2023wizardcoder,
223
+ title={WizardCoder: Empowering Code Large Language Models with Evol-Instruct},
224
+ 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},
225
+ year={2023},
226
+ }
227
+ ```
228
+ ## Disclaimer
229
+
230
+ The resources, including code, data, and model weights, associated with this project are restricted for academic research purposes only and cannot be used for commercial purposes. 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.
231
+
added_tokens.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "[PAD]": 49152
3
+ }
config.json ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "bigcode/starcoder",
3
+ "activation_function": "gelu",
4
+ "architectures": [
5
+ "GPTBigCodeForCausalLM"
6
+ ],
7
+ "attention_softmax_in_fp32": true,
8
+ "attn_pdrop": 0.1,
9
+ "bos_token_id": 0,
10
+ "embd_pdrop": 0.1,
11
+ "eos_token_id": 0,
12
+ "inference_runner": 0,
13
+ "initializer_range": 0.02,
14
+ "layer_norm_epsilon": 1e-05,
15
+ "max_batch_size": null,
16
+ "max_sequence_length": null,
17
+ "model_type": "gpt_bigcode",
18
+ "multi_query": true,
19
+ "n_embd": 6144,
20
+ "n_head": 48,
21
+ "n_inner": 24576,
22
+ "n_layer": 40,
23
+ "n_positions": 8192,
24
+ "pad_key_length": true,
25
+ "pre_allocate_kv_cache": false,
26
+ "resid_pdrop": 0.1,
27
+ "scale_attention_softmax_in_fp32": true,
28
+ "scale_attn_weights": true,
29
+ "summary_activation": null,
30
+ "summary_first_dropout": 0.1,
31
+ "summary_proj_to_labels": true,
32
+ "summary_type": "cls_index",
33
+ "summary_use_proj": true,
34
+ "torch_dtype": "float16",
35
+ "transformers_version": "4.30.0.dev0",
36
+ "use_cache": true,
37
+ "validate_runner_input": true,
38
+ "vocab_size": 49153
39
+ }
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 0,
4
+ "eos_token_id": 0,
5
+ "transformers_version": "4.30.0.dev0"
6
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
special_tokens_map.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|endoftext|>",
4
+ "<fim_prefix>",
5
+ "<fim_middle>",
6
+ "<fim_suffix>",
7
+ "<fim_pad>",
8
+ "<filename>",
9
+ "<gh_stars>",
10
+ "<issue_start>",
11
+ "<issue_comment>",
12
+ "<issue_closed>",
13
+ "<jupyter_start>",
14
+ "<jupyter_text>",
15
+ "<jupyter_code>",
16
+ "<jupyter_output>",
17
+ "<empty_output>",
18
+ "<commit_before>",
19
+ "<commit_msg>",
20
+ "<commit_after>",
21
+ "<reponame>"
22
+ ],
23
+ "bos_token": "<|endoftext|>",
24
+ "eos_token": "<|endoftext|>",
25
+ "pad_token": "[PAD]",
26
+ "unk_token": "<|endoftext|>"
27
+ }
split_pytorch.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import torch
3
+ import json
4
+
5
+ # load your large model
6
+ model = SomeLargeModel('/mnt/e/ai_cache/output/wizardcoder_mmlu_2/merged')
7
+ model.load_state_dict(torch.load('pytorch_model.bin'))
8
+
9
+ # save each tensor to a separate file and record the mapping in the index
10
+ state_dict = model.state_dict()
11
+ index = {"metadata": {"total_size": 0}, "weight_map": {}}
12
+ i = 1
13
+ total_files = len(state_dict.keys())
14
+
15
+ for key, tensor in state_dict.items():
16
+ chunk_file = f'pytorch_model-{str(i).zfill(5)}-of-{str(total_files).zfill(5)}.bin'
17
+ torch.save({key: tensor}, chunk_file)
18
+ index["weight_map"][key] = chunk_file
19
+ index["metadata"]["total_size"] += tensor.nelement() * tensor.element_size()
20
+ i += 1
21
+
22
+ # save the index
23
+ with open('pytorch_model.bin.index', 'w') as f:
24
+ json.dump(index, f)
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "additional_special_tokens": [
4
+ "<|endoftext|>",
5
+ "<fim_prefix>",
6
+ "<fim_middle>",
7
+ "<fim_suffix>",
8
+ "<fim_pad>",
9
+ "<filename>",
10
+ "<gh_stars>",
11
+ "<issue_start>",
12
+ "<issue_comment>",
13
+ "<issue_closed>",
14
+ "<jupyter_start>",
15
+ "<jupyter_text>",
16
+ "<jupyter_code>",
17
+ "<jupyter_output>",
18
+ "<empty_output>",
19
+ "<commit_before>",
20
+ "<commit_msg>",
21
+ "<commit_after>",
22
+ "<reponame>"
23
+ ],
24
+ "bos_token": "<|endoftext|>",
25
+ "clean_up_tokenization_spaces": true,
26
+ "eos_token": "<|endoftext|>",
27
+ "model_max_length": 2048,
28
+ "padding_side": "right",
29
+ "tokenizer_class": "GPT2Tokenizer",
30
+ "unk_token": "<|endoftext|>",
31
+ "vocab_size": 49152
32
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff