arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2408.05727cs.SE
收藏

大型语言模型代码热修复

Hotfixing Large Language Models for Code

Zhou Yang, David Lo

AI总结:

本文提出热修复LLM4Code的概念,通过同时优化学习期望行为、取消学习不良行为和保留其他代码知识三个目标,使用LoRA微调技术有效减少有缺陷代码生成并增加已修复代码生成,且不影响功能正确性。

摘要:

大型语言模型用于代码(LLM4Code)已成为开发者工作流程中不可或缺的一部分,协助完成代码补全和生成等任务。然而,这些模型在发布后被发现表现出不良行为,例如生成有缺陷的代码,这归因于它们在包含此类有缺陷代码的大量源代码上进行了广泛训练。训练数据(通常来自开源软件)不断演变,例如开发者修复有缺陷的代码。然而,适应这种演变以减轻LLM4Code的不良行为并非易事,因为在更新后的数据集上重新训练模型通常需要大量时间和资源。这促使我们提出LLM4Code热修复的概念,即以最小的负面影响有效且高效地减轻LLM4Code的不良行为。本文主要聚焦于热修复LLM4Code,使其生成更少有缺陷的代码和更多已修复的代码。我们首先证明来自流行的CodeGen系列的模型经常生成有缺陷的代码。然后,我们定义了热修复中的三个学习目标,并为每个目标设计了多种损失函数:(1)学习期望行为,(2)取消学习不良行为,以及(3)保留其他代码的知识。我们评估了四种不同的微调技术用于热修复模型,并获得以下见解。使用LoRA(低秩适配)同时优化这三个学习目标,能有效影响模型的行为。具体而言,它将已修复代码的生成量提高了最多108.42%,并将有缺陷代码的生成量降低了最多50.47%。统计检验确认,热修复并未显著影响模型在HumanEval基准上的功能正确性。此外,为评估热修复的泛化性,通过将电子邮件地址的暴露减少99.30%来验证。

英文摘要:

Large Language Models for Code (LLM4Code) have become an integral part of developers' workflows, assisting with tasks such as code completion and generation. However, these models are found to exhibit undesired behaviors after their release, like generating buggy code, due to their extensive training on vast amounts of source code that contain such buggy code. The training data (usually coming from open-source software) keeps evolving, e.g., developers fix the buggy code. However, adapting such evolution to mitigate LLM4Code's undesired behaviors is non-trivial, as retraining models on the updated dataset usually takes much time and resources. This motivates us to propose the concept of hotfixing LLM4Code, mitigating LLM4Code's undesired behaviors effectively and efficiently with minimal negative effects. This paper mainly focuses on hotfixing LLM4Code to make them generate less buggy code and more fixed code. We begin by demonstrating that models from the popular CodeGen family frequently generate buggy code. Then, we define three learning objectives in hotfixing and design multiple loss functions for each objective: (1) learn the desired behaviors, (2) unlearn the undesired behaviors, and (3) retain knowledge of other code. We evaluate four different fine-tuning techniques for hotfixing the models and gain the following insights. Optimizing these three learning goals together, using LoRA (low-rank adaptation), effectively influences the model's behavior. Specifically, it increases the generation of fixed code by up to 108.42% and decreases the generation of buggy code by up to 50.47%. Statistical tests confirm that hotfixing does not significantly affect the models' functional correctness on the HumanEval benchmark. Additionally, to evaluate the generalizability of hotfixing by reducing the exposure of email addresses by 99.30%.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑