一句话:提出结合功能等价代码变换与测试执行反馈的多任务学习,提升神经代码生成功能正确性。
现有神经代码生成多将代码视为普通文本,未充分利用程序特有信息,如功能等价的代码片段和测试执行反馈,因而生成代码的功能正确性仍受限。本文提出将程序分析与深度学习结合的方法:在训练阶段,设计若干代码变换启发式,为同一功能生成不同代码变体;同时利用测试执行反馈构造测试驱动的判别任务,训练判别器判断生成代码是否正确,并与生成任务进行多任务学习。在新发布数据集上的初步实验表明该框架有效,[email protected] 相比 CodeGPT 和 CodeT5 分别提升 8.81 和 11.53。
Automated code generation is a longstanding challenge in both communities of software engineering and artificial intelligence. Currently, some works have started to investigate the functional correctness of code generation, where a code snippet is considered correct if it passes a set of test cases. However, most existing works still model code generation as text generation without considering program-specific information, such as functionally equivalent code snippets and test execution feedback. To address the above limitations, this paper proposes a method combining program analysis with deep learning for neural code generation, where functionally equivalent code snippets and test execution feedback will be considered at the training stage. Concretely, we firstly design several code transformation heuristics to produce different variants of the code snippet satisfying the same functionality. In addition, we employ the test execution feedback and design a test-driven discriminative task to train a novel discriminator, aiming to let the model distinguish whether the generated code is correct or not. The preliminary results on a newly published dataset demonstrate the effectiveness of our proposed framework for code generation. Particularly, in terms of the [email protected] metric, we achieve 8.81 and 11.53 gains compared with CodeGPT and CodeT5, respectively.
@inproceedings{paperbot7167,
title = {Test-Driven Multi-Task Learning with Functionally Equivalent Code Transformation for Neural Code Generation},
author = {Xin Wang and Xiao Liu and Pingyi Zhou and Qixia Liu and Jin Liu and Hao Wu and Xiaohui Cui},
booktitle = {ASE},
year = {2022},
doi = {10.1145/3551349.3559549}
}