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

通过合成进化学习代码偏好

Learning Code Preference via Synthetic Evolution

University of Illinois Urbana-Champaign(伊利诺伊大学厄巴纳-香槟分校);AWS AI Labs(亚马逊云科技AI实验室)

Jiawei Liu, Thanh Nguyen, Mingyue Shang, Hantian Ding, Xiaopeng Li, Yu Yu, Varun Kumar, Zijian Wang

AI总结:

提出 CodeFavor 框架,利用代码提交与评论等合成进化数据训练成对代码偏好模型,并通过 CodePrefBench 验证其显著提升偏好判断准确率、降低成本。

摘要:

大语言模型(LLM)近期展现出卓越的编码能力。然而,基于良构属性评估代码生成并使其与开发者偏好保持一致,仍然具有挑战性。本文在代码偏好学习这一新挑战下探讨两个关键问题:(i)我们如何训练模型以预测有意义的代码偏好?以及(ii)人类和 LLM 的偏好如何与可验证的代码属性及开发者代码品味保持一致?为此,我们提出 CodeFavor,这是一个利用合成进化数据(包括代码提交和代码评论)训练成对代码偏好模型的框架。为评估代码偏好,我们引入 CodePrefBench,该基准包含 1364 个经过严格筛选的代码偏好任务,覆盖正确性、效率和安全性三种可验证属性,以及人类偏好。评估表明,CodeFavor 将基于模型的代码偏好准确率整体提升最高达 28.8%。同时,CodeFavor 模型能够匹配参数量为其 6–9 倍的模型性能,同时成本效益提高 34 倍。我们还通过一系列全面的受控实验严格验证了 CodeFavor 中的设计选择。此外,我们发现基于人类的代码偏好存在高昂成本和局限:尽管每个任务花费 23.4 人分钟,仍有 15.1–40.3% 的任务未解决。与基于模型的偏好相比,人类偏好在代码正确性目标下往往更准确,但在非功能性目标上并非最优。

英文摘要:

Large Language Models (LLMs) have recently demonstrated remarkable coding capabilities. However, assessing code generation based on well-formed properties and aligning it with developer preferences remains challenging. In this paper, we explore two key questions under the new challenge of code preference learning: (i) How do we train models to predict meaningful preferences for code? and (ii) How do human and LLM preferences align with verifiable code properties and developer code tastes? To this end, we propose CodeFavor, a framework for training pairwise code preference models from synthetic evolution data, including code commits and code critiques. To evaluate code preferences, we introduce CodePrefBench, a benchmark comprising 1364 rigorously curated code preference tasks to cover three verifiable properties-correctness, efficiency, and security-along with human preference. Our evaluation shows that CodeFavor holistically improves the accuracy of model-based code preferences by up to 28.8%. Meanwhile, CodeFavor models can match the performance of models with 6-9x more parameters while being 34x more cost-effective. We also rigorously validate the design choices in CodeFavor via a comprehensive set of controlled experiments. Furthermore, we discover the prohibitive costs and limitations of human-based code preference: despite spending 23.4 person-minutes on each task, 15.1-40.3% of tasks remain unsolved. Compared to model-based preference, human preference tends to be more accurate under the objective of code correctness, while being sub-optimal for non-functional objectives.

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

↑