用合成演化数据训练代码偏好模型,提升生成代码质量与效率。
Learning Code Preference via Synthetic Evolution
- 基于代码提交和评注构建合成演化数据,训练成对代码偏好模型。
- 在1364个任务上准确率提升28.8%,仅需34倍更低成本。
- 适合需要高效、可扩展代码评估的开发者与研究者使用。
大型语言模型在代码生成方面表现出色,但如何基于良好结构属性评估生成代码并与其开发者偏好对齐仍具挑战。本文提出CodeFavor框架,利用合成演化数据(包括代码提交与代码评注)训练成对代码偏好模型。为评估偏好,我们构建CodePrefBench基准,涵盖1364个严格筛选的任务,覆盖正确性、效率、安全性三类可验证属性及人类偏好。实验表明,CodeFavor在模型预测偏好准确率上最高提升28.8%;其性能可媲美参数量6-9倍更大的模型,同时成本降低34倍。通过控制实验验证设计合理性。此外,发现人工标注成本极高:每任务耗时23.4人分钟,仍有15.1%-40.3%无法解决;人类偏好在代码正确性上更优,但在非功能性目标上表现欠佳。
原文摘要 · Abstract (English)
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.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。