Learning Code Preference via Synthetic Evolution

Jiawei Liu, Thanh Nguyen, Mingyue Shang, Hantian Ding, Xiaopeng Li +3 more
10/4/2024
cs.LGcs.CLcs.SE

No official code found. Best implementation: amazon-science/llm-code-preference (38 stars, last commit 2024-11-15).

Abstract

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.

View on arXivView PDF

Code Implementations(1)

Training and Benchmarking LLMs for Code Preference.

383PythonOct 22, 20241 years agoNOASSERTION
code-generationllm-evaluationllm-trainingllms-benchmarking

Similar Papers

Cite this paper

@article{liu2024learning,
  title  = {Learning Code Preference via Synthetic Evolution},
  author = {Jiawei Liu and Thanh Nguyen and Mingyue Shang and Hantian Ding and Xiaopeng Li and Yu Yu and Varun Kumar and Zijian Wang},
  year   = {2024},
  eprint = {2410.03837},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2410.03837v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2410.03837.svg)](https://codeofpaper.com/paper/2410.03837)

Discussion