Uncertainty-Guided Chain-of-Thought for Code Generation with LLMs
On the map: LLM reasoning → Reasoning for agents, planning and code
Abstract (arXiv)
Chain-of-Thought (CoT) reasoning has been demonstrated as an effective technique for improving the problem-solving capabilities of large language models (LLMs) in the context of code generation. However, existing CoT methods often exhibit a tendency toward "overthinking", where the LLM consistently applies reasoning strategies without adequately considering the task's underlying complexity. This results in the LLMs allocating excessive computational resources, in terms of tokens, to relatively simple tasks or problems where the correct answer is already evident. Additionally, this overthinking may lead LLMs down incorrect reasoning paths, resulting in incorrect code generation. In this paper, we introduce UnCertainty-Aware Chain-of-Thought (UnCert-CoT), an LLM-based approach designed to enhance code generation by incorporating an uncertainty-aware CoT reasoning mechanism, which focuses computational resources on targeting points where LLMs are more prone to error. We propose two confidence-based uncertainty measures: Entropy-based and Probability Differential-based methods. When uncertainty is high, UnCert-CoT activates CoT-decoding to generate multiple reasoning paths and selects the final code that exhibits the highest likelihood of correctness. In contrast, LLM directly generates the code when uncertainty is low. This uncertainty judgment mechanism allows LLMs to prioritize complex tasks and avoid unnecessary steps in simpler cases, thereby improving overall efficiency and accuracy in code generation. Our experimental results demonstrate that UnCert-CoT significantly enhances code generation accuracy on challenging benchmark MHPP(Mostly Hard Python Problems), it achieves improvements up to 6.1% on PassRate accuracy, particularly in situations where traditional LLMs are prone to errors.
Key facts. Cited by 32 papers in the map (data through 14 Oct 2026). Placed in Reasoning for agents, planning and code, one of 17 directions in LLM reasoning. Builds on 20 of its 26 references that are in the map. First posted on arXiv 19 Mar 2025.
Builds on
20 of 26 references.
Closest ancestors · 3
Same direction, newest first
- 2024Qwen2.5-Coder Technical Report18 Sep
- 2023Structured Chain-of-Thought Prompting for Code Generation11 May
- 2023Teaching Large Language Models to Self-Debug11 Apr
Other references · 17
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2022Large Language Models are Zero-Shot Reasonerscited by 4,374
- 2023Code Llama: Open Foundation Models for Codecited by 2,139
- 2022Challenging BIG-Bench Tasks and Whether Chain-of-Thought Can Solve Themcited by 1,807
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
- 2022Large Language Models Are Human-Level Prompt Engineerscited by 1,045
- 2024Do NOT Think That Much for 2+3=? On the Overthinking of o1-Like LLMscited by 570
- 2024Chain-of-Thought Reasoning Without Promptingcited by 210
- 2023Planning with Large Language Models for Code Generationcited by 182
- 2022Natural Language to Code Translation with Executioncited by 124
- 2022Repository-Level Prompt Generation for Large Language Models of Codecited by 106
- 2024Calibration and Correctness of Language Models for Codecited by 49
5 more
- 2024Teaching Code LLMs to Use Autocompletion Tools in Repository-Level Code Generationcited by 30
- 2024MHPP: Exploring the Capabilities and Limitations of Language Models Beyond Basic Code Generationcited by 26
- 2025Large Language Models for Code Generation: A Comprehensive Survey of Challenges, Techniques, Evaluation, and Applicationscited by 26
- 2023Guiding Language Models of Code with Global Context using Monitorscited by 20
- 2024Exploring Data-Efficient Adaptation of Large Language Models for Code Generationcited by 3
Built on by
Citing papers per year: 2025: 13; 2026: 19.
32 papers.
Sort:
By area:
- 2025TokUR: Token-Level Uncertainty Estimation for Large Language Model Reasoningcited by 24
- 2025Think Just Enough: Sequence-Level Entropy as a Confidence Signal for LLM Reasoningcited by 24
- 2026Uncertainty Quantification in LLM Agents: Foundations, Emerging Challenges, and Opportunitiescited by 20
- 2025Semantic Energy: Detecting LLM Hallucination Beyond Entropycited by 18
- 2025Temporalizing Confidence: Evaluation of Chain-of-Thought Reasoning with Signal Temporal Logiccited by 11
- 2025TreeDiff: AST-Guided Code Generation with Diffusion LLMscited by 11
- 2025Reasoning Efficiently Through Adaptive Chain-of-Thought Compression: A Self-Optimizing Frameworkcited by 6
- 2026From Reasoning Traces to Reusable Modules: Understanding Compositional Generalization in Language Model Reasoningcited by 5
- 2025Chain-of-Code Collapse: Reasoning Failures in LLMs via Adversarial Prompting in Code Generationcited by 4
- 2025Self-Reflective Generation at Test Timecited by 3
- 2026Lil: Less is Less When Applying Post-Training Sparse-Attention Algorithms in Long-Decode Stagecited by 3
- 2026Uncertainty Propagation in LLM-Based Systemscited by 3
20 more
- 2026Functional Entropy: Predicting Functional Correctness in LLM-Generated Code with Uncertainty Quantificationcited by 3
- 2025Fast, Slow, and Tool-augmented Thinking for LLMs: A Reviewcited by 2
- 2025Can Confidence Estimates Decide When Chain-of-Thought Is Necessary for LLMs?cited by 2
- 2025Reinforcement Learning-Guided Chain-of-Draft for Token-Efficient Code Generationcited by 1
- 2026Benchmarking Text-to-Python against Text-to-SQL: The Impact of Explicit Logic and Ambiguitycited by 1
- 2026Uncertainty and Fairness Awareness in LLM-Based Recommendation Systemscited by 1
- 2025Enhancing LLM Reasoning via Non-Human-Like Reasoning Path Preference Optimizationcited by 0
- 2025Lifecycle-Aware code generation: Leveraging Software Engineering Phases in LLMscited by 0
- 2026Synthesizing File-Level Data for Unit Test Generation with Chain-of-Thoughts via Self-Debuggingcited by 0
- 2026Structural Anchors and Reasoning Fragility:Understanding CoT Robustness in LLM4Codecited by 0
- 2026Improving LLM Code Generation via Requirement-Aware Curriculum Reinforcement Learningcited by 0
- 2026OracleTSC: Oracle-Informed Reward Hurdle and Uncertainty Regularization for Traffic Signal Controlcited by 0
- 2026ThinkBooster: A Unified Framework for Seamless Test-Time Scaling of LLM Reasoningcited by 0
- 2026Code-MUE: Measuring Code LLMs' Uncertainty through Execution-based Semantic Interaction Graphscited by 0
- 2026How Reasoning Shapes Social Bias in LLM-Generated Code?cited by 0
- 2026When Uncertainty Isn't Enough: An Empirical Study of Self-Correction in Code Generationcited by 0
- 2026GUT: Quantifying and Optimizing the Reasoning Uncertainty of LLMs via Graph Complexitycited by 0
- 2026Uncertainty Quantification for LLM Agents: A Taxonomy, an Evaluation Protocol, and an Empirical Studycited by 0
- 2026Visible Reasoning Is Not a Universal Optimizer: Persona- and Thinking-Dependent Effects in Analytics Code Generationcited by 0
- 2026The Optimal Decoder is Tilted Temperaturecited by 0
- 2026The Optimal Decoder is Tilted Temperature10 Oct 2026
- 2026Visible Reasoning Is Not a Universal Optimizer: Persona- and Thinking-Dependent Effects in Analytics Code Generation7 Oct 2026
- 2026Uncertainty Quantification for LLM Agents: A Taxonomy, an Evaluation Protocol, and an Empirical Study7 Sep 2026
- 2026GUT: Quantifying and Optimizing the Reasoning Uncertainty of LLMs via Graph Complexity4 Sep 2026
- 2026How Reasoning Shapes Social Bias in LLM-Generated Code?7 Aug 2026
- 2026When Uncertainty Isn't Enough: An Empirical Study of Self-Correction in Code Generation31 Jul 2026
- 2026Code-MUE: Measuring Code LLMs' Uncertainty through Execution-based Semantic Interaction Graphs14 Jul 2026
- 2026From Reasoning Traces to Reusable Modules: Understanding Compositional Generalization in Language Model Reasoning16 Jun 2026
- 2026ThinkBooster: A Unified Framework for Seamless Test-Time Scaling of LLM Reasoning5 Jun 2026
- 2026Functional Entropy: Predicting Functional Correctness in LLM-Generated Code with Uncertainty Quantification27 May 2026
- 2026OracleTSC: Oracle-Informed Reward Hurdle and Uncertainty Regularization for Traffic Signal Control8 May 2026
- 2026Improving LLM Code Generation via Requirement-Aware Curriculum Reinforcement Learning1 May 2026
20 more
- 2026Uncertainty Propagation in LLM-Based Systems26 Apr 2026
- 2026Structural Anchors and Reasoning Fragility:Understanding CoT Robustness in LLM4Code14 Apr 2026
- 2026Uncertainty Quantification in LLM Agents: Foundations, Emerging Challenges, and Opportunities4 Feb 2026
- 2026Synthesizing File-Level Data for Unit Test Generation with Chain-of-Thoughts via Self-Debugging3 Feb 2026
- 2026Uncertainty and Fairness Awareness in LLM-Based Recommendation Systems31 Jan 2026
- 2026Benchmarking Text-to-Python against Text-to-SQL: The Impact of Explicit Logic and Ambiguity22 Jan 2026
- 2026Lil: Less is Less When Applying Post-Training Sparse-Attention Algorithms in Long-Decode Stage6 Jan 2026
- 2025Lifecycle-Aware code generation: Leveraging Software Engineering Phases in LLMs28 Oct 2025
- 2025Can Confidence Estimates Decide When Chain-of-Thought Is Necessary for LLMs?23 Oct 2025
- 2025Enhancing LLM Reasoning via Non-Human-Like Reasoning Path Preference Optimization13 Oct 2025
- 2025Think Just Enough: Sequence-Level Entropy as a Confidence Signal for LLM Reasoning9 Oct 2025
- 2025Self-Reflective Generation at Test Time3 Oct 2025
- 2025Reinforcement Learning-Guided Chain-of-Draft for Token-Efficient Code Generation26 Sep 2025
- 2025Reasoning Efficiently Through Adaptive Chain-of-Thought Compression: A Self-Optimizing Framework17 Sep 2025
- 2025Semantic Energy: Detecting LLM Hallucination Beyond Entropy20 Aug 2025
- 2025Fast, Slow, and Tool-augmented Thinking for LLMs: A Review17 Aug 2025
- 2025TreeDiff: AST-Guided Code Generation with Diffusion LLMs2 Aug 2025
- 2025Temporalizing Confidence: Evaluation of Chain-of-Thought Reasoning with Signal Temporal Logic9 Jun 2025
- 2025Chain-of-Code Collapse: Reasoning Failures in LLMs via Adversarial Prompting in Code Generation8 Jun 2025
- 2025TokUR: Token-Level Uncertainty Estimation for Large Language Model Reasoning16 May 2025
- 2025TokUR: Token-Level Uncertainty Estimation for Large Language Model Reasoningcited by 24
- 2025Think Just Enough: Sequence-Level Entropy as a Confidence Signal for LLM Reasoningcited by 24
- 2025Temporalizing Confidence: Evaluation of Chain-of-Thought Reasoning with Signal Temporal Logiccited by 11
- 2025Reasoning Efficiently Through Adaptive Chain-of-Thought Compression: A Self-Optimizing Frameworkcited by 6
- 2026From Reasoning Traces to Reusable Modules: Understanding Compositional Generalization in Language Model Reasoningcited by 5
- 2025Chain-of-Code Collapse: Reasoning Failures in LLMs via Adversarial Prompting in Code Generationcited by 4
- 2025Self-Reflective Generation at Test Timecited by 3
- 2025Fast, Slow, and Tool-augmented Thinking for LLMs: A Reviewcited by 2
- 2025Can Confidence Estimates Decide When Chain-of-Thought Is Necessary for LLMs?cited by 2
- 2025Enhancing LLM Reasoning via Non-Human-Like Reasoning Path Preference Optimizationcited by 0
- 2026Synthesizing File-Level Data for Unit Test Generation with Chain-of-Thoughts via Self-Debuggingcited by 0
- 2026Structural Anchors and Reasoning Fragility:Understanding CoT Robustness in LLM4Codecited by 0
12 most cited of 16 All 16 (JSON)
- 2026Visible Reasoning Is Not a Universal Optimizer: Persona- and Thinking-Dependent Effects in Analytics Code Generation7 Oct 2026
- 2026GUT: Quantifying and Optimizing the Reasoning Uncertainty of LLMs via Graph Complexity4 Sep 2026
- 2026How Reasoning Shapes Social Bias in LLM-Generated Code?7 Aug 2026
- 2026From Reasoning Traces to Reusable Modules: Understanding Compositional Generalization in Language Model Reasoning16 Jun 2026
- 2026ThinkBooster: A Unified Framework for Seamless Test-Time Scaling of LLM Reasoning5 Jun 2026
- 2026Structural Anchors and Reasoning Fragility:Understanding CoT Robustness in LLM4Code14 Apr 2026
- 2026Synthesizing File-Level Data for Unit Test Generation with Chain-of-Thoughts via Self-Debugging3 Feb 2026
- 2025Can Confidence Estimates Decide When Chain-of-Thought Is Necessary for LLMs?23 Oct 2025
- 2025Enhancing LLM Reasoning via Non-Human-Like Reasoning Path Preference Optimization13 Oct 2025
- 2025Think Just Enough: Sequence-Level Entropy as a Confidence Signal for LLM Reasoning9 Oct 2025
- 2025Self-Reflective Generation at Test Time3 Oct 2025
- 2025Reasoning Efficiently Through Adaptive Chain-of-Thought Compression: A Self-Optimizing Framework17 Sep 2025
12 newest of 16 All 16 (JSON)
- 2025Semantic Energy: Detecting LLM Hallucination Beyond Entropycited by 18
- 2025TreeDiff: AST-Guided Code Generation with Diffusion LLMscited by 11
- 2026Lil: Less is Less When Applying Post-Training Sparse-Attention Algorithms in Long-Decode Stagecited by 3
- 2026Uncertainty Propagation in LLM-Based Systemscited by 3
- 2026Functional Entropy: Predicting Functional Correctness in LLM-Generated Code with Uncertainty Quantificationcited by 3
- 2025Reinforcement Learning-Guided Chain-of-Draft for Token-Efficient Code Generationcited by 1
- 2026Benchmarking Text-to-Python against Text-to-SQL: The Impact of Explicit Logic and Ambiguitycited by 1
- 2026Uncertainty and Fairness Awareness in LLM-Based Recommendation Systemscited by 1
- 2025Lifecycle-Aware code generation: Leveraging Software Engineering Phases in LLMscited by 0
- 2026Improving LLM Code Generation via Requirement-Aware Curriculum Reinforcement Learningcited by 0
- 2026OracleTSC: Oracle-Informed Reward Hurdle and Uncertainty Regularization for Traffic Signal Controlcited by 0
- 2026Code-MUE: Measuring Code LLMs' Uncertainty through Execution-based Semantic Interaction Graphscited by 0
12 most cited of 14 All 14 (JSON)
- 2026The Optimal Decoder is Tilted Temperature10 Oct 2026
- 2026When Uncertainty Isn't Enough: An Empirical Study of Self-Correction in Code Generation31 Jul 2026
- 2026Code-MUE: Measuring Code LLMs' Uncertainty through Execution-based Semantic Interaction Graphs14 Jul 2026
- 2026Functional Entropy: Predicting Functional Correctness in LLM-Generated Code with Uncertainty Quantification27 May 2026
- 2026OracleTSC: Oracle-Informed Reward Hurdle and Uncertainty Regularization for Traffic Signal Control8 May 2026
- 2026Improving LLM Code Generation via Requirement-Aware Curriculum Reinforcement Learning1 May 2026
- 2026Uncertainty Propagation in LLM-Based Systems26 Apr 2026
- 2026Uncertainty and Fairness Awareness in LLM-Based Recommendation Systems31 Jan 2026
- 2026Benchmarking Text-to-Python against Text-to-SQL: The Impact of Explicit Logic and Ambiguity22 Jan 2026
- 2026Lil: Less is Less When Applying Post-Training Sparse-Attention Algorithms in Long-Decode Stage6 Jan 2026
- 2025Lifecycle-Aware code generation: Leveraging Software Engineering Phases in LLMs28 Oct 2025
- 2025Reinforcement Learning-Guided Chain-of-Draft for Token-Efficient Code Generation26 Sep 2025
12 newest of 14 All 14 (JSON)
Similar, not cited
Close in wording, no citation either way
- 2023Chain-of-Thought in Neural Code Generation: From and For Lightweight Language Models
- 2025Code Execution as Grounded Supervision for LLM Reasoning
- 2025Scaling Code-Assisted Chain-of-Thoughts and Instructions for Model Reasoning
- 2025Understanding Chain-of-Thought Effectiveness in Code Generation: An Empirical and Information-Theoretic Analysis
- 2024Understanding Chain-of-Thought in LLMs through Information Theory
- 2025CoT-UQ: Improving Response-wise Uncertainty Quantification in LLMs with Chain-of-Thought
- 2025SEER: Enhancing Chain-of-Thought Code Generation through Self-Exploring Deep Reasoning
- 2026Hierarchical Chain-of-Thought: Enhancing LLM Reasoning Performance and Efficiency