2024-11-02 · 专家 · 机器学习 · 计算机视觉 · 自然语言处理

SelfCodeAlign: Self-Alignment for Code Generation

SelfCodeAlign提出了一种无需大量人工标注或知识蒸馏的完全透明和许可的代码LLM自对齐管道,显著提升了模型在编程任务上的性能。

更新于 2024-11-09。作者:Yuxiang Wei、Federico Cassano、Jiawei Liu、Yifeng Ding、Naman Jain、Zachary Mueller、Harm de Vries、Leandro von Werra、Arjun Guha、Lingming Zhang。

中文摘要

指令微调是一种监督式微调方法,它显著提升了大型语言模型(LLMs)遵循人类指令的能力。我们提出了SelfCodeAlign,这是首个完全透明且具有许可性的自我对齐代码LLMs的流水线,无需大量的人类标注或蒸馏。SelfCodeAlign在整个数据生成过程中使用相同的基模型进行推理。它首先从高质量种子片段中提取多样化的编码概念以生成新的任务。然后,针对每个任务采样多个响应,将每个响应与测试案例配对,并在沙盒环境中验证它们。最后,选出通过验证的示例用于指令微调。在我们的主要实验中,我们使用SelfCodeAlign与CodeQwen1.5-7B生成包含74k指令-响应对的数据库。在这个数据库上进行微调,得到的模型在HumanEval+上的pass@1达到了67.1,尽管其规模是CodeLlama-70B-Instruct的十分之一,但仍然超越了后者。在所有基准测试中,这个经过微调的模型始终优于使用OctoPack训练的原版模型,而OctoPack是之前在没有人类标注或蒸馏的情况下进行指令微调的最佳方法。此外,我们还证明SelfCodeAlign适用于不同规模的LLMs,从30亿到330亿,并且基模型可以从与其自己的数据分布对齐中获益更多。我们进一步验证了我们流水线中每个组件的有效性,表明SelfCodeAlign优于从GPT-4o直接蒸馏以及领先基于GPT-3.5的蒸馏方法,如OSS-Instruct和Evol-Instruct。SelfCodeAlign还促成了StarCoder2-Instruct的创建,这是首个完全透明、具有许可性且自我对齐的代码LLMs,实现了最先进的编码性能。

英文摘要

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.

解读

一句话总结

SelfCodeAlign提出了一种无需大量人工标注或知识蒸馏的完全透明和许可的代码LLM自对齐管道,显著提升了模型在编程任务上的性能。

问题1:这篇论文想要解决什么具体问题?

• 问题背景:目前代码LLM的训练需要大量人工标注的指令-响应对或由大型私有LLM生成的数据,成本高且可能受限。 • 现有方案不足:现有方法依赖于人工标注或知识蒸馏,成本高、透明度低、可扩展性差。 • 研究目标:提出一种无需大量人工标注或知识蒸馏的代码LLM自对齐方法,提高训练效率和模型性能。

问题2:论文的核心创新点是什么?

• 技术创新:提出SelfCodeAlign管道,通过提取代码概念、生成新任务、采样响应、测试验证和指令微调等步骤实现自对齐。 • 方法改进:采用自生成数据,无需人工标注或知识蒸馏,提高透明度和可扩展性。 • 优势:与现有方法相比,SelfCodeAlign在性能上具有显著优势,同时降低了成本和提高了透明度。

问题3:实验结果如何验证了方法的有效性?

• 关键实验:使用CodeQwen1.5-7B在SelfCodeAlign生成的数据集上进行微调,并在多个基准测试中进行评估。 • 性能提升:在HumanEval+上,SelfCodeAlign-CQ-7B的pass@1达到67.1,超过CodeLlama-70B-Instruct,同时比CodeQwen1.5-7B-OctoPack高21.4个百分点。 • 对比结果:SelfCodeAlign-CQ-7B在所有基准测试中均优于原始模型和OctoPack训练的模型。

问题4:这个研究的实际应用价值是什么?

• 应用场景:SelfCodeAlign可用于提高代码LLM的训练效率和性能,降低成本和提高透明度。 • 实施建议:建议在代码LLM训练中使用SelfCodeAlign,以提高模型性能和降低成本。 • 局限与展望:SelfCodeAlign在数据生成和模型训练方面仍有改进空间,未来可进一步研究长上下文指令-响应对生成和负样本利用等问题。

来源

机器可读索引:llms.txt