CoSPlay:通过自生成代码与单元测试的测试时合作自博弈
阅读原文· arxiv.orgCoSPlay是一个无需Ground-Truth数据且无需训练的代码生成框架,其通过合作自博弈机制联合提升代码与单元测试质量。工作流程为:探索多样化方案并识别潜在失败模式以生成有区分度的单元测试;利用代码-单元测试执行矩阵中的双向通过计数信号,迭代修剪或修复弱代码、刷新或替换不可靠测试,使两个候选池协同演进;最终从最大输出共识簇中选择代码,因为正确代码对相同输入的输出一致。在四个基准测试上,应用于Qwen2.5-7B-Instruct时,将平均BoN从22.1%提升至33.2%,单元测试准确率从14.6%提升至78.3%,性能匹配或超越RLVR模型CURE-7B;应用于CURE-7B时,可进一步将BoN提升5.7%。该方法在不同骨干模型上具备泛化能力,且在可比的token预算下优于无GT数据的TTS基线,性能随预算增加持续提升。
Recently, Reinforcement Learning with Verifiable Rewards (RLVR) and Test-Time Scaling (TTS) have advanced LLM code generation through executable verification. Yet Ground-Truth Unit Tests (GT UTs) remain a bottleneck: SOTA RLVR methods require them for costly training, while existing TTS methods lose competitiveness without them. This motivates GT-free TTS, where existing methods directly use self-generated UTs to refine and select code candidates. Yet such UTs are often noisy or spuriously coupled with wrong code, and UT quality in turn cannot be validated without reliable code. The key challenge is therefore to jointly improve both. To this end, we present CoSPlay, a GT-free, training-free framework that jointly improves codes and UTs through cooperative self-play. It first explores diverse solution ideas and identifies their potential failure modes to produce discriminative UT ideas. It then uses bidirectional pass-count signals from the Code-UT execution matrix to iteratively prune or fix weak codes and refresh or replace unreliable UTs, letting the two pools co-evolve. Finally, when multiple codes remain tied at the highest pass count, it picks the final code from the largest output-consensus cluster, since correct codes agree on the same inputs while wrong codes diverge. Experiments on four challenging benchmarks show that CoSPlay on Qwen2.5-7B-Instruct improves average BoN from 22.1% to 33.2% and UT accuracy from 14.6% to 78.3%, matching or surpassing the RLVR model CURE-7B. When applied to CURE-7B, it further improves BoN by 5.7%. CoSPlay also generalizes across diverse backbones and outperforms GT-free TTS baselines under comparable token budgets, with continued gains as the budget scales up. These results suggest a scalable inference strategy for competitive code generation without any GT data.