paper-with-me

홈 › Papers

Structured Chain-of-Thought Prompting for Code Generation

2023-05-11 · Jia Li, Ge Li, Yongmin Li, Zhi Jin

Large Language Models (LLMs) (e.g., ChatGPT) have shown impressive performance in code generation. LLMs take prompts as inputs, and Chain-of-Thought (CoT) prompting is the state-of-the-art prompting technique. CoT prompting asks LLMs first to generate CoTs (i.e., intermediate natural language reasoning steps) and then output the code. However, CoT prompting is designed for natural language generation and has low accuracy in code generation. In this paper, we propose Structured CoTs (SCoTs) and present a novel prompting technique for code generation, named SCoT prompting. Our motivation is source code contains rich structural information and any code can be composed of three program structures (i.e., sequence, branch, and loop structures). Intuitively, structured intermediate reasoning steps make for structured source code. Thus, we ask LLMs to use program structures to build CoTs, obtaining SCoTs. Then, LLMs generate the final code based on SCoTs. Compared to CoT prompting, SCoT prompting explicitly constrains LLMs to think about how to solve requirements from the view of source code and further the performance of LLMs in code generation. We apply SCoT prompting to two LLMs (i.e., ChatGPT and Codex) and evaluate it on three benchmarks (i.e., HumanEval, MBPP, and MBCPP). (1) SCoT prompting outperforms the state-of-the-art baseline - CoT prompting by up to 13.79% in Pass@1. (2) Human evaluation shows human developers prefer programs from SCoT prompting. (3) SCoT prompting is robust to examples and achieves substantial improvements.

📄 PDF Abstract BibTeX arXiv:2305.06599

Code (0)

등록된 구현이 없습니다.

Tasks

Code GenerationHumanEvalmbppText Generation

Methods 이 논문이 사용한 방법론

CoT Prompting Chain-of-thought prompts contain a series of intermediate reasoning steps, and they are shown to significantly improve the ability of large language models to perform certain…

Similar Papers 제목 키워드 기반

Understanding Defects in Generated Codes by Language Models

2024-08-23 · Ali Mohammadi Esfahani, Nafiseh Kahani, Samuel A. Ajila

This study investigates the reliability of code generation by Large Language Models (LLMs), focusing on identifying and analyzing defects in the generated code. Despite the advanced capabilities of LLMs in automating cod…

Code GenerationPrompt Engineering

Intention Chain-of-Thought Prompting with Dynamic Routing for Code Generation

2025-12-16 · Shen Li, Li Huang, Shaoxiong Zhan, Weifeng Sun 외 arxiv

Large language models (LLMs) exhibit strong generative capabilities and have shown great potential in code generation. Existing chain-of-thought (CoT) prompting methods enhance model reasoning by eliciting intermediate s…

Code Generation

Assessing GPT4-V on Structured Reasoning Tasks

2023-12-13 · Mukul Singh, José Cambronero, Sumit Gulwani, Vu Le 외

Multi-modality promises to unlock further uses for large language models. Recently, the state-of-the-art language model GPT-4 was enhanced with vision capabilities. We carry out a prompting evaluation of GPT-4V and five …

Code GenerationLanguage ModelingLanguage ModellingMathematical Reasoning+1

Structured Chain-of-Thought Prompting for Few-Shot Generation of Content-Grounded QA Conversations

2024-02-19 · Md Arafat Sultan, Jatin Ganhotra, Ramón Fernandez Astudillo

We introduce a structured chain-of-thought (SCoT) prompting approach to generating content-grounded multi-turn question-answer conversations using a pre-trained large language model (LLM). At the core of our proposal is …

HallucinationLanguage ModelingLanguage ModellingLarge Language Model

Evaluating Prompting Strategies for Chart Question Answering with Large Language Models

2026-03-03 · Ruthuparna Naikar, Ying Zhu arxiv

Prompting strategies affect LLM reasoning performance, but their role in chart-based QA remains underexplored. We present a systematic evaluation of four widely used prompting paradigms (Zero-Shot, Few-Shot, Zero-Shot Ch…

Chart Question Answering