CodeCoT: Tackling Code Syntax Errors in CoT Reasoning for Code Generation
Dong Huang, Qingwen Bu, Yuhao Qing, Heming Cui

TL;DR
CodeCoT enhances code generation by integrating chain-of-thought reasoning with self-examination and iterative refinement, significantly reducing syntax errors and improving execution success rates.
Contribution
This paper introduces CodeCoT, a novel method combining CoT reasoning with self-examination and test-based refinement to address syntax errors in code generation.
Findings
Increases pass@1 from 75.6% to 79.3% on HumanEval
Effectively reduces syntax errors during code execution
Demonstrates improved code correctness and reliability
Abstract
Chain-of-thought (CoT) has emerged as a groundbreaking tool in NLP, notably for its efficacy in complex reasoning tasks, such as mathematical proofs. However, its application in code generation faces a distinct challenge, i.e., although the code generated with CoT reasoning is logically correct, it faces the problem of syntax error (e.g., invalid syntax error report) during code execution, which causes the CoT result's pass@1 in HumanEval even lower than the zero-shot result. In this paper, we present Code Chain-of-Thought (CodeCoT) that integrates CoT with a self-examination process for code generation. CodeCoT begins with the LLMs using CoT for initial code development to ensure the generated code follows the correct logic flow. Then, CodeCoT will generate test cases to validate whether the code has syntax errors during the execution. CodeCoT then employs a self-examination phase,…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsExperimental Learning in Engineering
