InstructCoder:指令微调大型语言模型以进行代码编辑
InstructCoder: Instruction Tuning Large Language Models for Code Editing
AI总结:
针对自动代码编辑数据稀缺及现有 LLM 指令遵循不足的问题,本文构建含 11.4 万余三元组的 InstructCoder 指令微调数据集,使开源模型达到先进专有模型的代码编辑性能。
摘要:
代码编辑涵盖开发者日常处理的各种实用任务。尽管它具有相关性和实际用途,但在深度学习模型的演进过程中,自动代码编辑仍是一个探索不足的领域,部分原因在于数据稀缺。在本研究中,我们探索使用大型语言模型(LLM)根据用户指令编辑代码。在一个名为 EditEval 的全新人工编写、基于执行的基准上进行评估后,我们发现当前模型往往难以完成这些指令。有鉴于此,我们贡献了 InstructCoder,这是首个旨在使 LLM 适配通用代码编辑的指令微调数据集,包含注释插入、代码优化和代码重构等高多样性代码编辑任务。它由超过 114,000 个指令-输入-输出三元组组成,覆盖多种不同的代码编辑场景。收集过程首先使用来自 GitHub Python 仓库的经过筛选的提交数据作为种子。随后,通过迭代过程系统性扩展数据集,在该过程中,种子任务和生成任务都被用于提示 ChatGPT 以获取更多数据。我们的研究结果表明,在 InstructCoder 上微调的开源 LLM 可以显著提高代码编辑的准确率,展现出与先进专有 LLM 相当的优越代码编辑性能。数据集和源代码可在 https://github.com/qishenghu/CodeInstruct 公开获取。
英文摘要:
Code editing encompasses a variety of pragmatic tasks that developers deal with daily. Despite its relevance and practical usefulness, automatic code editing remains an underexplored area in the evolution of deep learning models, partly due to data scarcity. In this work, we explore the use of Large Language Models (LLMs) to edit code based on user instructions. Evaluated on a novel human-written execution-based benchmark dubbed EditEval, we found current models often struggle to fulfill the instructions. In light of this, we contribute InstructCoder, the first instruction-tuning dataset designed to adapt LLMs for general-purpose code editing, containing high-diversity code-editing tasks such as comment insertion, code optimization, and code refactoring. It consists of over 114,000 instruction-input-output triplets and covers multiple distinct code editing scenarios. The collection process starts with filtered commit data sourced from GitHub Python repositories as seeds. Subsequently, the dataset is systematically expanded through an iterative process, where both seed and generated tasks are used to prompt ChatGPT for more data. Our findings reveal that open-source LLMs fine-tuned on InstructCoder can significantly enhance the accuracy of code edits, exhibiting superior code-editing performance matching advanced proprietary LLMs. The datasets and the source code are publicly available at https://github.com/qishenghu/CodeInstruct.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。