mlsanityData to 14 Oct 2026

LeDex: Training LLMs to Better Self-Debug and Explain Code

arXiv 2405.18649 ↗First posted 28 May 2024cs.CL cs.AI cs.SEcited by 40

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

  1. 2017Proximal Policy Optimization Algorithmscited by 15,215
  2. 2023Judging LLM-as-a-Judge with MT-Bench and Chatbot Arenacited by 8,626
  3. 2021Evaluating Large Language Models Trained on Codecited by 8,320
  4. 2023Direct Preference Optimization: Your Language Model is Secretly a Reward Modelcited by 8,065
  5. 2021Program Synthesis with Large Language Modelscited by 3,637
  6. 2022Competition-Level Code Generation with AlphaCodecited by 1,462
  7. 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,391
  8. 2023Teaching Large Language Models to Self-Debugcited by 988
  9. 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 906
  10. 2021Measuring Coding Challenge Competence With APPScited by 902
  11. 2020Making Monolingual Sentence Embeddings Multilingual using Knowledge Distillationcited by 593
  12. 2022CodeRL: Mastering Code Generation through Pretrained Models and Deep Reinforcement Learningcited by 358
16 more
  1. 2023CodeT5+: Open Code Large Language Models for Code Understanding and Generationcited by 333
  2. 2024OpenCodeInterpreter: Integrating Code Generation with Execution and Refinementcited by 247
  3. 2022Practical Program Repair in the Era of Large Pre-trained Language Modelscited by 133
  4. 2023CodeGen2: Lessons for Training LLMs on Programming and Natural Languagescited by 125
  5. 2022Large Language Models are Few-shot Testers: Exploring LLM-based General Bug Reproductioncited by 111
  6. 2023Self-Edit: Fault-Aware Code Editor for Code Generationcited by 111
  7. 2022Large Language Models are Zero-Shot Fuzzers: Fuzzing Deep-Learning Libraries via Large Language Modelscited by 103
  8. 2023Execution-based Code Generation using Deep Reinforcement Learningcited by 99
  9. 2023Impact of Code Language Models on Automated Program Repaircited by 85
  10. 2023Improving Code Generation by Training with Natural Language Feedbackcited by 76
  11. 2023How Effective Are Neural Networks for Fixing Security Vulnerabilitiescited by 52
  12. 2022Training Language Models with Language Feedbackcited by 49
  13. 2024CYCLE: Learning to Self-Refine the Code Generationcited by 42
  14. 2024A Deep Dive into Large Language Models for Automated Bug Localization and Repaircited by 39
  15. 2024TOGLL: Correct and Strong Test Oracle Generation with LLMscited by 24
  16. 2024Leveraging Print Debugging to Improve Code Generation in Large Language Modelscited by 15

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2024: 6; 2025: 19; 2026: 15.

40 papers.

Sort:

By area:

  1. 2024Enhancing Code LLMs with Reinforcement Learning in Code Generation: A Surveycited by 83
  2. 2026Hierarchy-of-Groups Policy Optimization for Long-Horizon Agentic Taskscited by 49
  3. 2024From Code to Correctness: Closing the Last Mile of Code Generation with Hierarchical Debuggingcited by 46
  4. 2025Vibe Coding vs. Agentic Coding: Fundamentals and Practical Implications of Agentic AIcited by 42
  5. 2025Internet of Agents: Fundamentals, Applications, and Challengescited by 31
  6. 2025AlgoTune: Can Language Models Speed Up General-Purpose Numerical Programs?cited by 27
  7. 2025Advancing Tool-Augmented Large Language Models via Meta-Verification and Reflection Learningcited by 24
  8. 2025Revisit Self-Debugging with Self-Generated Tests for Code Generationcited by 22
  9. 2024An LLM Agent for Automatic Geospatial Data Analysiscited by 21
  10. 2025VisCoder: Fine-Tuning LLMs for Executable Python Visualization Code Generationcited by 17
  11. 2025R4ec: A Reasoning, Reflection, and Refinement Framework for Recommendation Systemscited by 16
  12. 2025RefineBench: Evaluating Refinement Capability of Language Models via Checklistscited by 15
28 more
  1. 2025RepoST: Scalable Repository-Level Coding Environment Construction with Sandbox Testingcited by 13
  2. 2024Multi-Programming Language Sandbox for LLMscited by 10
  3. 2024LATTE: Improving Latex Recognition for Tables and Formulae with Iterative Refinementcited by 8
  4. 2026ReflexiCoder: Teaching Large Language Models to Self-Reflect on Generated Code and Self-Correct It via Reinforcement Learningcited by 7
  5. 2026PatchWorld: Gradient-Free Optimization of Executable World Models for Agent Environmentscited by 7
  6. 2025CodeEvo: Interaction-Driven Synthesis of Code-centric Data through Hybrid and Iterative Feedbackcited by 5
  7. 2026How Many Tries Does It Take? Iterative Self-Repair in LLM Code Generation Across Model Scales and Benchmarkscited by 5
  8. 2025NL-Debugging: Exploiting Natural Language as an Intermediate Representation for Code Debuggingcited by 4
  9. 2025Code Reasoning for Software Engineering Tasks: A Survey and A Call to Actioncited by 4
  10. 2026InCoder-32B-Thinking: Industrial Code World Model for Thinkingcited by 4
  11. 2026Falsification, Not Exposure: An Internally Preregistered Placebo-Controlled Decomposition of Self-Repair Feedback in Frozen Small Code Modelscited by 4
  12. 2025Agentic-R1: Distilled Dual-Strategy Reasoningcited by 3
  13. 2025MapCoder-Lite: Distilling Multi-Agent Coding into a Single Small LLMcited by 3
  14. 2024VDebugger: Harnessing Execution Feedback for Debugging Visual Programscited by 2
  15. 2025To Trade or Not to Trade: An Agentic Approach to Estimating Market Risk Improves Trading Decisionscited by 2
  16. 2025Self-Correction Distillation for Structured Data Question Answeringcited by 2
  17. 2026Credit-Budgeted ICPC-Style Coding: When Agents Must Pay for Every Decisioncited by 2
  18. 2026REFLEX: Reflective Evolution from LLM Experiencecited by 2
  19. 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
  20. 2026FVRuleLearner: Operator-Level Reasoning Tree (Op-Tree)-Based Rules Learning for Formal Verificationcited by 1
  21. 2026Two-Stage Reinforcement Learning for Sound and Adversarial Test Generation in Code LLMscited by 1
  22. 2025TGPR: Tree-Guided Policy Refinement for Robust Self-Debugging of LLMscited by 0
  23. 2025DebugTA: An LLM-Based Agent for Simplifying Debugging and Teaching in Programming Educationcited by 0
  24. 2025GAPO: Robust Advantage Estimation for Real-World Code LLMscited by 0
  25. 2026SAFEdit: Does Multi-Agent Decomposition Resolve the Reliability Challenges of Instructed Code Editing?cited by 0
  26. 2026Security of LLM-generated Code: A Comparative Analysiscited by 0
  27. 2026ACTS-SQL: Agentic and Critic-Oriented Tree-Structured SQL Correctness with Large Language Modelscited by 0
  28. 2026Mapping the RAG Landscape: A Four Axis Taxonomy of Efficiency, Defense, Interactivity, and Reasoningcited by 0

Similar, not cited

Close in wording, no citation either way

  1. 2026Self-Execution Simulation Improves Coding Models
  2. 2025LeetCodeDataset: A Temporal Dataset for Robust Evaluation and Efficient Training of Code LLMs
  3. 2024NExT: Teaching Large Language Models to Reason about Code Execution
  4. 2025Enhancing LLM Code Generation: A Systematic Evaluation of Multi-Agent Collaboration and Runtime Debugging for Improved Accuracy, Reliability, and Latency
  5. 2026Unlocking LLM Code Correction with Iterative Feedback Loops
  6. 2026Teaching Code LLMs to Reason with Intermediate Formal Specifications
  7. 2024SelfPiCo: Self-Guided Partial Code Execution with LLMs
  8. 2024COAST: Enhancing the Code Debugging Ability of LLMs through Communicative Agent Based Data Synthesis