ATGen:用于测试用例生成的对抗性强化学习
ATGen: Adversarial Reinforcement Learning for Test Case Generation
AI总结:
针对静态测试生成方法存在固定难度上限的问题,提出ATGen框架,通过对抗性强化学习动态生成更难错误并训练测试生成器,显著提升测试用例质量与代码可靠性。
摘要:
大型语言模型(LLMs)在代码生成方面表现出色,但其输出往往包含微妙的错误,而有效的测试用例是发现这些错误的关键瓶颈。现有的测试生成方法,无论是基于提示还是基于监督微调,都依赖于静态数据集。这施加了一个“固定难度上限”,从根本上限制了它们发现训练范围之外的新颖或更复杂错误的能力。为了克服这一局限,我们引入了ATGen,一个通过对抗性强化学习训练测试用例生成器的框架。ATGen将测试生成器与一个对抗性代码生成器对抗,后者不断制造更难的错误以规避当前策略。这一动态循环创造了一个难度递增的课程,挑战当前策略。测试生成器通过强化学习(RL)进行优化,以联合最大化“输出准确率”和“攻击成功率”,使其能够学习到一种逐步增强的策略,从而打破静态训练的固定难度上限。大量实验表明,ATGen显著优于最先进的基线方法。我们进一步验证了其实用价值,证明它既可以作为Best-of-N推理的更有效过滤器,也可以作为训练代码生成模型时更高质量的奖励来源。我们的工作为提升LLM生成代码的可靠性建立了一种新的动态范式。
英文摘要:
Large Language Models (LLMs) excel at code generation, yet their outputs often contain subtle bugs, for which effective test cases are a critical bottleneck. Existing test generation methods, whether based on prompting or supervised fine-tuning, rely on static datasets. This imposes a ``fixed-difficulty ceiling'', fundamentally limiting their ability to uncover novel or more complex bugs beyond their training scope. To overcome this, we introduce ATGen, a framework that trains a test case generator via adversarial reinforcement learning. ATGen pits a test generator against an adversarial code generator that continuously crafts harder bugs to evade the current policy. This dynamic loop creates a curriculum of increasing difficulty challenging current policy. The test generator is optimized via Reinforcement Learning (RL) to jointly maximize ``Output Accuracy'' and ``Attack Success'', enabling it to learn a progressively stronger policy that breaks the fixed-difficulty ceiling of static training. Extensive experiments demonstrate that ATGen significantly outperforms state-of-the-art baselines. We further validate its practical utility, showing it serves as both a more effective filter for Best-of-N inference and a higher-quality reward source for training code generation models. Our work establishes a new, dynamic paradigm for improving the reliability of LLM-generated code.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。