模型:
WizardLM/WizardCoder-15B-V1.0
这是WizardCoder的完整版本。
Repository: https://github.com/nlpxucan/WizardLM/tree/main/WizardCoder
Twitter: https://twitter.com/WizardLM_AI/status/1669109414559911937
论文: WizardCoder: Empowering Code Large Language Models with Evol-Instruct
为了开发我们的WizardCoder模型,我们首先根据编程任务对Evol-Instruct方法进行了改进。这涉及将提示信息定制为代码相关指令的领域。随后,我们使用新创建的遵循指令的训练集对Code LLM模型StarCoder进行了微调。
🔥下图显示,我们的WizardCoder在此基准中排名第三,超过Claude-Plus(59.8 vs 53.0)和Bard(59.8 vs 44.5)。值得注意的是,相比这些模型,我们的模型体积更小。
❗注意:在这项研究中,我们从 LLM-Humaneval-Benchmarks 拷贝了HumanEval和HumanEval+的得分。值得注意的是,所有提到的模型都是使用一次尝试生成问题的代码解决方案,并报告结果的pass rate百分比。我们的WizardCoder使用贪婪解码生成答案,并使用相同的 code 进行测试。
下表清楚地显示了我们的WizardCoder相比于所有开源模型的性能优势。❗如果你对我们模型的不同得分(57.3和59.8)感到困惑,请查看注释。
| Model | HumanEval Pass@1 | MBPP Pass@1 |
|---|---|---|
| CodeGen-16B-Multi | 18.3 | 20.9 |
| CodeGeeX | 22.9 | 24.4 |
| LLaMA-33B | 21.7 | 30.2 |
| LLaMA-65B | 23.7 | 37.7 |
| PaLM-540B | 26.2 | 36.8 |
| PaLM-Coder-540B | 36.0 | 47.0 |
| PaLM 2-S | 37.6 | 50.0 |
| CodeGen-16B-Mono | 29.3 | 35.3 |
| Code-Cushman-001 | 33.5 | 45.9 |
| StarCoder-15B | 33.6 | 43.6* |
| InstructCodeT5+ | 35.0 | -- |
| WizardLM-30B 1.0 | 37.8 | -- |
| WizardCoder-15B 1.0 | 57.3 | 51.8 |
❗注意:StarCoder在MBPP上的再现结果。
❗注意:上述表格对我们的WizardCoder与其他模型在HumanEval和MBPP基准上进行了全面比较。我们按照之前的研究中的方法为每个问题生成20个样本以估计pass@1得分,并使用相同的 code 进行评估。 OpenAI 所报告的GPT4和GPT3.5的得分分别为67.0和48.1(可能是早期版本的GPT4&3.5)。
我们欢迎大家使用专业而困难的指令来评估WizardCoder,并向我们展示性能不佳的例子和你的建议。我们正致力于改进Evol-Instruct,并希望在WizardCoder的下一个版本中解决现有的弱点和问题。之后,我们将公开最新版本的Evol-Instruct算法的代码和流程,并与您一起改进它。
在线演示
微调
推理
评估
引用
免责声明
我们将尽可能长时间地为您提供我们的最新模型。如果您发现链接失效,请尝试其他链接。同时,请尽可能多地尝试在工作和生活中遇到的真实和具有挑战性的与代码相关的问题。我们将根据您的反馈不断改进我们的模型。
我们使用 Llama-X 中的修改后的train.py代码对WizardCoder进行微调。我们使用以下超参数对StarCoder-15B进行微调:
| Hyperparameter | StarCoder-15B |
|---|---|
| Batch size | 512 |
| Learning rate | 2e-5 |
| Epochs | 3 |
| Max length | 2048 |
| Warmup step | 30 |
| LR scheduler | cosine |
要复现我们对WizardCoder的微调,请按照以下步骤进行操作:
huggingface-cli login
deepspeed train_wizardcoder.py \
--model_name_or_path "bigcode/starcoder" \
--data_path "/your/path/to/code_instruction_data.json" \
--output_dir "/your/path/to/ckpt" \
--num_train_epochs 3 \
--model_max_length 2048 \
--per_device_train_batch_size 16 \
--per_device_eval_batch_size 1 \
--gradient_accumulation_steps 4 \
--evaluation_strategy "no" \
--save_strategy "steps" \
--save_steps 50 \
--save_total_limit 2 \
--learning_rate 2e-5 \
--warmup_steps 30 \
--logging_steps 2 \
--lr_scheduler_type "cosine" \
--report_to "tensorboard" \
--gradient_checkpointing True \
--deepspeed configs/deepspeed_config.json \
--fp16 True
我们提供了用于WizardCoder的解码脚本,该脚本读取一个输入文件,并为每个样本生成相应的响应,最后将它们合并到一个输出文件中。
您可以在src\inference_wizardcoder.py中指定base_model、input_data_path和output_data_path来设置解码模型、输入文件路径和输出文件路径。
pip install jsonlines
解码的命令是:
python src\inference_wizardcoder.py \
--base_model "/your/path/to/ckpt" \
--input_data_path "/your/path/to/input/data.jsonl" \
--output_data_path "/your/path/to/output/result.jsonl"
data.jsonl的格式应为:
{"idx": 11, "Instruction": "Write a Python code to count 1 to 10."}
{"idx": 12, "Instruction": "Write a Jave code to sum 1 to 10."}
在src\inference_wizardcoder.py中,WizardCoder的提示是:
Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
{instruction}
### Response:
我们提供了用于HumanEval的WizardCoder评估脚本。
model="/path/to/your/model"
temp=0.2
max_len=2048
pred_num=200
num_seqs_per_iter=2
output_path=preds/T${temp}_N${pred_num}
mkdir -p ${output_path}
echo 'Output path: '$output_path
echo 'Model to eval: '$model
# 164 problems, 21 per GPU if GPU=8
index=0
gpu_num=8
for ((i = 0; i < $gpu_num; i++)); do
start_index=$((i * 21))
end_index=$(((i + 1) * 21))
gpu=$((i))
echo 'Running process #' ${i} 'from' $start_index 'to' $end_index 'on GPU' ${gpu}
((index++))
(
CUDA_VISIBLE_DEVICES=$gpu python humaneval_gen.py --model ${model} \
--start_index ${start_index} --end_index ${end_index} --temperature ${temp} \
--num_seqs_per_iter ${num_seqs_per_iter} --N ${pred_num} --max_len ${max_len} --output_path ${output_path}
) &
if (($index % $gpu_num == 0)); then wait; fi
done
output_path=preds/T${temp}_N${pred_num}
echo 'Output path: '$output_path
python process_humaneval.py --path ${output_path} --out_path ${output_path}.jsonl --add_prompt
evaluate_functional_correctness ${output_path}.jsonl
如果您在此仓库中使用数据或代码,请引用。
@misc{luo2023wizardcoder,
title={WizardCoder: Empowering Code Large Language Models with Evol-Instruct},
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},
year={2023},
}
与该项目相关的资源,包括代码、数据和模型权重,仅限于学术研究目的,并且不能用于商业用途。任何版本的WizardCoder生成的内容都受到无法控制的变量(如随机性)的影响,因此无法保证输出的准确性。本项目对模型输出的内容不承担任何法律责任,并且不对使用相关资源和输出结果所造成的任何损失承担责任。