AB
AiBoss
project

CodeDPO - A code generation optimization framework jointly launched by Peking University and ByteDance.

CodeDPO is a code generation and optimization framework developed in collaboration between Peking University and ByteDance. It improves the correctness and efficiency of code models. The framework is based on a self-generation and verification mechanism, simultaneously building and evaluating code and its tests...

What is CodeDPO?

CodeDPO is a code generation and optimization framework developed in collaboration between Peking University and ByteDance. It improves the correctness and efficiency of code models. Based on a self-generation and verification mechanism, the framework simultaneously builds and evaluates code and its test cases, iteratively updating the ranking of code snippets using the PageRank algorithm, ultimately forming a dataset optimized for both correctness and efficiency. CodeDPO does not rely on external resources and can flexibly and scalably generate diverse, preference-optimized data, providing a solid foundation for optimizing code models in complex real-world scenarios.

Main functions of CodeDPO

  • Improve code accuracyThe self-verification mechanism ensures that the generated code can accurately solve the problem.
  • Optimize code efficiencyThe framework considers code execution efficiency, ensuring that the code is not only correct but also runs quickly.
  • Preference learning integrationIntegrating preference learning into code model training allows the model to make better choices between correct and incorrect solutions.
  • Self-generation and verificationIt generates code and test cases simultaneously, and uses the test cases to verify the correctness of the code.
  • Dataset ConstructionCreate a code preference optimization dataset based on correctness and efficiency for training and optimizing code models.
  • Reduce external dependenciesIt does not rely on external resources, and can independently generate and verify code and test cases, reducing the need for high-quality test data.

CodeDPO's technical principles

  • Self-generation and verification mechanismBased on the generated code and corresponding test cases, execute the test cases to verify the correctness of the code and build the dataset.
  • PageRank heuristic algorithmThe algorithm uses a PageRank-like approach to iteratively update the ranking score of code snippets, with the score based on how well the code passes tests, thus evaluating the correctness of the code.
  • Correctness optimizationBased on the self-verification process, code snippets that are more likely to be correct are identified because the code has passed more test cases.
  • Efficiency optimizationThe test cases that pass the best-performing code snippet during the correctness optimization phase are selected as the "trusted test set" to evaluate the code's execution efficiency.
  • Model training: Use methods such as Direct Preference Optimization (DPO) to train code models with datasets optimized for both correctness and efficiency, thereby improving the model's performance in these two aspects.

CodeDPO project address

Application scenarios of CodeDPO

  • Automated software developmentThe generated code can be directly used to automate the software development process, reducing the amount of manual coding work.
  • Code writing aidsIn an integrated development environment (IDE), it functions as a plugin to help developers quickly generate code snippets and improve development efficiency.
  • Education and LearningIn programming education, it assists students in learning programming languages and algorithms by generating example code to deepen their understanding.
  • Code quality assuranceIn the continuous integration/continuous deployment (CI/CD) process, it is used to generate test cases to help detect code defects and improve code quality.
  • Code optimization and refactoringIt helps identify inefficient or redundant code and proposes optimization solutions to achieve code refactoring and performance improvement.