paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Automatic Validation of LLM-Generated Code with Prompt Paraphrasing

基于提示改写的LLM生成代码自动验证
ICSE Proceedings of the IEEE/ACM 48th International Conference on Software Engineering2026匹配度 4/10 · 该论文关注 LLM 生成代码的缺陷检测,与 Coding Agent/LLM 代码可靠性这一邻近问题相关;但其核心方法是提示复述与多版本代码交叉验证,并不涉及用户重点关注的静态分析、形式化验证、浮点程序分析或贝叶斯程序分析,且更偏提示层测试技巧。引用 0 inbox
Xiaoyin Wang, Dakai Zhu
crossref: 2026-09-12

AI 速览

一句话:提出提示复述测试,通过改写提示生成多版代码并交叉验证语义一致性,以检测LLM生成代码缺陷。

LLM已被广泛用于代码生成,但生成代码的质量仍存疑,自动验证仍是难题。本文提出“提示复述测试”:观察到正确代码片段之间通常具有内在一致性,而有缺陷代码之间未必如此,因此可通过检测不一致性发现缺陷。方法是将给定提示改写为多个语义等价的提示,让LLM生成多版代码,再通过交叉验证检查这些代码之间的语义关系是否仍然成立。作者在HumanEval上进行初步评估,使用GPT-4o生成的程序,能检测出70.6%的错误程序,假阳性率为6.1%。

问题
如何自动验证LLM生成代码的正确性,并检测其中可能存在的缺陷。
方法
提出提示复述测试:将原提示改写为多个语义等价的提示,获取多版本生成代码,并交叉验证它们之间的语义关系是否一致;不一致则提示代码可能有缺陷。
评估
在HumanEval上使用GPT-4o生成程序进行初步评估,检测出70.6%的错误程序,假阳性率为6.1%。
原文摘要(Abstract)

Large Language Models (LLMs) have been widely used for code generation. However, the quality of generated code is still questionable, and code validation remains a challenging problem. In this paper, we propose a novel solution called paraphrase prompt testing. Our intuitive observation is that intrinsic consistency always exists among correct code pieces but may not exist among flawed code pieces, so we can detect flaws in the code by detecting inconsistencies. Therefore, we can vary a given prompt to multiple prompts with paraphrasing, and to ask the LLM to acquire multiple versions of generated code, so that we can validate whether the semantic relations still hold in the acquired code through cross-validation. Our initial evaluation on HumanEval shows that paraphrase prompt testing is able to detect 70.6% of the erroneous programs generated by GPT-4o, with a false positive rate of 6.1%.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@inproceedings{paperbot11981,
  title = {Automatic Validation of LLM-Generated Code with Prompt Paraphrasing},
  author = {Xiaoyin Wang and Dakai Zhu},
  booktitle = {ICSE},
  year = {2026},
  doi = {10.1145/3786582.3786809}
}