SKCODER: A Sketch-based Approach for Automatic Code Generation

被引:9
|
作者
Li, Jia [1 ]
Li, Yongmin [1 ]
Li, Ge [1 ]
Jin, Zhi [1 ]
Hao, Yiyang [2 ]
Hu, Xing [3 ]
机构
[1] Peking Univ, MoE, Key Lab High Confidence Software Technol, Beijing, Peoples R China
[2] aiXcoder, Beijing, Peoples R China
[3] Zhejiang Univ, Ningbo, Peoples R China
基金
中国国家自然科学基金;
关键词
Code Generation; Deep Learning;
D O I
10.1109/ICSE48619.2023.00179
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Recently, deep learning techniques have shown great success in automatic code generation. Inspired by the code reuse, some researchers propose copy-based approaches that can copy the content from similar code snippets to obtain better performance. Practically, human developers recognize the content in the similar code that is relevant to their needs, which can be viewed as a code sketch. The sketch is further edited to the desired code. However, existing copy-based approaches ignore the code sketches and tend to repeat the similar code without necessary modifications, which leads to generating wrong results. In this paper, we propose a sketch-based code generation approach named SKCODER to mimic developers' code reuse behavior. Given a natural language requirement, SKCODER retrieves a similar code snippet, extracts relevant parts as a code sketch, and edits the sketch into the desired code. Our motivations are that the extracted sketch provides a well-formed pattern for telling models "how to write". The post-editing further adds requirement-specific details into the sketch and outputs the complete code. We conduct experiments on two public datasets and a new dataset collected by this work. We compare our approach to 20 baselines using 5 widely used metrics. Experimental results show that (1) SKCODER can generate more correct programs, and outperforms the state-of-the-art - CodeT5-base by 30.30%, 35.39%, and 29.62% on three datasets. (2) Our approach is effective to multiple code generation models and improves them by up to 120.1% in Pass@1. (3) We investigate three plausible code sketches and discuss the importance of sketches. (4) We manually evaluate the generated code and prove the superiority of our SKCODER in three aspects.
引用
收藏
页码:2124 / 2135
页数:12
相关论文
共 50 条
  • [1] Automatic colorization for Thangka sketch-based paintings
    Wang, Fubo
    Geng, Shengling
    Zhang, Dan
    Zhou, Mingquan
    [J]. VISUAL COMPUTER, 2024, 40 (02): : 761 - 779
  • [2] Automatic colorization for Thangka sketch-based paintings
    Fubo Wang
    Shengling Geng
    Dan Zhang
    Mingquan Zhou
    [J]. The Visual Computer, 2024, 40 (2) : 761 - 779
  • [3] Sketch-a-Classifier: Sketch-based Photo Classifier Generation
    Hu, Conghui
    Li, Da
    Song, Yi-Zhe
    Xiang, Tao
    Hospedales, Timothy M.
    [J]. 2018 IEEE/CVF CONFERENCE ON COMPUTER VISION AND PATTERN RECOGNITION (CVPR), 2018, : 9136 - 9144
  • [4] Sketch-a-Segmenter: Sketch-Based Photo Segmenter Generation
    Hu, Conghui
    Li, Da
    Yang, Yongxin
    Hospedales, Timothy M.
    Song, Yi-Zhe
    [J]. IEEE TRANSACTIONS ON IMAGE PROCESSING, 2020, 29 : 9470 - 9481
  • [5] Sketch-Based Generation and Editing of Quad Meshes
    Takayama, Kenshi
    Panozzo, Daniele
    Sorkine-Hornung, Alexander
    Sorkine-Hornung, Olga
    [J]. ACM TRANSACTIONS ON GRAPHICS, 2013, 32 (04):
  • [6] Sketch-based compatible clothing image generation
    Cao, Xiao-Lu
    Lu, Fu-Nan
    Zhu, Xiang
    Weng, Li-Bo
    Lu, Shu-Fang
    Gao, Fei
    [J]. Zhejiang Daxue Xuebao (Gongxue Ban)/Journal of Zhejiang University (Engineering Science), 2023, 57 (05): : 939 - 947
  • [7] A sketch-based approach to human body modelling
    Mao, Chen
    Qjn, Sheng Feng
    Wright, David
    [J]. COMPUTERS & GRAPHICS-UK, 2009, 33 (04): : 521 - 541
  • [8] A Novel Recognition Approach for Sketch-Based Interfaces
    Avola, Danilo
    Del Buono, Andrea
    Gianforme, Giorgio
    Paolozzi, Stefano
    [J]. IMAGE ANALYSIS AND PROCESSING - ICIAP 2009, PROCEEDINGS, 2009, 5716 : 1015 - +
  • [9] Conversational Image Search: A Sketch-based Approach
    Braghis, Daniel D.
    Liu, Haiming
    [J]. PROCEEDINGS OF THE 4TH ANNUAL ACM INTERNATIONAL CONFERENCE ON MULTIMEDIA RETRIEVAL, ICMR 2024, 2024, : 1265 - 1269
  • [10] Sketch-based stroke generation in Chinese flower painting
    Yang, Lijie
    Xu, Tianchen
    Du, Jixiang
    Wu, Enhua
    [J]. SCIENCE CHINA-INFORMATION SCIENCES, 2016, 59 (07)