SkCoder: A Sketch-based Approach for Automatic Code Generation

素描 计算机科学 编码(集合论) 代码段 代码生成 源代码 代码重用 重新使用 草图识别 人工智能 冗余代码 程序设计语言 情报检索 自然语言处理 钥匙(锁) 算法 软件 手势识别 集合(抽象数据类型) 生物 手势 计算机安全 生态学
作者
Jia Li,Yongmin Li,Ge Li,Zhi Jin,Yiyang Hao,Xing Hu
标识
DOI:10.1109/icse48619.2023.00179
摘要

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 Skcoderto mimic developers' code reuse behavior. Given a natural language requirement, Skcoderretrieves 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) Skcodercan 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@l. (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 Skcoderin three aspects.

科研通智能强力驱动
Strongly Powered by AbleSci AI
科研通是完全免费的文献互助平台,具备全网最快的应助速度,最高的求助完成率。 对每一个文献求助,科研通都将尽心尽力,给求助人一个满意的交代。
实时播报
沙xiaohan发布了新的文献求助10
刚刚
1秒前
ZAO完成签到,获得积分10
2秒前
endmarki应助Gergeo采纳,获得50
2秒前
3秒前
小蘑菇应助su采纳,获得30
3秒前
Orange应助Wenpandaen采纳,获得10
3秒前
JMao完成签到,获得积分10
3秒前
3秒前
天天快乐应助天天采纳,获得10
3秒前
Ava应助聪明摩托采纳,获得10
3秒前
小单王发布了新的文献求助10
3秒前
4秒前
司马惜儿发布了新的文献求助10
4秒前
4秒前
xxkim721发布了新的文献求助10
5秒前
ZAO发布了新的文献求助10
6秒前
6秒前
海涛完成签到,获得积分10
7秒前
呆萌的觅松完成签到,获得积分10
7秒前
7秒前
9秒前
9秒前
韩soso发布了新的文献求助10
10秒前
科研通AI5应助热心冷亦采纳,获得10
10秒前
莫默完成签到,获得积分10
10秒前
10秒前
浮生如梦完成签到,获得积分10
10秒前
10秒前
11秒前
苗条的傲丝完成签到,获得积分10
12秒前
12秒前
12秒前
Hello应助桃子采纳,获得10
12秒前
13秒前
14秒前
含糊的小松鼠完成签到 ,获得积分10
14秒前
14秒前
禹卓发布了新的文献求助10
15秒前
15秒前
高分求助中
Continuum Thermodynamics and Material Modelling 3000
Production Logging: Theoretical and Interpretive Elements 2700
Mechanistic Modeling of Gas-Liquid Two-Phase Flow in Pipes 2500
Structural Load Modelling and Combination for Performance and Safety Evaluation 1000
Conference Record, IAS Annual Meeting 1977 710
電気学会論文誌D(産業応用部門誌), 141 巻, 11 号 510
Virulence Mechanisms of Plant-Pathogenic Bacteria 500
热门求助领域 (近24小时)
化学 材料科学 生物 医学 工程类 有机化学 生物化学 物理 纳米技术 计算机科学 内科学 化学工程 复合材料 基因 遗传学 物理化学 催化作用 量子力学 光电子学 冶金
热门帖子
关注 科研通微信公众号,转发送积分 3564065
求助须知:如何正确求助?哪些是违规求助? 3137276
关于积分的说明 9421653
捐赠科研通 2837658
什么是DOI,文献DOI怎么找? 1559942
邀请新用户注册赠送积分活动 729224
科研通“疑难数据库(出版商)”最低求助积分说明 717215