atlas

Research map / Large language models / Reasoning and chain of thought

CodeChain: Towards Modular Code Generation Through Chain of Self-revisions with Representative Sub-modules

ICLR 2024 · Large language models › Reasoning and chain of thought · approach: Search and self-correction in reasoning · 2 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Proposes CodeChain, an inference-time framework that prompts LLMs to write modular code via chain-of-thought and iteratively self-revises using clustered representative sub-modules, improving APPS and CodeContests pass@1.

Problem

LLMs struggle with complex competitive programming tasks, largely because they generate monolithic code rather than decomposing it into reusable sub-modules; prior self-revision methods use only per-sample feedback.

Approach

Chain-of-thought prompting elicits modular code with explicit sub-module signatures; sub-modules from all samples are embedded, clustered, and the centroid implementations are fed back into the prompt for iterative self-revision rounds.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
add CoT modularized prompting (without revision) (ablation)GPT3.5 direct generation · APPS validationpass@1 All: 26.00 -> 22.43 (no CoT vs CoT, no revision)Hurt
add public test filtering before clustering (ablation)CodeChain sub-module selection with GPT3.5 · APPS validationpass@1 All: +12.7 (22.43 -> 35.11 with C-M vs C-P without filter ~21.71 gain 13.4)Helped
select centroid sub-modules (clustering) vs random sub-modules (ablation)CodeChain revision with GPT3.5 · APPS validationpass@1 All: 32.87 (R-M) -> 35.11 (C-M)Helped
revise using sub-modules instead of whole programs (ablation)CodeChain with GPT3.5 (public filtered, centroid) · APPS validationpass@1 All: 30.16 (C-P) -> 35.11 (C-M)Helped
CodeChain self-revision with GPT3.5 vs direct generationGPT3.5 · APPS testpass@1 All: 22.33 -> 30.24Helped
CodeChain self-revision with WizardCoder 15BWizardCoder 15B · APPS testpass@1 All: 7.90 -> 10.50Helped
CodeChain sub-module revision with GPT4GPT4 · APPS 20-sample subsetpass@1 All: 34.75 -> 61.50Helped
CodeChain sub-module revision with GPT3.5GPT3.5 · APPS 20-sample subsetpass@1 All: 23.75 -> 26.35Helped
choice of embedding model for clustering (StarCoder vs CodeBert vs CodeT5+) (ablation)CodeChain with GPT3.5 · APPS validationpass@1 All: StarCoder 35.11, CodeT5+ 33.82, CodeBert 33.11Mixed
filter by private tests vs public tests before clustering (ablation)CodeChain with GPT3.5 · APPS validationpass@1 All: 35.11 (public) -> 37.40 (private)Helped
use synthetic tests for filtering instead of public tests (ablation)CodeChain with GPT3.5 · APPS validationpass@1 All: 35.11 (public) -> 22.04-25.09 (synthetic)Hurt
decreasing cluster number schedule across revision rounds (ablation)CodeChain cluster scheduling · APPS validationpass@1Helped

Surprising findings

Limitations

Experimental setup

Datasets: APPS CodeContests LeetCodeHardGym

Benchmarks: APPS CodeContests LeetCodeHardGym

Metrics: pass@1 pass@5 relative pass@1 improvement Likert modularity/reusability score

Baselines: Codex CodeT5 CodeRL+CodeT5 text-davinci-002 Self-edit+text-davinci-002 code-davinci-002 WizardCoder GPT3.5 Self-repair+GPT4 Self-debug Reflexion CodeT

Builds on: chain-of-thought prompting CodeT Self-debug Self-repair Reflexion

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy