arXiv:2410.24198cs.CLcs.LG2024-10NeurIPS被引 74

无需人工标注,用模型自动生成代码指令数据,显著提升小模型性能。

SelfCodeAlign: Self-Alignment for Code Generation

  • 用同一模型生成任务与响应,全程自动完成数据构建。
  • 生成7.4万条数据,小模型在HumanEval+上达67.1分,超大模型CodeLlama。
  • 适用于3B到33B多种规模模型,适合追求高效、透明的代码生成研究者。

指令微调能显著提升大语言模型遵循人类指令的能力。我们提出SelfCodeAlign,首个完全透明且开放许可的代码大模型自对齐管道,无需大量人工标注或知识蒸馏。SelfCodeAlign在整个数据生成过程中使用同一基础模型进行推理。首先从高质量代码片段中提取多样化的编程概念以生成新任务;接着为每个任务采样多个响应,配以测试用例,并在沙箱环境中验证;最后筛选通过的样本用于指令微调。主实验中,使用CodeQwen1.5-7B生成包含74,000条指令-响应对的数据集。微调后模型在HumanEval+上达到67.1的pass@1,超越十倍更大的CodeLlama-70B-Instruct。在所有基准测试中,该模型持续优于此前无需人工标注或蒸馏的最先进方法OctoPack。此外,SelfCodeAlign在3B至33B不同规模的模型上均有效,且基础模型更能受益于自身数据分布的对齐。我们验证了各组件有效性,表明其性能优于直接从GPT-4o蒸馏及主流GPT-3.5基蒸馏方法(如OSS-Instruct和Evol-Instruct)。SelfCodeAlign已促成StarCoder2-Instruct的诞生——首个完全透明、开源许可且自对齐的代码大模型,达到当前最优编码表现。

原文摘要 · Abstract (English)

Instruction tuning is a supervised fine-tuning approach that significantly improves the ability of large language models (LLMs) to follow human instructions. We propose SelfCodeAlign, the first fully transparent and permissive pipeline for self-aligning code LLMs without extensive human annotations or distillation. SelfCodeAlign employs the same base model for inference throughout the data generation process. It first extracts diverse coding concepts from high-quality seed snippets to generate new tasks. It then samples multiple responses per task, pairs each with test cases, and validates them in a sandbox environment. Finally, passing examples are selected for instruction tuning. In our primary experiments, we use SelfCodeAlign with CodeQwen1.5-7B to generate a dataset of 74k instruction-response pairs. Finetuning on this dataset leads to a model that achieves a 67.1 pass@1 on HumanEval+, surpassing CodeLlama-70B-Instruct despite being ten times smaller. Across all benchmarks, this finetuned model consistently outperforms the original version trained with OctoPack, the previous state-of-the-art method for instruction tuning without human annotations or distillation. Additionally, we show that SelfCodeAlign is effective across LLMs of various sizes, from 3B to 33B, and that the base models can benefit more from alignment with their own data distribution. We further validate each component's effectiveness in our pipeline, showing that SelfCodeAlign outperforms both direct distillation from GPT-4o and leading GPT-3.5-based distillation methods, such as OSS-Instruct and Evol-Instruct. SelfCodeAlign has also led to the creation of StarCoder2-Instruct, the first fully transparent, permissively licensed, and self-aligned code LLM that achieves state-of-the-art coding performance.

代码生成自对齐指令微调开源模型

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。