Boost, Disentangle, and Customize: A Robust System2-to-System1 Pipeline for Code Generation (2025)

Abstract: To address these limitations, we propose BDC, a novel framework that Boosts reasoning exploration via multi-agent collaboration, Disentangles heterogeneous data into specialized experts, and Customizes solutions through dynamic model composition. BDC integrates a Monte Carlo Tree-of-Agents algorithm, where multiple LLMs mutually verify and refine reasoning paths through reflection-guided pruning, enabling efficient exploration of high-quality solutions. To handle data diversity, we cluster problems by latent semantics, train composable LoRA experts on each cluster, and deploy an input-aware hypernetwork to dynamically merge these experts into tailored solvers. Experiments on APPS and CodeContest benchmarks demonstrate BDC’s superiority: it achieves up to 73.8% accuracy on hard problems, outperforming state-of-the-art methods like LATS and RethinkMCTS by 9–15%. This work lays the groundwork for advancing LLM capabilities in complex reasoning tasks, offering a novel System2-to-System1 solution.

## introduction large language models show significant intelligence in various domains, striking both the academic and industrial institutions. despite their prominent problem-solving abilities in system 1 tasks, the mechanism behind the system 2 task solving procedure remain opaque. in this paper, we focus on the code generation task, which emerges as a captivating frontier @xcite @xcite , promising to revolutionize software development by enabling machines to write and optimize code with minimal human intervention. recent research of llms for code focus on inference-time computation (system 2 methods) @xcite @xcite and post-training. while during post-training, distilling system 2 knowledge into system 1 backbones is important and widely-used @xcite . however, the complex hidden reasoning process and the heterogeneous data distribution pose challenges to the existing system2-to-system1 pipeline. on one hand, the hidden reasoning process for code generation is complex and hard to explore (c1). on the other hand, the heterogeneous data distribution, e.g., jumping structure like branching, recursion, etc., makes the existing train-once-for-all strategy hard to fit the complex latent patterns for robust and generalizable llm solvers (c2). for (c1), we propose to disentangle the problem solving process into problem2thought and thought2solution stages, exploring the inherent reasoning clues via combining the strengths of multiple llms by mutually-verification and boosting. the exploration is integrated into a monte-carlo tree search process, where reflexion-based pruning and refinement are designed for more efficient and effective reasoning clues search. for (c2), we propose to disentangle the heterogeneous data into clusters, finetuning llms capable of different aspects of tasks to obtain the meta lora experts hub, and then adaptively generate customized problem solver for each code problem. concretely, we design an input-aware hypernetwork to generate rank-wise weights over meta lora experts for customized problem solver, offering robustness and flexibility. the main contributions of our work can be summarized below. ## methodology in this section, we introduce the overall methodology of bdc, addressing challenges in the system2to-system1 pipeline for code generation, specifically the complexity of hidden reasoning processes and heterogeneous data distributions. the proposed bdc pipeline consists of three main stages: 1) explore the system 2 knowledge via mutual verification and boosting between llms; 2) disentangle the obtained data into clusters over which composible lora experts are tuned; 3) customize problem solver by weighting over the composable lora experts using an input-aware hypernetwork. ## experiments we conduct empirical studies starting from the following research questions. rq1 does the proposed data collection algorithm explore insightful reasoning knowledge? rq2 do the complex latent patterns of reasoning data impact the training performance? rq3 can the disentangle-and-compose mechanism help to promote performance? rq4 do the proposed input-aware hypernet work outperform other model composition techniques? rq5 how does disenlora perform on untrained datasets? ## conclusion we identify the complexity of inherent reasoning exploration and the heterogeneous data distribution problems that hinder the performance of system2-to-system1 methods. correspondingly, we propose the bdc pipeline that explores insightful system2 knowledge via mutually boosting between llm agents, disentangle heterogeneous data distribution for composable lora experts, and customize problem solver for each instance, offering flexibility and robustness. correspondingly, we propose the mc-tree-of-agents algorithm to efficiently and effectively explore the insightful sys-tem2 knowledge via mutual verification and boosting of different llm agents, armed with rewardguided pruning and refinement to explore more beneficial states in limited rollouts for better performance. additionally, we design an input-aware hypernetwork to aggregate over the disentangled composable lora experts trained on different clusters of data collected from mc-tree-of-agents. this mechanism offers a customized problem solver for each data instance. various experiments and discussions validate the effectiveness of different model components.