CodeChain: Towards Modular Code Generation Through Chain of Self-revisions with Representative Sub-modules
Not on the map. Why?
Abstract (arXiv)
Large Language Models (LLMs) have already become quite proficient at solving simpler programming tasks like those in HumanEval or MBPP benchmarks. However, solving more complex and competitive programming tasks is still quite challenging for these models - possibly due to their tendency to generate solutions as monolithic code blocks instead of decomposing them into logical sub-tasks and sub-modules. On the other hand, experienced programmers instinctively write modularized code with abstraction for solving complex tasks, often reusing previously developed modules. To address this gap, we propose CodeChain, a novel framework for inference that elicits modularized code generation through a chain of self-revisions, each being guided by some representative sub-modules generated in previous iterations. Concretely, CodeChain first instructs the LLM to generate modularized codes through chain-of-thought prompting. Then it applies a chain of self-revisions by iterating the two steps: 1) extracting and clustering the generated sub-modules and selecting the cluster representatives as the more generic and re-usable implementations, and 2) augmenting the original chain-of-thought prompt with these selected module-implementations and instructing the LLM to re-generate new modularized solutions. We find that by naturally encouraging the LLM to reuse the previously developed and verified sub-modules, CodeChain can significantly boost both modularity as well as correctness of the generated solutions, achieving relative pass@1 improvements of 35% on APPS and 76% on CodeContests. It is shown to be effective on both OpenAI LLMs as well as open-sourced LLMs like WizardCoder. We also conduct comprehensive ablation studies with different methods of prompting, number of clusters, model sizes, program qualities, etc., to provide useful insights that underpin CodeChain's success.
Key facts. Cited by 58 papers in the map (data through 7 Oct 2026). Builds on 39 of its 60 references that are in the map. First posted on arXiv 13 Oct 2023.
Builds on
39 of 60 references.
References · 39
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2022Training language models to follow instructions with human feedbackcited by 15,712
- 2023LLaMA: Open and Efficient Foundation Language Modelscited by 13,958
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
- 2021Evaluating Large Language Models Trained on Codecited by 8,053
- 2023Efficient Memory Management for Large Language Model Serving with PagedAttentioncited by 5,767
- 2022Large Language Models are Zero-Shot Reasonerscited by 4,323
- 2023Reflexion: Language Agents with Verbal Reinforcement Learningcited by 4,064
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2023Self-Refine: Iterative Refinement with Self-Feedbackcited by 3,317
- 2019HuggingFace's Transformers: State-of-the-art Natural Language Processingcited by 2,201
27 more
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2022Competition-Level Code Generation with AlphaCodecited by 1,427
- 2022Least-to-Most Prompting Enables Complex Reasoning in Large Language Modelscited by 1,397
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,286
- 2023Teaching Large Language Models to Self-Debugcited by 963
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 890
- 2021Measuring Coding Challenge Competence With APPScited by 879
- 2023StarCoder: may the source be with you!cited by 790
- 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 732
- 2023WizardCoder: Empowering Code Large Language Models with Evol-Instructcited by 728
- 2023Textbooks Are All You Needcited by 561
- 2022DS-1000: A Natural and Reliable Benchmark for Data Science Code Generationcited by 442
- 2022CodeT: Code Generation with Generated Testscited by 369
- 2022CodeRL: Mastering Code Generation through Pretrained Models and Deep Reinforcement Learningcited by 342
- 2023CodeT5+: Open Code Large Language Models for Code Understanding and Generationcited by 327
- 2022Generating Sequences by Learning to Self-Correctcited by 271
- 2023LEVER: Learning to Verify Language-to-Code Generation with Executioncited by 228
- 2017RobustFill: Neural Program Learning under Noisy I/Ocited by 124
- 2023CodeGen2: Lessons for Training LLMs on Programming and Natural Languagescited by 124
- 2022Natural Language to Code Translation with Executioncited by 122
- 2023Self-Edit: Fault-Aware Code Editor for Code Generationcited by 110
- 2016Neuro-Symbolic Program Synthesiscited by 84
- 2022Coder Reviewer Reranking for Code Generationcited by 83
- 2020PyMT5: multi-mode translation of natural language and Python code with transformerscited by 80
- 2023Improving Code Generation by Training with Natural Language Feedbackcited by 75
- 2022Fault-Aware Neural Code Rankerscited by 33
- 2015Neural Random-Access Machinescited by 32
Built on by
Citing papers per year: 2023: 3; 2024: 27; 2025: 17; 2026: 11.
58 papers.
Sort:
By area:
- 2024TextGrad: Automatic "Differentiation" via Textcited by 250
- 2024Large Language Model-Based Agents for Software Engineering: A Surveycited by 173
- 2024Debug like a Human: A Large Language Model Debugger via Verifying Runtime Execution Step-by-stepcited by 123
- 2024Code Generation with AlphaCodium: From Prompt Engineering to Flow Engineeringcited by 100
- 2024Agents in Software Engineering: Survey, Landscape, and Visioncited by 60
- 2024What's Wrong with Your Code Generated by Large Language Models? An Extensive Studycited by 52
- 2024Beyond Chain-of-Thought: A Survey of Chain-of-X Paradigms for LLMscited by 48
- 2025Code to Think, Think to Code: A Survey on Code-Enhanced Reasoning and Reasoning-Driven Code Intelligence in LLMscited by 47
- 2025CodeCoR: An LLM-Based Self-Reflective Multi-Agent Framework for Code Generationcited by 33
- 2024CodeTree: Agent-guided Tree Search for Code Generation with Large Language Modelscited by 32
- 2023AgentCoder: Multi-Agent-based Code Generation with Iterative Testing and Optimisationcited by 31
- 2024What Makes Large Language Models Reason in (Multi-Turn) Code Generation?cited by 29
38 more
- 2023LLM-Assisted Code Cleaning For Training Accurate Code Generatorscited by 27
- 2025Large Language Model-based Data Science Agent: A Surveycited by 22
- 2025AutoIOT: LLM-Driven Automated Natural Language Programming for AIoT Applicationscited by 17
- 2024Selective Prompt Anchoring for Code Generationcited by 16
- 2026Vision2Web: A Hierarchical Benchmark for Visual Website Development with Agent Verificationcited by 16
- 2025From Code Foundation Models to Agents and Applications: A Comprehensive Survey and Practical Guide to Code Intelligencecited by 13
- 2024Problem Solving Through Human-AI Preference-Based Cooperationcited by 11
- 2024Scattered Forest Search: Smarter Code Space Exploration with LLMscited by 10
- 2025LLM4EFFI: Leveraging Large Language Models to Enhance Code Efficiency and Correctnesscited by 10
- 2023MoTCoder: Elevating Large Language Models with Modular of Thought for Challenging Programming Taskscited by 9
- 2024Measuring the Influence of Incorrect Code on Test Generationcited by 9
- 2024Multi-Programming Language Sandbox for LLMscited by 9
- 2024Large Language Models Synergize with Automated Machine Learningcited by 8
- 2024CoCoST: Automatic Complex Code Generation with Online Searching and Correctness Testingcited by 7
- 2024INDICT: Code Generation with Internal Dialogues of Critiques for Both Security and Helpfulnesscited by 7
- 2026LLM-Based Agentic Systems for Software Engineering: Challenges and Opportunitiescited by 7
- 2024Data Analysis in the Era of Generative AIcited by 6
- 2025An LLM Agentic Approach for Legal-Critical Software: A Case Study for Tax Prep Softwarecited by 5
- 2026PhysCodeBench: Benchmarking Physics-Aware Symbolic Simulation of 3D Scenes via Self-Corrective Multi-Agent Refinementcited by 5
- 2024PropTest: Automatic Property Testing for Improved Visual Programmingcited by 4
- 2024Testing the Effect of Code Documentation on Large Language Model Code Understandingcited by 4
- 2024PECC: Problem Extraction and Coding Challengescited by 4
- 2024PathOCL: Path-Based Prompt Augmentation for OCL Generation with GPT-4cited by 4
- 2025Code Reasoning for Software Engineering Tasks: A Survey and A Call to Actioncited by 4
- 2025From Legacy Fortran to Portable Kokkos: An Autonomous Agentic AI Workflowcited by 4
- 2025Agint: Agentic Graph Compilation for Software Engineering Agentscited by 4
- 2024Recursive Chain-of-Feedback Prevents Performance Degradation from Redundant Promptingcited by 3
- 2024Survey of User Interface Design and Interaction Techniques in Generative AI Applicationscited by 3
- 2025Enhancing Code Generation via Bidirectional Comment-Level Mutual Groundingcited by 3
- 2025Illuminating LLM Coding Agents: Visual Analytics for Deeper Understanding and Enhancementcited by 3
- 2026Solvita: Enhancing Large Language Models for Competitive Programming via Agentic Evolutioncited by 3
- 2024Self-Explained Keywords Empower Large Language Models for Code Generationcited by 2
- 2025MoT: Modularization-of-Thought Prompting for Effective Code Generationcited by 2
- 2025Optimizing LLM Code Suggestions: Feedback-Driven Timing with Lightweight State Boundscited by 2
- 2026VIBEPASS: Can Vibe Coders Really Pass the Vibe Check?cited by 2
- 2026PaT: Planning-after-Trial for Efficient Test-Time Code Generationcited by 2
- 2024AMR-Evol: Adaptive Modular Response Evolution Elicits Better Knowledge Distillation for Large Language Models in Code Generationcited by 1
- 2025Reinforcement Learning-Guided Chain-of-Draft for Token-Efficient Code Generationcited by 1
50 most cited of 58 All 58 (JSON)
- 2026Do Uncertainty Signals Help? A Systematic Study of Uncertainty-Aware Decoding with Rollback Mechanisms31 Jul 2026
- 2026DecompRL: Solving Harder Problems by Learning Modular Code Generation2 Jul 2026
- 2026Solvita: Enhancing Large Language Models for Competitive Programming via Agentic Evolution14 May 2026
- 2026PaT: Planning-after-Trial for Efficient Test-Time Code Generation8 May 2026
- 2026PhysCodeBench: Benchmarking Physics-Aware Symbolic Simulation of 3D Scenes via Self-Corrective Multi-Agent Refinement26 Apr 2026
- 2026RAT: RunAnyThing via Fully Automated Environment Configuration25 Apr 2026
- 2026DuET: Dual Execution for Test Output Prediction with Generated Code and Pseudocode13 Apr 2026
- 2026Vision2Web: A Hierarchical Benchmark for Visual Website Development with Agent Verification27 Mar 2026
- 2026VIBEPASS: Can Vibe Coders Really Pass the Vibe Check?16 Mar 2026
- 2026Compiling Large Multi-Modal Requirement Documents into Runnable Software Systems: From an Agentic Test-Driven Perspective14 Feb 2026
- 2026LLM-Based Agentic Systems for Software Engineering: Challenges and Opportunities14 Jan 2026
- 2025Agint: Agentic Graph Compilation for Software Engineering Agents24 Nov 2025
38 more
- 2025Optimizing LLM Code Suggestions: Feedback-Driven Timing with Lightweight State Bounds24 Nov 2025
- 2025From Code Foundation Models to Agents and Applications: A Comprehensive Survey and Practical Guide to Code Intelligence23 Nov 2025
- 2025Knowledge-Guided Multi-Agent Framework for Application-Level Software Code Generation22 Oct 2025
- 2025Reinforcement Learning-Guided Chain-of-Draft for Token-Efficient Code Generation26 Sep 2025
- 2025An LLM Agentic Approach for Legal-Critical Software: A Case Study for Tax Prep Software16 Sep 2025
- 2025From Legacy Fortran to Portable Kokkos: An Autonomous Agentic AI Workflow15 Sep 2025
- 2025Illuminating LLM Coding Agents: Visual Analytics for Deeper Understanding and Enhancement18 Aug 2025
- 2025Large Language Model-based Data Science Agent: A Survey2 Aug 2025
- 2025Code Reasoning for Software Engineering Tasks: A Survey and A Call to Action16 Jun 2025
- 2025LLM Agents for Interactive Exploration of Historical Cadastre Data: Framework and Application to Venice22 May 2025
- 2025Enhancing Code Generation via Bidirectional Comment-Level Mutual Grounding12 May 2025
- 2025MoT: Modularization-of-Thought Prompting for Effective Code Generation16 Mar 2025
- 2025AutoIOT: LLM-Driven Automated Natural Language Programming for AIoT Applications7 Mar 2025
- 2025Code to Think, Think to Code: A Survey on Code-Enhanced Reasoning and Reasoning-Driven Code Intelligence in LLMs26 Feb 2025
- 2025LLM4EFFI: Leveraging Large Language Models to Enhance Code Efficiency and Correctness17 Feb 2025
- 2025CodeCoR: An LLM-Based Self-Reflective Multi-Agent Framework for Code Generation14 Jan 2025
- 2024CodeTree: Agent-guided Tree Search for Code Generation with Large Language Models7 Nov 2024
- 2024Multi-Programming Language Sandbox for LLMs30 Oct 2024
- 2024Survey of User Interface Design and Interaction Techniques in Generative AI Applications28 Oct 2024
- 2024Scattered Forest Search: Smarter Code Space Exploration with LLMs22 Oct 2024
- 2024Self-Explained Keywords Empower Large Language Models for Code Generation21 Oct 2024
- 2024What Makes Large Language Models Reason in (Multi-Turn) Code Generation?10 Oct 2024
- 2024AMR-Evol: Adaptive Modular Response Evolution Elicits Better Knowledge Distillation for Large Language Models in Code Generation1 Oct 2024
- 2024Data Analysis in the Era of Generative AI27 Sep 2024
- 2024Measuring the Influence of Incorrect Code on Test Generation14 Sep 2024
- 2024Agents in Software Engineering: Survey, Landscape, and Vision13 Sep 2024
- 2024Large Language Model-Based Agents for Software Engineering: A Survey4 Sep 2024
- 2024Selective Prompt Anchoring for Code Generation17 Aug 2024
- 2024Problem Solving Through Human-AI Preference-Based Cooperation14 Aug 2024
- 2024What's Wrong with Your Code Generated by Large Language Models? An Extensive Study8 Jul 2024
- 2024INDICT: Code Generation with Internal Dialogues of Critiques for Both Security and Helpfulness23 Jun 2024
- 2024Investigating the Transferability of Code Repair for Low-Resource Programming Languages21 Jun 2024
- 2024TextGrad: Automatic "Differentiation" via Text11 Jun 2024
- 2024PathOCL: Path-Based Prompt Augmentation for OCL Generation with GPT-421 May 2024
- 2024Large Language Models Synergize with Automated Machine Learning6 May 2024
- 2024PECC: Problem Extraction and Coding Challenges29 Apr 2024
- 2024Beyond Chain-of-Thought: A Survey of Chain-of-X Paradigms for LLMs24 Apr 2024
- 2024Testing the Effect of Code Documentation on Large Language Model Code Understanding3 Apr 2024
50 newest of 58 All 58 (JSON)
- 2024Large Language Model-Based Agents for Software Engineering: A Surveycited by 173
- 2024Agents in Software Engineering: Survey, Landscape, and Visioncited by 60
- 2025CodeCoR: An LLM-Based Self-Reflective Multi-Agent Framework for Code Generationcited by 33
- 2023AgentCoder: Multi-Agent-based Code Generation with Iterative Testing and Optimisationcited by 31
- 2025Large Language Model-based Data Science Agent: A Surveycited by 22
- 2026Vision2Web: A Hierarchical Benchmark for Visual Website Development with Agent Verificationcited by 16
- 2025From Code Foundation Models to Agents and Applications: A Comprehensive Survey and Practical Guide to Code Intelligencecited by 13
- 2026LLM-Based Agentic Systems for Software Engineering: Challenges and Opportunitiescited by 7
- 2025An LLM Agentic Approach for Legal-Critical Software: A Case Study for Tax Prep Softwarecited by 5
- 2026PhysCodeBench: Benchmarking Physics-Aware Symbolic Simulation of 3D Scenes via Self-Corrective Multi-Agent Refinementcited by 5
- 2025From Legacy Fortran to Portable Kokkos: An Autonomous Agentic AI Workflowcited by 4
- 2025Agint: Agentic Graph Compilation for Software Engineering Agentscited by 4
12 most cited of 17 All 17 (JSON)
- 2026Solvita: Enhancing Large Language Models for Competitive Programming via Agentic Evolution14 May 2026
- 2026PhysCodeBench: Benchmarking Physics-Aware Symbolic Simulation of 3D Scenes via Self-Corrective Multi-Agent Refinement26 Apr 2026
- 2026Vision2Web: A Hierarchical Benchmark for Visual Website Development with Agent Verification27 Mar 2026
- 2026VIBEPASS: Can Vibe Coders Really Pass the Vibe Check?16 Mar 2026
- 2026Compiling Large Multi-Modal Requirement Documents into Runnable Software Systems: From an Agentic Test-Driven Perspective14 Feb 2026
- 2026LLM-Based Agentic Systems for Software Engineering: Challenges and Opportunities14 Jan 2026
- 2025Agint: Agentic Graph Compilation for Software Engineering Agents24 Nov 2025
- 2025From Code Foundation Models to Agents and Applications: A Comprehensive Survey and Practical Guide to Code Intelligence23 Nov 2025
- 2025Knowledge-Guided Multi-Agent Framework for Application-Level Software Code Generation22 Oct 2025
- 2025An LLM Agentic Approach for Legal-Critical Software: A Case Study for Tax Prep Software16 Sep 2025
- 2025From Legacy Fortran to Portable Kokkos: An Autonomous Agentic AI Workflow15 Sep 2025
- 2025Illuminating LLM Coding Agents: Visual Analytics for Deeper Understanding and Enhancement18 Aug 2025
12 newest of 17 All 17 (JSON)
- 2024Beyond Chain-of-Thought: A Survey of Chain-of-X Paradigms for LLMscited by 48
- 2025Code to Think, Think to Code: A Survey on Code-Enhanced Reasoning and Reasoning-Driven Code Intelligence in LLMscited by 47
- 2024CodeTree: Agent-guided Tree Search for Code Generation with Large Language Modelscited by 32
- 2024What Makes Large Language Models Reason in (Multi-Turn) Code Generation?cited by 29
- 2024Scattered Forest Search: Smarter Code Space Exploration with LLMscited by 10
- 2023MoTCoder: Elevating Large Language Models with Modular of Thought for Challenging Programming Taskscited by 9
- 2024PropTest: Automatic Property Testing for Improved Visual Programmingcited by 4
- 2025Code Reasoning for Software Engineering Tasks: A Survey and A Call to Actioncited by 4
- 2024Recursive Chain-of-Feedback Prevents Performance Degradation from Redundant Promptingcited by 3
- 2025MoT: Modularization-of-Thought Prompting for Effective Code Generationcited by 2
- 2026PaT: Planning-after-Trial for Efficient Test-Time Code Generationcited by 2
- 2026PaT: Planning-after-Trial for Efficient Test-Time Code Generation8 May 2026
- 2025Code Reasoning for Software Engineering Tasks: A Survey and A Call to Action16 Jun 2025
- 2025MoT: Modularization-of-Thought Prompting for Effective Code Generation16 Mar 2025
- 2025Code to Think, Think to Code: A Survey on Code-Enhanced Reasoning and Reasoning-Driven Code Intelligence in LLMs26 Feb 2025
- 2024CodeTree: Agent-guided Tree Search for Code Generation with Large Language Models7 Nov 2024
- 2024Scattered Forest Search: Smarter Code Space Exploration with LLMs22 Oct 2024
- 2024What Makes Large Language Models Reason in (Multi-Turn) Code Generation?10 Oct 2024
- 2024Beyond Chain-of-Thought: A Survey of Chain-of-X Paradigms for LLMs24 Apr 2024
- 2024PropTest: Automatic Property Testing for Improved Visual Programming25 Mar 2024
- 2024Recursive Chain-of-Feedback Prevents Performance Degradation from Redundant Prompting5 Feb 2024
- 2023MoTCoder: Elevating Large Language Models with Modular of Thought for Challenging Programming Tasks26 Dec 2023
- 2024TextGrad: Automatic "Differentiation" via Textcited by 250
- 2024Debug like a Human: A Large Language Model Debugger via Verifying Runtime Execution Step-by-stepcited by 123
- 2024Code Generation with AlphaCodium: From Prompt Engineering to Flow Engineeringcited by 100
- 2024What's Wrong with Your Code Generated by Large Language Models? An Extensive Studycited by 52
- 2023LLM-Assisted Code Cleaning For Training Accurate Code Generatorscited by 27
- 2025AutoIOT: LLM-Driven Automated Natural Language Programming for AIoT Applicationscited by 17
- 2024Selective Prompt Anchoring for Code Generationcited by 16
- 2024Problem Solving Through Human-AI Preference-Based Cooperationcited by 11
- 2025LLM4EFFI: Leveraging Large Language Models to Enhance Code Efficiency and Correctnesscited by 10
- 2024Measuring the Influence of Incorrect Code on Test Generationcited by 9
- 2024Multi-Programming Language Sandbox for LLMscited by 9
- 2024Large Language Models Synergize with Automated Machine Learningcited by 8
12 most cited of 30 All 30 (JSON)
- 2026Do Uncertainty Signals Help? A Systematic Study of Uncertainty-Aware Decoding with Rollback Mechanisms31 Jul 2026
- 2026DecompRL: Solving Harder Problems by Learning Modular Code Generation2 Jul 2026
- 2026RAT: RunAnyThing via Fully Automated Environment Configuration25 Apr 2026
- 2026DuET: Dual Execution for Test Output Prediction with Generated Code and Pseudocode13 Apr 2026
- 2025Optimizing LLM Code Suggestions: Feedback-Driven Timing with Lightweight State Bounds24 Nov 2025
- 2025Reinforcement Learning-Guided Chain-of-Draft for Token-Efficient Code Generation26 Sep 2025
- 2025LLM Agents for Interactive Exploration of Historical Cadastre Data: Framework and Application to Venice22 May 2025
- 2025Enhancing Code Generation via Bidirectional Comment-Level Mutual Grounding12 May 2025
- 2025AutoIOT: LLM-Driven Automated Natural Language Programming for AIoT Applications7 Mar 2025
- 2025LLM4EFFI: Leveraging Large Language Models to Enhance Code Efficiency and Correctness17 Feb 2025
- 2024Multi-Programming Language Sandbox for LLMs30 Oct 2024
- 2024Survey of User Interface Design and Interaction Techniques in Generative AI Applications28 Oct 2024
12 newest of 30 All 30 (JSON)
Similar, not cited
Close in wording, no citation either way
- 2023Beyond Accuracy: Evaluating Self-Consistency of Code Large Language Models with IdentityChain
- 2026Are you Synthesizing or Recalling? Evaluating LLMs on Algorithmic Code Retrieval
- 2025Towards Advancing Code Generation with Large Language Models: A Research Roadmap
- 2024HumanEval Pro and MBPP Pro: Evaluating Large Language Models on Self-invoking Code Generation
- 2024Large Language Models as Test Case Generators: Performance Evaluation and Enhancement
- 2023Self-planning Code Generation with Large Language Models
- 2024Assessing Code Generation with Intermediate Languages
- 2025Chain of Execution Supervision Promotes General Reasoning in Large Language Models