CodeDPO: Aligning Code Models with Self Generated and Verified Source Code

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Zhang, Kechi, Li, Ge, Dong, Yihong, Xu, Jingjing, Zhang, Jun, Su, Jing, Liu, Yongfei, Jin, Zhi
Format: Preprint
Veröffentlicht: 2024
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866915318996140032
author Zhang, Kechi
Li, Ge
Dong, Yihong
Xu, Jingjing
Zhang, Jun
Su, Jing
Liu, Yongfei
Jin, Zhi
author_facet Zhang, Kechi
Li, Ge
Dong, Yihong
Xu, Jingjing
Zhang, Jun
Su, Jing
Liu, Yongfei
Jin, Zhi
contents Code generation models have shown significant potential for programming tasks. However, existing training methods like supervised fine-tuning face key limitations: they do not effectively teach models to prioritize correct over incorrect solutions in ambiguous situations, nor do they effectively optimize the runtime efficiency of the generated code. To address these challenges, we propose CodeDPO, a framework that integrates preference learning into code generation to improve two key code preference factors: code correctness and efficiency. CodeDPO employs a novel dataset construction method, utilizing a self-generation-and-validation mechanism that simultaneously generates and evaluates code and test cases. The underlying assumption is that test cases executable by multiple code snippets provide more reliable validation, and code that passes more tests is more likely to be correct. Through this self-validation process, our PageRank-inspired algorithm iteratively updates the ranking score of each code snippet, ultimately creating a code preference optimization dataset based on correctness and efficiency. CodeDPO is flexible and scalable, generating diverse preference optimization data without depending on external resources. Through comprehensive evaluations of five widely used benchmarks, CodeDPO demonstrates significant improvements in correctness and efficiency compared to existing methods. Our experiments prove that CodeDPO enhances the capabilities of LLMs in code generation and provides a robust foundation for conducting code preference optimization in more complex and challenging real-world scenarios.
format Preprint
id arxiv_https___arxiv_org_abs_2410_05605
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle CodeDPO: Aligning Code Models with Self Generated and Verified Source Code
Zhang, Kechi
Li, Ge
Dong, Yihong
Xu, Jingjing
Zhang, Jun
Su, Jing
Liu, Yongfei
Jin, Zhi
Software Engineering
Code generation models have shown significant potential for programming tasks. However, existing training methods like supervised fine-tuning face key limitations: they do not effectively teach models to prioritize correct over incorrect solutions in ambiguous situations, nor do they effectively optimize the runtime efficiency of the generated code. To address these challenges, we propose CodeDPO, a framework that integrates preference learning into code generation to improve two key code preference factors: code correctness and efficiency. CodeDPO employs a novel dataset construction method, utilizing a self-generation-and-validation mechanism that simultaneously generates and evaluates code and test cases. The underlying assumption is that test cases executable by multiple code snippets provide more reliable validation, and code that passes more tests is more likely to be correct. Through this self-validation process, our PageRank-inspired algorithm iteratively updates the ranking score of each code snippet, ultimately creating a code preference optimization dataset based on correctness and efficiency. CodeDPO is flexible and scalable, generating diverse preference optimization data without depending on external resources. Through comprehensive evaluations of five widely used benchmarks, CodeDPO demonstrates significant improvements in correctness and efficiency compared to existing methods. Our experiments prove that CodeDPO enhances the capabilities of LLMs in code generation and provides a robust foundation for conducting code preference optimization in more complex and challenging real-world scenarios.
title CodeDPO: Aligning Code Models with Self Generated and Verified Source Code
topic Software Engineering
url https://arxiv.org/abs/2410.05605