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 条
  • [41] 3D Shape Generation via Variational Autoencoder with Signed Distance Function Relativistic Average Generative Adversarial Network
    Ajayi, Ebenezer Akinyemi
    Lim, Kian Ming
    Chong, Siew-Chin
    Lee, Chin Poo
    APPLIED SCIENCES-BASEL, 2023, 13 (10):
  • [42] REMOTE SENSING IMAGE SPATIO-TEMPORAL FUSION VIA A GENERATIVE ADVERSARIAL NETWORK THROUGH ONE PRIOR IMAGE PAIR
    Song, Yiyao
    Zhang, Hongyan
    Zhang, Liangpei
    IGARSS 2020 - 2020 IEEE INTERNATIONAL GEOSCIENCE AND REMOTE SENSING SYMPOSIUM, 2020, : 7009 - 7012
  • [43] Kill Two Birds With One Stone: A Multi-View Multi-Adversarial Learning Approach for Joint Air Quality and Weather Prediction
    Han, Jindong
    Liu, Hao
    Zhu, Hengshu
    Xiong, Hui
    IEEE TRANSACTIONS ON KNOWLEDGE AND DATA ENGINEERING, 2023, 35 (11) : 11515 - 11528
  • [44] Two birds with one stone: natural polyphenols boosted periodontitis treatment of chlorhexidine via reducing toxicity and regulating microenvironments
    Sun, Zhiyuan
    Wang, Tianyou
    Chen, Enni
    Xu, Lingyi
    Ding, Yi
    Gu, Zhipeng
    Xiao, Shimeng
    MATERIALS HORIZONS, 2025, 12 (02) : 608 - 622
  • [45] Two birds with one stone: natural polyphenols boosted periodontitis treatment of chlorhexidine via reducing toxicity and regulating microenvironments
    Sun, Zhiyuan
    Wang, Tianyou
    Chen, Enni
    Xu, Lingyi
    Ding, Yi
    Gu, Zhipeng
    Xiao, Shimeng
    Materials Horizons, 2024, 12 (02) : 608 - 622
  • [46] Prompt Image Search with Deep Convolutional Neural Network via Efficient Hashing Code and Addictive Latent Semantic Layer
    Li, Jun-yi
    Li, Jian-hua
    JOURNAL OF INTERNET TECHNOLOGY, 2018, 19 (03): : 949 - 957
  • [47] Kill two birds with one stone: To reduce toxicity and enhance photodegradation of antibiotics by lead cesium bromide via tin doping
    Gao, Jingyang
    Wu, Jianhao
    Liu, Chunxi
    Chen, Zhi
    Li, Lan
    Hu, Jinglei
    Li, Chunyan
    Liu, Yurong
    Wang, Xu-Sheng
    Wang, Wen
    JOURNAL OF CLEANER PRODUCTION, 2024, 441
  • [48] Two Birds With One Stone: A Unified Approach to Saliency and Co-Saliency Detection via Multi-Instance Learning
    Quan, Honglin
    Feng, Songhe
    Chen, Baifan
    IEEE ACCESS, 2017, 5 : 23519 - 23531
  • [49] Two-tier coordinated optimal scheduling of wind/PV/hydropower and storage systems based on generative adversarial network scene generation
    Cai, Changchun
    Li, Yuanjia
    He, Yaoyao
    Guo, Lei
    FRONTIERS IN ENERGY RESEARCH, 2023, 11
  • [50] One stone two birds: cobalt-catalyzed in situ generation of isocyanates and benzyl alcohols for the synthesis of N-aryl carbamates
    Li, Sida
    Khan, Ruhima
    Zhang, Xia
    Yang, Yong
    Wang, Zheting
    Zhan, Yong
    Dai, Yuze
    Liu, Yue-e
    Fan, Baomin
    ORGANIC & BIOMOLECULAR CHEMISTRY, 2019, 17 (24) : 5891 - 5896