arXiv:2607.02390cs.LG2026-07

让大模型分步写代码,用模块化组合解决更难问题

DecompRL: Solving Harder Problems by Learning Modular Code Generation

论文配图:DecompRL: Solving Harder Problems by Learning Modular Code Generation
图 1 · 摘自论文原文
  • 将复杂问题拆解为可独立实现的子模块,再组合求解
  • 在两个数据集上,超过10万次提示后仍能持续提升准确率
  • 适合需要高精度代码生成的复杂任务,如编程竞赛

大型语言模型为何无法解决某些问题?重复采样虽能提升成功率,但显存成本随尝试次数线性增长;强化学习虽可提升单次尝试的准确率,却牺牲了样本多样性。当基础策略产生正确解的概率极低时,无论怎样采样或优化梯度都无法突破搜索空间过大的瓶颈。本文提出新思路:不盲目增加采样,而是通过分解问题为多个可独立求解的子函数,实现模块化代码生成。由于现成模型未训练于此,我们设计 DecompRL——一种显式学习层次化代码结构分解与实现的强化学习算法。重组 $k$ 个模块的 $n$ 种实现,最多可生成 $k^{n}$ 个候选解,将计算瓶颈从昂贵的GPU推理转为低成本的CPU评估,使GPU token消耗降低约50倍。在 LiveCodeBench 与 CodeContests(Qwen 2.5 7B、Code World Model 32B)上,DecompRL 在每题超10^5个token后仍优于标准及多样性优化的强化学习基线,成功解决了标准生成无法触及的问题。

原文摘要 · Abstract (English)

How can Large Language Models (LLMs) solve problems they currently cannot? Repeated sampling scales test-time compute but GPU cost grows linearly with attempts, while reinforcement learning (RL) with verifiable rewards improves single-attempt accuracy at the expense of sample diversity. Both strategies ultimately fail when the base policy has near-zero probability of producing a correct solution: no amount of sampling or gradient signal can overcome a search space that is simply too large. We take a different approach: rather than sampling harder, we make the task easier by decomposing problems into smaller, independently solvable sub-functions whose implementations can be recombined. Since off-the-shelf models are not trained for this modular generation, we introduce DecompRL, an RL algorithm that explicitly learns to decompose and implement hierarchical code structures. Recombining $k$ implementations of $n$ modules yields up to $k^{n}$ candidate solutions, shifting the bottleneck from GPU inference to cheap CPU evaluation and cutting GPU token cost by $\sim$50$\times$. On LiveCodeBench and CodeContests (Qwen~2.5~7B, Code World Model~32B), DecompRL outperforms standard and diversity-optimized RL baselines beyond $10^5$ tokens per problem, solving problems that standard generation cannot reach.

代码生成强化学习模块化大模型

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。