LeDex: Training LLMs to Better Self-Debug and Explain Code
Not on the map. Why?
Abstract (arXiv)
In the domain of code generation, self-debugging is crucial. It allows LLMs to refine their generated code based on execution feedback. This is particularly important because generating correct solutions in one attempt proves challenging for complex tasks. Prior works on self-debugging mostly focus on prompting methods by providing LLMs with few-shot examples, which work poorly on small open-sourced LLMs. In this work, we propose LeDex, a training framework that significantly improves the self-debugging capability of LLMs. Intuitively, we observe that a chain of explanations on the wrong code followed by code refinement helps LLMs better analyze the wrong code and do refinement. We thus propose an automated pipeline to collect a high-quality dataset for code explanation and refinement by generating a number of explanations and refinement trajectories from the LLM itself or a larger teacher model and filtering via execution verification. We perform supervised fine-tuning (SFT) and further reinforcement learning (RL) on both success and failure trajectories with a novel reward design considering code explanation and refinement quality. SFT improves the pass@1 by up to 15.92% and pass@10 by 9.30% over four benchmarks. RL training brings additional up to 3.54% improvement on pass@1 and 2.55% improvement on pass@10. The trained LLMs show iterative refinement ability and can keep refining code continuously. Lastly, our human evaluation shows that the LLMs trained with our framework generate more useful code explanations and help developers better understand bugs in source code.
Key facts. Cited by 40 papers in the map (data through 14 Oct 2026). Builds on 28 of its 42 references that are in the map. First posted on arXiv 28 May 2024.
Builds on
28 of 42 references.
References · 28
- 2017Proximal Policy Optimization Algorithmscited by 15,215
- 2023Judging LLM-as-a-Judge with MT-Bench and Chatbot Arenacited by 8,626
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2023Direct Preference Optimization: Your Language Model is Secretly a Reward Modelcited by 8,065
- 2021Program Synthesis with Large Language Modelscited by 3,637
- 2022Competition-Level Code Generation with AlphaCodecited by 1,462
- 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,391
- 2023Teaching Large Language Models to Self-Debugcited by 988
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 906
- 2021Measuring Coding Challenge Competence With APPScited by 902
- 2020Making Monolingual Sentence Embeddings Multilingual using Knowledge Distillationcited by 593
- 2022CodeRL: Mastering Code Generation through Pretrained Models and Deep Reinforcement Learningcited by 358
16 more
- 2023CodeT5+: Open Code Large Language Models for Code Understanding and Generationcited by 333
- 2024OpenCodeInterpreter: Integrating Code Generation with Execution and Refinementcited by 247
- 2022Practical Program Repair in the Era of Large Pre-trained Language Modelscited by 133
- 2023CodeGen2: Lessons for Training LLMs on Programming and Natural Languagescited by 125
- 2022Large Language Models are Few-shot Testers: Exploring LLM-based General Bug Reproductioncited by 111
- 2023Self-Edit: Fault-Aware Code Editor for Code Generationcited by 111
- 2022Large Language Models are Zero-Shot Fuzzers: Fuzzing Deep-Learning Libraries via Large Language Modelscited by 103
- 2023Execution-based Code Generation using Deep Reinforcement Learningcited by 99
- 2023Impact of Code Language Models on Automated Program Repaircited by 85
- 2023Improving Code Generation by Training with Natural Language Feedbackcited by 76
- 2023How Effective Are Neural Networks for Fixing Security Vulnerabilitiescited by 52
- 2022Training Language Models with Language Feedbackcited by 49
- 2024CYCLE: Learning to Self-Refine the Code Generationcited by 42
- 2024A Deep Dive into Large Language Models for Automated Bug Localization and Repaircited by 39
- 2024TOGLL: Correct and Strong Test Oracle Generation with LLMscited by 24
- 2024Leveraging Print Debugging to Improve Code Generation in Large Language Modelscited by 15
Built on by
Citing papers per year: 2024: 6; 2025: 19; 2026: 15.
40 papers.
Sort:
By area:
- 2024Enhancing Code LLMs with Reinforcement Learning in Code Generation: A Surveycited by 83
- 2026Hierarchy-of-Groups Policy Optimization for Long-Horizon Agentic Taskscited by 49
- 2024From Code to Correctness: Closing the Last Mile of Code Generation with Hierarchical Debuggingcited by 46
- 2025Vibe Coding vs. Agentic Coding: Fundamentals and Practical Implications of Agentic AIcited by 42
- 2025Internet of Agents: Fundamentals, Applications, and Challengescited by 31
- 2025AlgoTune: Can Language Models Speed Up General-Purpose Numerical Programs?cited by 27
- 2025Advancing Tool-Augmented Large Language Models via Meta-Verification and Reflection Learningcited by 24
- 2025Revisit Self-Debugging with Self-Generated Tests for Code Generationcited by 22
- 2024An LLM Agent for Automatic Geospatial Data Analysiscited by 21
- 2025VisCoder: Fine-Tuning LLMs for Executable Python Visualization Code Generationcited by 17
- 2025R4ec: A Reasoning, Reflection, and Refinement Framework for Recommendation Systemscited by 16
- 2025RefineBench: Evaluating Refinement Capability of Language Models via Checklistscited by 15
28 more
- 2025RepoST: Scalable Repository-Level Coding Environment Construction with Sandbox Testingcited by 13
- 2024Multi-Programming Language Sandbox for LLMscited by 10
- 2024LATTE: Improving Latex Recognition for Tables and Formulae with Iterative Refinementcited by 8
- 2026ReflexiCoder: Teaching Large Language Models to Self-Reflect on Generated Code and Self-Correct It via Reinforcement Learningcited by 7
- 2026PatchWorld: Gradient-Free Optimization of Executable World Models for Agent Environmentscited by 7
- 2025CodeEvo: Interaction-Driven Synthesis of Code-centric Data through Hybrid and Iterative Feedbackcited by 5
- 2026How Many Tries Does It Take? Iterative Self-Repair in LLM Code Generation Across Model Scales and Benchmarkscited by 5
- 2025NL-Debugging: Exploiting Natural Language as an Intermediate Representation for Code Debuggingcited by 4
- 2025Code Reasoning for Software Engineering Tasks: A Survey and A Call to Actioncited by 4
- 2026InCoder-32B-Thinking: Industrial Code World Model for Thinkingcited by 4
- 2026Falsification, Not Exposure: An Internally Preregistered Placebo-Controlled Decomposition of Self-Repair Feedback in Frozen Small Code Modelscited by 4
- 2025Agentic-R1: Distilled Dual-Strategy Reasoningcited by 3
- 2025MapCoder-Lite: Distilling Multi-Agent Coding into a Single Small LLMcited by 3
- 2024VDebugger: Harnessing Execution Feedback for Debugging Visual Programscited by 2
- 2025To Trade or Not to Trade: An Agentic Approach to Estimating Market Risk Improves Trading Decisionscited by 2
- 2025Self-Correction Distillation for Structured Data Question Answeringcited by 2
- 2026Credit-Budgeted ICPC-Style Coding: When Agents Must Pay for Every Decisioncited by 2
- 2026REFLEX: Reflective Evolution from LLM Experiencecited by 2
- 2026Form, Not Content? A Preregistered, Placebo-Controlled Evaluation of Learned Error-Conditioned Self-Repair Through Prompts and Weights in Frozen Small Code Modelscited by 2
- 2026FVRuleLearner: Operator-Level Reasoning Tree (Op-Tree)-Based Rules Learning for Formal Verificationcited by 1
- 2026Two-Stage Reinforcement Learning for Sound and Adversarial Test Generation in Code LLMscited by 1
- 2025TGPR: Tree-Guided Policy Refinement for Robust Self-Debugging of LLMscited by 0
- 2025DebugTA: An LLM-Based Agent for Simplifying Debugging and Teaching in Programming Educationcited by 0
- 2025GAPO: Robust Advantage Estimation for Real-World Code LLMscited by 0
- 2026SAFEdit: Does Multi-Agent Decomposition Resolve the Reliability Challenges of Instructed Code Editing?cited by 0
- 2026Security of LLM-generated Code: A Comparative Analysiscited by 0
- 2026ACTS-SQL: Agentic and Critic-Oriented Tree-Structured SQL Correctness with Large Language Modelscited by 0
- 2026Mapping the RAG Landscape: A Four Axis Taxonomy of Efficiency, Defense, Interactivity, and Reasoningcited by 0
- 2026Mapping the RAG Landscape: A Four Axis Taxonomy of Efficiency, Defense, Interactivity, and Reasoning1 Oct 2026
- 2026Two-Stage Reinforcement Learning for Sound and Adversarial Test Generation in Code LLMs3 Sep 2026
- 2026ACTS-SQL: Agentic and Critic-Oriented Tree-Structured SQL Correctness with Large Language Models15 Aug 2026
- 2026Form, Not Content? A Preregistered, Placebo-Controlled Evaluation of Learned Error-Conditioned Self-Repair Through Prompts and Weights in Frozen Small Code Models14 Jul 2026
- 2026Falsification, Not Exposure: An Internally Preregistered Placebo-Controlled Decomposition of Self-Repair Feedback in Frozen Small Code Models30 Jun 2026
- 2026REFLEX: Reflective Evolution from LLM Experience15 Jun 2026
- 2026PatchWorld: Gradient-Free Optimization of Executable World Models for Agent Environments29 May 2026
- 2026Security of LLM-generated Code: A Comparative Analysis21 May 2026
- 2026SAFEdit: Does Multi-Agent Decomposition Resolve the Reliability Challenges of Instructed Code Editing?28 Apr 2026
- 2026How Many Tries Does It Take? Iterative Self-Repair in LLM Code Generation Across Model Scales and Benchmarks12 Apr 2026
- 2026Credit-Budgeted ICPC-Style Coding: When Agents Must Pay for Every Decision11 Apr 2026
- 2026InCoder-32B-Thinking: Industrial Code World Model for Thinking3 Apr 2026
28 more
- 2026FVRuleLearner: Operator-Level Reasoning Tree (Op-Tree)-Based Rules Learning for Formal Verification6 Mar 2026
- 2026ReflexiCoder: Teaching Large Language Models to Self-Reflect on Generated Code and Self-Correct It via Reinforcement Learning6 Mar 2026
- 2026Hierarchy-of-Groups Policy Optimization for Long-Horizon Agentic Tasks26 Feb 2026
- 2025RefineBench: Evaluating Refinement Capability of Language Models via Checklists27 Nov 2025
- 2025Self-Correction Distillation for Structured Data Question Answering11 Nov 2025
- 2025GAPO: Robust Advantage Estimation for Real-World Code LLMs22 Oct 2025
- 2025DebugTA: An LLM-Based Agent for Simplifying Debugging and Teaching in Programming Education13 Oct 2025
- 2025TGPR: Tree-Guided Policy Refinement for Robust Self-Debugging of LLMs8 Oct 2025
- 2025MapCoder-Lite: Distilling Multi-Agent Coding into a Single Small LLM22 Sep 2025
- 2025CodeEvo: Interaction-Driven Synthesis of Code-centric Data through Hybrid and Iterative Feedback25 Jul 2025
- 2025R4ec: A Reasoning, Reflection, and Refinement Framework for Recommendation Systems23 Jul 2025
- 2025AlgoTune: Can Language Models Speed Up General-Purpose Numerical Programs?19 Jul 2025
- 2025To Trade or Not to Trade: An Agentic Approach to Estimating Market Risk Improves Trading Decisions11 Jul 2025
- 2025Agentic-R1: Distilled Dual-Strategy Reasoning8 Jul 2025
- 2025Code Reasoning for Software Engineering Tasks: A Survey and A Call to Action16 Jun 2025
- 2025Advancing Tool-Augmented Large Language Models via Meta-Verification and Reflection Learning5 Jun 2025
- 2025VisCoder: Fine-Tuning LLMs for Executable Python Visualization Code Generation4 Jun 2025
- 2025Vibe Coding vs. Agentic Coding: Fundamentals and Practical Implications of Agentic AI26 May 2025
- 2025NL-Debugging: Exploiting Natural Language as an Intermediate Representation for Code Debugging21 May 2025
- 2025Internet of Agents: Fundamentals, Applications, and Challenges12 May 2025
- 2025RepoST: Scalable Repository-Level Coding Environment Construction with Sandbox Testing10 Mar 2025
- 2025Revisit Self-Debugging with Self-Generated Tests for Code Generation22 Jan 2025
- 2024Enhancing Code LLMs with Reinforcement Learning in Code Generation: A Survey29 Dec 2024
- 2024Multi-Programming Language Sandbox for LLMs30 Oct 2024
- 2024An LLM Agent for Automatic Geospatial Data Analysis24 Oct 2024
- 2024From Code to Correctness: Closing the Last Mile of Code Generation with Hierarchical Debugging2 Oct 2024
- 2024LATTE: Improving Latex Recognition for Tables and Formulae with Iterative Refinement21 Sep 2024
- 2024VDebugger: Harnessing Execution Feedback for Debugging Visual Programs19 Jun 2024
- 2026Hierarchy-of-Groups Policy Optimization for Long-Horizon Agentic Taskscited by 49
- 2025R4ec: A Reasoning, Reflection, and Refinement Framework for Recommendation Systemscited by 16
- 2025Code Reasoning for Software Engineering Tasks: A Survey and A Call to Actioncited by 4
- 2026InCoder-32B-Thinking: Industrial Code World Model for Thinkingcited by 4
- 2025Agentic-R1: Distilled Dual-Strategy Reasoningcited by 3
- 2024VDebugger: Harnessing Execution Feedback for Debugging Visual Programscited by 2
- 2026FVRuleLearner: Operator-Level Reasoning Tree (Op-Tree)-Based Rules Learning for Formal Verificationcited by 1
- 2025TGPR: Tree-Guided Policy Refinement for Robust Self-Debugging of LLMscited by 0
- 2025GAPO: Robust Advantage Estimation for Real-World Code LLMscited by 0
- 2026Mapping the RAG Landscape: A Four Axis Taxonomy of Efficiency, Defense, Interactivity, and Reasoningcited by 0
- 2026Mapping the RAG Landscape: A Four Axis Taxonomy of Efficiency, Defense, Interactivity, and Reasoning1 Oct 2026
- 2026InCoder-32B-Thinking: Industrial Code World Model for Thinking3 Apr 2026
- 2026FVRuleLearner: Operator-Level Reasoning Tree (Op-Tree)-Based Rules Learning for Formal Verification6 Mar 2026
- 2026Hierarchy-of-Groups Policy Optimization for Long-Horizon Agentic Tasks26 Feb 2026
- 2025GAPO: Robust Advantage Estimation for Real-World Code LLMs22 Oct 2025
- 2025TGPR: Tree-Guided Policy Refinement for Robust Self-Debugging of LLMs8 Oct 2025
- 2025R4ec: A Reasoning, Reflection, and Refinement Framework for Recommendation Systems23 Jul 2025
- 2025Agentic-R1: Distilled Dual-Strategy Reasoning8 Jul 2025
- 2025Code Reasoning for Software Engineering Tasks: A Survey and A Call to Action16 Jun 2025
- 2024VDebugger: Harnessing Execution Feedback for Debugging Visual Programs19 Jun 2024
- 2025Vibe Coding vs. Agentic Coding: Fundamentals and Practical Implications of Agentic AIcited by 42
- 2025Internet of Agents: Fundamentals, Applications, and Challengescited by 31
- 2024An LLM Agent for Automatic Geospatial Data Analysiscited by 21
- 2025MapCoder-Lite: Distilling Multi-Agent Coding into a Single Small LLMcited by 3
- 2025To Trade or Not to Trade: An Agentic Approach to Estimating Market Risk Improves Trading Decisionscited by 2
- 2026Credit-Budgeted ICPC-Style Coding: When Agents Must Pay for Every Decisioncited by 2
- 2025DebugTA: An LLM-Based Agent for Simplifying Debugging and Teaching in Programming Educationcited by 0
- 2026SAFEdit: Does Multi-Agent Decomposition Resolve the Reliability Challenges of Instructed Code Editing?cited by 0
- 2026ACTS-SQL: Agentic and Critic-Oriented Tree-Structured SQL Correctness with Large Language Modelscited by 0
- 2026ACTS-SQL: Agentic and Critic-Oriented Tree-Structured SQL Correctness with Large Language Models15 Aug 2026
- 2026SAFEdit: Does Multi-Agent Decomposition Resolve the Reliability Challenges of Instructed Code Editing?28 Apr 2026
- 2026Credit-Budgeted ICPC-Style Coding: When Agents Must Pay for Every Decision11 Apr 2026
- 2025DebugTA: An LLM-Based Agent for Simplifying Debugging and Teaching in Programming Education13 Oct 2025
- 2025MapCoder-Lite: Distilling Multi-Agent Coding into a Single Small LLM22 Sep 2025
- 2025To Trade or Not to Trade: An Agentic Approach to Estimating Market Risk Improves Trading Decisions11 Jul 2025
- 2025Vibe Coding vs. Agentic Coding: Fundamentals and Practical Implications of Agentic AI26 May 2025
- 2025Internet of Agents: Fundamentals, Applications, and Challenges12 May 2025
- 2024An LLM Agent for Automatic Geospatial Data Analysis24 Oct 2024
- 2026REFLEX: Reflective Evolution from LLM Experiencecited by 2
- 2026REFLEX: Reflective Evolution from LLM Experience15 Jun 2026
- 2024Enhancing Code LLMs with Reinforcement Learning in Code Generation: A Surveycited by 83
- 2024From Code to Correctness: Closing the Last Mile of Code Generation with Hierarchical Debuggingcited by 46
- 2025AlgoTune: Can Language Models Speed Up General-Purpose Numerical Programs?cited by 27
- 2025Advancing Tool-Augmented Large Language Models via Meta-Verification and Reflection Learningcited by 24
- 2025VisCoder: Fine-Tuning LLMs for Executable Python Visualization Code Generationcited by 17
- 2025RefineBench: Evaluating Refinement Capability of Language Models via Checklistscited by 15
- 2025RepoST: Scalable Repository-Level Coding Environment Construction with Sandbox Testingcited by 13
- 2024Multi-Programming Language Sandbox for LLMscited by 10
- 2024LATTE: Improving Latex Recognition for Tables and Formulae with Iterative Refinementcited by 8
- 2026ReflexiCoder: Teaching Large Language Models to Self-Reflect on Generated Code and Self-Correct It via Reinforcement Learningcited by 7
- 2025CodeEvo: Interaction-Driven Synthesis of Code-centric Data through Hybrid and Iterative Feedbackcited by 5
- 2026How Many Tries Does It Take? Iterative Self-Repair in LLM Code Generation Across Model Scales and Benchmarkscited by 5
12 most cited of 18 All 18 (JSON)
- 2026Two-Stage Reinforcement Learning for Sound and Adversarial Test Generation in Code LLMs3 Sep 2026
- 2026Form, Not Content? A Preregistered, Placebo-Controlled Evaluation of Learned Error-Conditioned Self-Repair Through Prompts and Weights in Frozen Small Code Models14 Jul 2026
- 2026Falsification, Not Exposure: An Internally Preregistered Placebo-Controlled Decomposition of Self-Repair Feedback in Frozen Small Code Models30 Jun 2026
- 2026Security of LLM-generated Code: A Comparative Analysis21 May 2026
- 2026How Many Tries Does It Take? Iterative Self-Repair in LLM Code Generation Across Model Scales and Benchmarks12 Apr 2026
- 2026ReflexiCoder: Teaching Large Language Models to Self-Reflect on Generated Code and Self-Correct It via Reinforcement Learning6 Mar 2026
- 2025RefineBench: Evaluating Refinement Capability of Language Models via Checklists27 Nov 2025
- 2025Self-Correction Distillation for Structured Data Question Answering11 Nov 2025
- 2025CodeEvo: Interaction-Driven Synthesis of Code-centric Data through Hybrid and Iterative Feedback25 Jul 2025
- 2025AlgoTune: Can Language Models Speed Up General-Purpose Numerical Programs?19 Jul 2025
- 2025Advancing Tool-Augmented Large Language Models via Meta-Verification and Reflection Learning5 Jun 2025
- 2025VisCoder: Fine-Tuning LLMs for Executable Python Visualization Code Generation4 Jun 2025
12 newest of 18 All 18 (JSON)
Similar, not cited
Close in wording, no citation either way
- 2026Self-Execution Simulation Improves Coding Models
- 2025LeetCodeDataset: A Temporal Dataset for Robust Evaluation and Efficient Training of Code LLMs
- 2024NExT: Teaching Large Language Models to Reason about Code Execution
- 2025Enhancing LLM Code Generation: A Systematic Evaluation of Multi-Agent Collaboration and Runtime Debugging for Improved Accuracy, Reliability, and Latency
- 2026Unlocking LLM Code Correction with Iterative Feedback Loops
- 2026Teaching Code LLMs to Reason with Intermediate Formal Specifications
- 2024SelfPiCo: Self-Guided Partial Code Execution with LLMs
- 2024COAST: Enhancing the Code Debugging Ability of LLMs through Communicative Agent Based Data Synthesis