NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

SRLCG: Self-Rectified Large-Scale Code Generation with Multidimensional Chain-of-Thought and Dynamic Backtracking

Hongru Ma, Yanjie Liang, Jiasheng Si, Weiyu Zhang, Hongjiao Guan, Chaoqun Zheng, Bing Xu, Wenpeng LuarXiv 2025

TL;DR

SRLCG (Self-Rectified Large-Scale Code Generator) is a novel framework designed to generate complete, multi-file software projects from a single user prompt, overcoming the limitation of LLMs only producing isolated code snippets. By combining a top-down multidimensional Chain-of-Thought approach with dynamic backtracking and adaptive self-rectification, it produces code that is up to 16× longer and significantly more robust than standard LLM outputs.

What Problem Does This Paper Address?

While Large Language Models (LLMs) excel at generating short code snippets, they struggle to build complex, multi-file software projects. For non-expert users, prompting an LLM often results in fragmented code that they cannot easily assemble, modify, or debug.

Existing Chain-of-Thought (CoT) prompting methods typically operate on a single dimension, focusing on localized problem-solving rather than system-level architecture. This leads to two critical gaps:

  1. Inability to scale: Models fail to directly generate large-scale, complex project code.
  2. Lack of project integrity: Models neglect cross-module interactions, resulting in cascading logical errors and dependency mismatches across different files.

The authors introduce SRLCG to bridge these gaps, allowing users with zero coding knowledge to generate fully functional, multi-file projects from a single prompt.

Comparison of SRLCG and existing methods

Methods

SRLCG splits the code generation task into two core modules:

1. MdCoT-DB (Multidimensional Chain-of-Thought and Dynamic Backtracking)

This module adopts a top-down divide-and-conquer paradigm to break down project requirements into three distinct levels of granularity:

  • Strategic Dimension: Decomposes the initial prompt into high-level macro modules (e.g., authentication, data storage).
  • Tactical Dimension: Refines these modules into specific sub-functions and defines their responsibilities.
  • Operational Dimension: Translates the sub-function rationales directly into executable code files.

To assemble these pieces, a Dynamic Backtracking Algorithm iteratively merges function-level rationales. If a conflict (such as a return type discrepancy or dependency mismatch) is detected within or across modules, the algorithm backtracks, isolating the conflict set and invoking the backbone LLM to regenerate only the affected code subsets.

2. Self-Rectification with Adaptive Feedback

Verifying every single step in a large-scale project is computationally expensive. SRLCG introduces an adaptive feedback mechanism that calculates a verification weight (probability) that progressively attenuates (decreases) over successful iterations. If a verification check is triggered and fails, a feedback loop forces the model to revisit and refine its intermediate rationales before moving to the next dimension.

Figure 2: The SRLCG framework consists of two modules: (a) MdCoT-DB, which decomposes user prompts into sub-functions and then integrates them via dynamic backtracking, and (b) Self-Rectification applies to each MdCoT dimension, performing verification and rectification to ensure the correctness and robustness of the generated code.

Datasets

Because no public benchmark existed for single-prompt, large-scale project generation, the authors curated a new dataset consisting of 400 samples across six domains:

  • Game Development (60 samples)
  • Web Development (72 samples)
  • Artificial Intelligence / Machine Learning (100 samples)
  • Database Management (60 samples)
  • Mobile Development (60 samples)
  • Project Management Tools (48 samples)

Each sample includes a comprehensive task definition, explicit functional requirements, and technical specifications.

Key Insights and Ideas

  • Mimicking Human Engineering: Breaking down code generation into strategic, tactical, and operational phases mirrors how human software engineers architect systems, preventing the LLM from getting overwhelmed by immediate implementation details.
  • Targeted Backtracking Prevents Total Failure: In multi-file generation, a single error early on can ruin the entire codebase. Isolating conflicts and rewriting only the broken dependencies saves the successful parts of the generation.
  • Compute Efficiency via Attenuation: By dynamically lowering the probability of verification as the model demonstrates stable reasoning, the framework balances rigorous error-checking with inference speed.

Key Results

The authors evaluated SRLCG using GPT-4 and DeepSeek-V3 as backbone models, comparing it against several state-of-the-art CoT baselines:

  • Massive Code Length Extension: SRLCG generated code that was 15× longer than DeepSeek-V3 and 16× longer than GPT-4 on average, achieving an order-of-magnitude improvement over other baselines.
  • Enhanced Project Completeness: On a 0-to-100 LLM-based assessment scale, SRLCG improved project completeness by ~16.5%, correctness by ~13.1%, usability by ~20.0%, and robustness by ~19.1% compared to vanilla LLM baselines.
  • Human Evaluation Success: Professional programmers with 5+ years of experience reported that SRLCG improved project satisfaction and code quality while reducing development time by 36× compared to manually assembling vanilla LLM outputs.

Limitations and Future Work

The primary limitation of SRLCG is its high computational overhead. Due to the multi-step nature of multidimensional CoT and self-rectification, the average processing time for a single project is approximately 11 minutes using two Tesla V100 GPUs.

The authors acknowledge that this processing time may exceed user expectations for interactive tools. Consequently, future work will focus on optimizing inference efficiency and reducing the overall processing overhead.

Summary updated

BibTeX
@misc{ma2025srlcg,
  author = {Hongru Ma and Yanjie Liang and Jiasheng Si and Weiyu Zhang and Hongjiao Guan and Chaoqun Zheng and Bing Xu and Wenpeng Lu},
  title = {{SRLCG: Self-Rectified Large-Scale Code Generation with Multidimensional Chain-of-Thought and Dynamic Backtracking}},
  year = {2025},
  eprint = {2504.00532},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2504.00532},
}
Figure