Structured Chain-of-Thought Prompting for Code Generation

计算机科学 链条(单位) 编码(集合论) 软件工程 程序设计语言 物理 集合(抽象数据类型) 天文
作者
Jia Li,Ge Li,Yongmin Li,Zhi Jin
出处
期刊:ACM Transactions on Software Engineering and Methodology [Association for Computing Machinery]
被引量:15
标识
DOI:10.1145/3690635
摘要

Large Language Models (LLMs) have shown impressive abilities in code generation. Chain-of-Thought (CoT) prompting is the state-of-the-art approach to utilizing LLMs. CoT prompting asks LLMs first to generate CoTs ( i.e., intermediate natural language reasoning steps) and then output the code. However, the accuracy of CoT prompting still can not satisfy practical applications. For example, gpt-3.5-turbo with CoT prompting only achieves 53.29% Pass@1 in HumanEval. In this paper, we propose Structured CoTs (SCoTs) and present a novel prompting technique for code generation named SCoT prompting. Our motivation is that human developers follow structured programming. Developers use three programming structures ( i.e., sequential, branch, and loop) to design and implement structured programs. Thus, we ask LLMs to use three programming structures to generate SCoTs (structured reasoning steps) before outputting the final code. Compared to CoT prompting, SCoT prompting explicitly introduces programming structures and unlocks the structured programming thinking of LLMs. We apply SCoT prompting to two LLMs ( i.e., gpt-4-turbo, gpt-3.5-turbo, and DeepSeek Coder-Instruct-{1.3B, 6.7B, 33B}) and evaluate it on three benchmarks ( i.e., HumanEval, MBPP, and MBCPP). SCoT prompting outperforms CoT prompting by up to 13.79% in Pass@1. SCoT prompting is robust to examples and achieves substantial improvements. The human evaluation also shows human developers prefer programs from SCoT prompting.

科研通智能强力驱动
Strongly Powered by AbleSci AI
科研通是完全免费的文献互助平台,具备全网最快的应助速度,最高的求助完成率。 对每一个文献求助,科研通都将尽心尽力,给求助人一个满意的交代。
实时播报
yjy完成签到 ,获得积分10
刚刚
务实的绝悟完成签到,获得积分10
1秒前
海边听海完成签到 ,获得积分10
2秒前
2秒前
大吴克发布了新的文献求助10
4秒前
Glitter完成签到 ,获得积分10
6秒前
每天完成签到 ,获得积分10
6秒前
小井盖完成签到 ,获得积分10
6秒前
gqb完成签到,获得积分10
7秒前
书是人类进步的阶梯完成签到 ,获得积分10
7秒前
8秒前
家向松完成签到,获得积分10
9秒前
Aurora完成签到,获得积分10
10秒前
Jj完成签到,获得积分10
10秒前
任性的半凡完成签到,获得积分10
10秒前
跳跳虎完成签到 ,获得积分10
14秒前
大吴克发布了新的文献求助10
14秒前
饱满若灵发布了新的文献求助10
15秒前
15秒前
16秒前
16秒前
16秒前
好好学习完成签到,获得积分10
16秒前
有有完成签到 ,获得积分10
17秒前
天上掉下篇NCS完成签到,获得积分10
18秒前
冷静曲奇完成签到 ,获得积分10
21秒前
xwx发布了新的文献求助10
21秒前
21秒前
清玄一叶发布了新的文献求助10
21秒前
ZZWSWJ发布了新的文献求助10
22秒前
everyone_woo完成签到,获得积分10
25秒前
wangxuan完成签到,获得积分10
26秒前
饱满若灵完成签到,获得积分10
29秒前
岩中花树完成签到,获得积分20
29秒前
29秒前
大吴克发布了新的文献求助10
30秒前
ZZWSWJ完成签到,获得积分10
31秒前
32秒前
xiaoguang li完成签到,获得积分10
33秒前
打打应助xwx采纳,获得10
33秒前
高分求助中
Continuum Thermodynamics and Material Modelling 3000
Production Logging: Theoretical and Interpretive Elements 2700
Les Mantodea de Guyane Insecta, Polyneoptera 1000
Structural Load Modelling and Combination for Performance and Safety Evaluation 1000
Conference Record, IAS Annual Meeting 1977 820
電気学会論文誌D(産業応用部門誌), 141 巻, 11 号 510
Typology of Conditional Constructions 500
热门求助领域 (近24小时)
化学 材料科学 生物 医学 工程类 有机化学 生物化学 物理 纳米技术 计算机科学 内科学 化学工程 复合材料 基因 遗传学 物理化学 催化作用 量子力学 光电子学 冶金
热门帖子
关注 科研通微信公众号,转发送积分 3571404
求助须知:如何正确求助?哪些是违规求助? 3141954
关于积分的说明 9445076
捐赠科研通 2843424
什么是DOI,文献DOI怎么找? 1562840
邀请新用户注册赠送积分活动 731366
科研通“疑难数据库(出版商)”最低求助积分说明 718524