SEER: Enhancing Chain-of-Thought Code Generation through Self-Exploring Deep Reasoning
Preprint
Abstract
Code generation, the task of creating executable programs from natural language requirements, has recently seen tremendous advances through Chain-of-Thought (CoT) reasoning, which enables Large Language Models (LLMs) to develop high-level reasoning plans before writing code. Recent research has proposed various methods to enhance models' CoT reasoning for code generation such as prompt engineering and supervised fine-tuning. However, existing approaches still face three critical limitations: (1) limited exploration of diverse reasoning paths, which constrains generalization across various programming scenarios, (2) lack of quality assessment for intermediate reasoning steps, which hampers the reliability of the generated plans and code, and (3) the potential negative impact of "overthinking", potentially leading to unnecessarily complex and incorrect solutions. To address these limitations, we frame CoT code generation as a decision making problem and present SEER, a SElf-Exploring deep Reasoning framework that enables accurate and adaptive reasoning for code generation. SEER introduces three key components: (1) Diverse reasoning path exploration, which aims at exploring diverse reasoning paths and annotating intermediate steps without relying on manual experts or closed-source proprietary models; (2) Reasoning quality-aware model training, which trains a policy model for generating candidate reasoning steps and a value model for assessing their quality; and (3) Adaptive CoT reasoning, which dynamically switches between direct generation and step-by-step reasoning for different problems.Keywords
All Related Versions
This publication has 15 references indexed in Scilit:
- Vul-R2: A Reasoning LLM for Automated Vulnerability Repair2025
- LLM Hallucinations in Practical Code Generation: Phenomena, Mechanism, and MitigationProceedings of the ACM on Software Engineering, 2025
- Structured Chain-of-Thought Prompting for Code GenerationACM Transactions on Software Engineering and Methodology, 2025
- Self-Planning Code Generation with Large Language ModelsACM Transactions on Software Engineering and Methodology, 2024
- Self-Collaboration Code Generation via ChatGPTACM Transactions on Software Engineering and Methodology, 2024
- Chain-of-Thought in Neural Code Generation: From and for Lightweight Language ModelsIEEE Transactions on Software Engineering, 2024
- MultiPL-E: A Scalable and Polyglot Approach to Benchmarking Neural Code GenerationIEEE Transactions on Software Engineering, 2023
- Code Structure–Guided Transformer for Source Code SummarizationACM Transactions on Software Engineering and Methodology, 2023
- Mastering the game of Go without human knowledgeNature, 2017
- Catastrophic Interference in Connectionist Networks: The Sequential Learning Problem1989