Two Birds with One Stone: Boosting Code Generation and Code Search via a Generative Adversarial Network

被引:4
|
作者
Wang, Shangwen [1 ,6 ]
Lin, Bo [1 ]
Sun, Zhensu [2 ]
Wen, Ming [3 ]
Liu, Yepang [4 ]
Lei, Yan [5 ]
Mao, Xiaoguang [1 ]
机构
[1] Natl Univ Def Technol, Coll Comp, Key Lab Software Engn Complex Syst, Changsha, Peoples R China
[2] Singapore Management Univ, Singapore, Singapore
[3] Huazhong Univ Sci & Technol, Sch Cyber Sci & Engn, Wuhan, Peoples R China
[4] Southern Univ Sci & Technol, Res Inst Trustworthy Autonoumous Syst, Dept Comp Sci & Engn, Shenzhen, Peoples R China
[5] Chongqing Univ, Chongqing, Peoples R China
[6] Southern Univ Sci & Technol, Shenzhen, Peoples R China
来源
基金
国家重点研发计划; 中国国家自然科学基金;
关键词
Code Generation; Code Search; Generative Adversarial Network;
D O I
10.1145/3622815
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Automatically transforming developers' natural language descriptions into source code has been a longstanding goal in software engineering research. Two types of approaches have been proposed in the literature to achieve this: code generation, which involves generating a new code snippet, and code search, which involves reusing existing code. However, despite existing efforts, the effectiveness of the state-of-the-art techniques remains limited. To seek for further advancement, our insight is that code generation and code search can help overcome the limitation of each other: the code generator can benefit from feedback on the quality of its generated code, which can be provided by the code searcher, while the code searcher can benefit from the additional training data augmented by the code generator to better understand code semantics. Drawing on this insight, we propose a novel approach that combines code generation and code search techniques using a generative adversarial network (GAN), enabling mutual improvement through the adversarial training. Specifically, we treat code generation and code search as the generator and discriminator in the GAN framework, respectively, and incorporate several customized designs for our tasks. We evaluate our approach in eight different settings, and consistently observe significant performance improvements for both code generation and code search. For instance, when using NatGen, a state-of-the-art code generator, as the generator and GraphCodeBERT, a state-of-the-art code searcher, as the discriminator, we achieve a 32% increase in CodeBLEU score for code generation, and a 12% increase in mean reciprocal rank for code search on a large-scale Python dataset, compared to their original performances.
引用
收藏
页数:30
相关论文
共 50 条
  • [31] Contactless Blood Pressure Measurement via Remote Photoplethysmography with Synthetic Data Generation Using Generative Adversarial Network
    Wu, Bing-Fei
    Chiu, Li-Wen
    Wu, Yi-Chiao
    Lai, Chun-Chih
    Chu, Pao-Hsien
    2022 IEEE/CVF CONFERENCE ON COMPUTER VISION AND PATTERN RECOGNITION WORKSHOPS, CVPRW 2022, 2022, : 2129 - 2137
  • [32] Correlation via Synthesis: End-to-end Image Generation and Radiogenomic Learning Based on Generative Adversarial Network
    Xu, Ziyue
    Wang, Xiaosong
    Shin, Hoo-Chang
    Yang, Dong
    Roth, Holger
    Milletari, Fausto
    Zhang, Ling
    Xu, Daguang
    MEDICAL IMAGING WITH DEEP LEARNING, VOL 121, 2020, 121 : 857 - 866
  • [33] Unsupervised Generation and Synthesis of Facial Images via an Auto-Encoder-Based Deep Generative Adversarial Network
    Kwak, Jeong gi
    Ko, Hanseok
    APPLIED SCIENCES-BASEL, 2020, 10 (06):
  • [34] Kill Two Birds with One Stone: Boosting Both Object Detection Accuracy and Speed with Adaptive Patch-of-Interest Composition
    Zhang, Shihao
    Lin, Weiyao
    Lu, Ping
    Li, Weihua
    Deng, Shuo
    2017 IEEE INTERNATIONAL CONFERENCE ON MULTIMEDIA & EXPO WORKSHOPS (ICMEW), 2017,
  • [35] In Situ Preparation of Porous Humidity Sensitive Composite via a One-Stone-Two-Birds Strategy
    Dai, Jianxun
    Guan, Xin
    Zhao, Hongran
    Liu, Sen
    Fei, Teng
    Zhang, Tong
    SENSORS AND ACTUATORS B-CHEMICAL, 2020, 316
  • [36] Generative adversarial network based two-stage generation of high-quality images from text
    Cao Y.
    Qin J.
    Gao T.
    Ma Q.
    Ren J.
    Zhejiang Daxue Xuebao (Gongxue Ban)/Journal of Zhejiang University (Engineering Science), 2024, 58 (04): : 674 - 683
  • [37] Quantification of scar collagen texture and prediction of scar development via second harmonic generation images and a generative adversarial network
    Wang, Qing
    Liu, Weiping
    Chen, Xinghong
    Wang, Xiumei
    Chen, Guannan
    Zhu, Xiaoqin
    BIOMEDICAL OPTICS EXPRESS, 2021, 12 (08) : 5305 - 5319
  • [38] Kill Two Birds with One Stone: Weakly-Supervised Neural Network for Image Annotation and Tag Refinement
    Zhang, Junjie
    Wu, Qi
    Zhang, Jian
    Shen, Chunhua
    Lu, Jianfeng
    THIRTY-SECOND AAAI CONFERENCE ON ARTIFICIAL INTELLIGENCE / THIRTIETH INNOVATIVE APPLICATIONS OF ARTIFICIAL INTELLIGENCE CONFERENCE / EIGHTH AAAI SYMPOSIUM ON EDUCATIONAL ADVANCES IN ARTIFICIAL INTELLIGENCE, 2018, : 7550 - 7557
  • [39] Facile synthesis of high-performance nonfullerene acceptor isomers via a one stone two birds strategy
    Li, Tengfei
    Yang, Langxuan
    Xiao, Yiqun
    Liu, Kuan
    Wang, Jiayu
    Lu, Xinhui
    Zhan, Xiaowei
    JOURNAL OF MATERIALS CHEMISTRY A, 2019, 7 (36) : 20667 - 20674
  • [40] Two Birds With One Stone: An Efficient Hierarchical Framework for Top-k and Threshold-based String Similarity Search
    Wang, Jin
    Li, Guoliang
    Deng, Dong
    Zhang, Yong
    Feng, Jianhua
    2015 IEEE 31ST INTERNATIONAL CONFERENCE ON DATA ENGINEERING (ICDE), 2015, : 519 - 530