Lune

ICSE2023顶会

SkCoder: A Sketch-based Approach for Automatic Code Generation

Jia Li, Yongmin Li, Ge Li, Zhi Jin, Yiyang Hao, Xing Hu

摘要

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 -CodeT5base 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.

问 Lune

几分钟读透这篇 Paper,不用再花一下午。

Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。

已有 23 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。

可以从这些问题问起

Lune 可以查阅

全文 · 引用它的顶会 Paper · 相关的 Paper

获取答案

免费开始,无需绑卡

脉络

  • CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation 引用了 CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • CodeGen4Libs: A Two-Stage Approach for Library-Oriented Code Generation 引用了 CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation
  • CodeGen4Libs: A Two-Stage Approach for Library-Oriented Code Generation 引用了 CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • CodeGen4Libs: A Two-Stage Approach for Library-Oriented Code Generation 引用了 ReACC: A Retrieval-Augmented Code Completion Framework
  • ReACC: A Retrieval-Augmented Code Completion Framework 引用了 CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation
  • ReACC: A Retrieval-Augmented Code Completion Framework 引用了 CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • ReACC: A Retrieval-Augmented Code Completion Framework 引用了 GraphCodeBERT: Pre-training Code Representations with Data Flow
  • ReACC: A Retrieval-Augmented Code Completion Framework 引用了 Language Models are Few-Shot Learners
  • Self-Edit: Fault-Aware Code Editor for Code Generation 引用了 Language Models are Few-Shot Learners
  • Out of Sight, Out of Mind: Better Automatic Vulnerability Repair by Broadening Input Ranges and Sources 引用了 CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation
  • Out of Sight, Out of Mind: Better Automatic Vulnerability Repair by Broadening Input Ranges and Sources 引用了 CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • Out of Sight, Out of Mind: Better Automatic Vulnerability Repair by Broadening Input Ranges and Sources 引用了 GraphCodeBERT: Pre-training Code Representations with Data Flow
  • Out of Sight, Out of Mind: Better Automatic Vulnerability Repair by Broadening Input Ranges and Sources 引用了 Language Models are Few-Shot Learners
它引用的引用它的从左到右按年份排列,引用越多,位置越高。

引用它的顶会 Paper23

  1. Exploring and Unleashing the Power of Large Language Models in Automated Code TranslationZhen Yang, Fang Liu, Zhongxing Yu, Jacky Wai Keung 等FSE 2024 · 72 次引用
  2. Hot or Cold? Adaptive Temperature Sampling for Code Generation with Large Language ModelsYuqi Zhu, Jia Li, Ge Li, Yunfei Zhao 等AAAI 2024 · 68 次引用
  3. Self-Edit: Fault-Aware Code Editor for Code GenerationKechi Zhang, Zhuo Li, Jia Li, Ge Li 等ACL 2023 · 42 次引用
  4. Out of Sight, Out of Mind: Better Automatic Vulnerability Repair by Broadening Input Ranges and SourcesXin Zhou, Kisub Kim, Bowen Xu, DongGyun Han 等ICSE 2024 · 32 次引用
  5. CodeGen4Libs: A Two-Stage Approach for Library-Oriented Code GenerationMingwei Liu, Tianyong Yang, Yiling Lou, Xueying Du 等ASE 2023 · 31 次引用

它引用的 Paper9

  1. Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah 等NeurIPS 2020 · 64,255 次引用
  2. CodeBERT: A Pre-Trained Model for Programming and Natural LanguagesZhangyin Feng, Daya Guo, Duyu Tang, Nan Duan 等EMNLP Findings 2020 · 2,828 次引用
  3. GraphCodeBERT: Pre-training Code Representations with Data FlowDaya Guo, Shuo Ren, Shuai Lu, Zhangyin Feng 等ICLR 2021 · 1,644 次引用
  4. CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and GenerationYue Wang, Weishi Wang, Shafiq R. Joty, Steven C. H. HoiEMNLP 2021 · 1,224 次引用
  5. ReACC: A Retrieval-Augmented Code Completion FrameworkShuai Lu, Nan Duan, Hojae Han, Daya Guo 等ACL 2022 · 208 次引用

相关 Paper

  1. Source Code Recommender Systems: The Practitioners' PerspectiveMatteo Ciniselli, Luca Pascarella, Emad Aghajani, Simone Scalabrino 等ICSE 2023 · 6 次引用
  2. Compilable Neural Code Generation with Compiler FeedbackXin Wang, Yasheng Wang, Yao Wan, Fei Mi 等ACL Findings 2022 · 46 次引用
  3. Retrieve and Refine: Exemplar-based Neural Comment GenerationBolin Wei, Yongmin Li, Ge Li, Xin Xia 等ASE 2020 · 68 次引用
  4. Improving Code Extraction from Coding Screencasts Using a Code-Aware Encoder-Decoder ModelAbdulkarim Malkadi, Ahmad Tayeb, Sonia HaiducASE 2023 · 5 次引用
  5. Code Search is All You Need? Improving Code Suggestions with Code SearchJunkai Chen, Xing Hu, Zhenhao Li, Cuiyun Gao 等ICSE 2024 · 31 次引用
黄昏的海面,两侧是细线勾勒的悬崖