arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2604.10449cs.SE
收藏

AdverMCTS:通过对抗性蒙特卡洛树搜索对抗代码生成中的伪正确性

AdverMCTS: Combating Pseudo-Correctness in Code Generation via Adversarial Monte Carlo Tree Search

Shanghai Jiao Tong University(上海交通大学);Nanyang Technological University(南洋理工大学)

Qingyao Li, Weiwen Liu, Weinan Zhang, Yong Yu, Bo An

AI总结:

本文提出AdverMCTS,通过将代码搜索与主动漏洞发现结合,对抗代码生成中的伪正确性问题,实验表明其优于现有方法,有效降低误报率。

摘要:

近年来,大型语言模型(LLMs)在代码生成中成功应用了基于搜索的策略。然而,现有方法通常依赖静态、稀疏的公开测试用例进行验证,导致伪正确性——即解决方案过拟合可见的公开测试用例但无法推广到隐藏测试用例。我们提出AdverMCTS,一种新颖的对抗性蒙特卡洛树搜索框架,通过将代码搜索与主动漏洞发现相结合,对抗伪正确性。AdverMCTS将生成过程建模为求解者代理与攻击者代理之间的最小最大博弈。求解者代理生成代码候选方案,攻击者代理则演化生成针对当前代码池的逻辑分歧的针对性测试用例。这些发现的测试用例形成一个动态、逐步恶化的过滤器,惩罚脆弱的推理。大量实验表明,AdverMCTS显著优于现有最先进基线方法,有效降低误报率并迫使模型超越初始约束。本工作的资源可在https://anonymous.4open.science/r/AdverMCTS_open-A255获取。

英文摘要:

Recent advancements in Large Language Models (LLMs) have successfully employed search-based strategies to enhance code generation. However, existing methods typically rely on static, sparse public test cases for verification, leading to pseudo-correctness -- where solutions overfit the visible public tests but fail to generalize to hidden test cases. We argue that optimizing against a fixed, weak environment inherently limits robustness. To address this, we propose AdverMCTS, a novel adversarial Monte Carlo Tree Search framework that combats pseudo-correctness by coupling code search with active vulnerability discovery. AdverMCTS formulates generation as a minimax-style game between a Solver agent, which synthesizes code candidates, and an Attacker agent, which evolves to generate targeted corner test cases that exploit logical divergences in the current code pool. These discovered tests form a dynamic, progressively hostile filter that penalizes fragile reasoning. Extensive experiments demonstrate that AdverMCTS significantly outperforms state-of-the-art baselines, effectively reducing false positive rates and forcing the model to generalize beyond the initial constraints. The resources of this work are available at https://anonymous.4open.science/r/AdverMCTS_open-A255.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑