paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Oracle-Guided Program Selection from Large Language Models

Oracle 引导的大语言模型程序选择
ISSTA Proceedings of the 33rd ACM SIGSOFT International Symposium on Software Testing and Analysis2024匹配度 3/10 · 论文关注LLM代码生成中的程序选择,使用LLM作为测试oracle,属于LLM辅助软件工程;但用户核心方向是静态分析、形式化验证、浮点/贝叶斯程序分析与LLM的交叉,该论文不涉及静态分析或形式化方法,与主要研究问题匹配度较低。引用 5 inbox
Zhiyu Fan, Haifeng Ruan, Sergey Mechtaev, Abhik Roychoudhury
crossref: 2026-09-12

AI 速览

一句话:提出以 LLM 作为测试 Oracle,通过区分性输入与输出选择提升 LLM 生成代码的正确性。

LLM 代码生成常产生错误程序,而以自然语言描述作为非形式化 oracle 并不可靠。现有方法从多个候选中选程序,依据 LLM 生成测试上执行结果的一致性,但测试可能冗余或无法区分正误,投票等准则也缺乏可解释依据。本文提出以 LLM 作为测试 oracle 的程序选择:首先生成能捕捉候选程序语义差异的区分性输入,记录各程序输出;再让 LLM 结合自然语言问题描述,从多个输出中选出最可能正确的输出。实现 LLMCodeChoice 并在 HumanEval 和 MBPP 上评估,pass@1 相比 CodeT 提升 3.6–7%;所选输入-输出规约还揭示任务描述不完整与歧义及基准错误参考实现。

问题
LLM 生成的代码可能不正确,且自然语言描述作为非形式化 oracle 不可靠;现有基于生成测试一致性的程序选择方法受冗余或无区分度测试、以及选择理由不透明等问题限制。
方法
提出以 LLM 作为测试 oracle:生成能区分候选程序语义的输入,记录各候选在这些输入上的输出,再让 LLM 依据自然语言描述从输出中选出最可能正确的输出,并实现工具 LLMCodeChoice。
评估
在 HumanEval 和 MBPP 基准上评估独立程序的生成与选择,pass@1 相比 CodeT 提升 3.6–7%;所选输入-输出规约还揭示了任务描述的不完整与歧义,以及基准中的错误参考实现。
原文摘要(Abstract)

While large language models (LLMs) have shown significant advancements in code generation, their susceptibility to producing incorrect code poses a significant challenge to the adoption of LLM-generated programs. This issue largely stems from the reliance on natural language descriptions as informal oracles in code generation. Current strategies to mitigate this involve selecting the best program from multiple LLM-generated alternatives, judged by criteria like the consistency of their execution results on an LLM-generated test suite. However, this approach has crucial limitations: (1) LLMs often generate redundant tests or tests that cannot distinguish between correct and incorrect solutions, (2) the used consistency criteria, such as the majority vote, fail to foster developer trust due to the absence of transparent rationale behind the made choices. In this work, we propose a new perspective on increasing the quality of LLM-generated code via program selection using the LLM as a test oracle. Our method is based on our experimentally confirmed observation that LLMs serve more effectively as oracles when tasked with selecting the correct output from multiple choices. Leveraging this insight, we first generate distinguishing inputs that capture semantic discrepancies of programs sampled from an LLM, and record outputs produced by the programs on these inputs. An LLM then selects the most likely to be correct output from these, guided by the natural language problem description. We implemented this idea in a tool LLMCodeChoice and evaluated its accuracy in generating and selecting standalone programs. Our experiments demonstrated its effectiveness in improving pass@1 by 3.6-7% on HumanEval and MBPP benchmarks compared to the state-of-art CodeT. Most interestingly, the selected input-output specifications helped us to uncover incompleteness and ambiguities in task descriptions and also identify incorrect ground-truth implementations in the benchmarks.

链接与引用

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

BibTeX
@inproceedings{paperbot8514,
  title = {Oracle-Guided Program Selection from Large Language Models},
  author = {Zhiyu Fan and Haifeng Ruan and Sergey Mechtaev and Abhik Roychoudhury},
  booktitle = {ISSTA},
  year = {2024},
  doi = {10.1145/3650212.3680308}
}