Oracle-Guided Program Selection from Large Language Models
Zhiyu Fan, Haifeng Ruan, Sergey Mechtaev, Abhik Roychoudhury
摘要
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.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 5 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- On LLMs’ Internal Representation of Code Correctness 引用了 Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generation
- Self-Refine: Iterative Refinement with Self-Feedback 引用了 Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
- Measuring the Influence of Incorrect Code on Test Generation 引用了 Self-Refine: Iterative Refinement with Self-Feedback
- Measuring the Influence of Incorrect Code on Test Generation 引用了 Teaching Large Language Models to Self-Debug
- Measuring the Influence of Incorrect Code on Test Generation 引用了 Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generation
- Teaching Large Language Models to Self-Debug 引用了 Self-Refine: Iterative Refinement with Self-Feedback
- Teaching Large Language Models to Self-Debug 引用了 Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
- Automated Repair of Ambiguous Problem Descriptions for LLM-Based Code Generation 引用了 Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generation
- Reducing Hallucinations in LLM-Generated Code via Semantic Triangulation 引用了 Automated Repair of Ambiguous Problem Descriptions for LLM-Based Code Generation
- Reducing Hallucinations in LLM-Generated Code via Semantic Triangulation 引用了 Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generation
- Reducing Hallucinations in LLM-Generated Code via Semantic Triangulation 引用了 Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
- Solving Quantitative Reasoning Problems with Language Models 引用了 Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
引用它的顶会 Paper5
- Automated Repair of Ambiguous Problem Descriptions for LLM-Based Code GenerationHaoxiang Jia, Robbie Morris, He Ye, Federica Sarro 等ASE 2025 · 6 次引用
- Unlocking LLM Repair Capabilities Through Cross-Language Translation and Multi-Agent RefinementWenqiang Luo, Jacky Wai Keung, Boyang Yang, Jacques Klein 等ICSE 2026
- On LLMs’ Internal Representation of Code CorrectnessFrancisco Ribeiro, Claudio Spiess, Premkumar Devanbu, Sarah NadiICSE 2026
- Measuring the Influence of Incorrect Code on Test GenerationDong Huang, Jie M. Zhang, Mark Harman, Mingzhe Du 等ICSE 2026
- Reducing Hallucinations in LLM-Generated Code via Semantic TriangulationYihan Dai, Sijie Liang, Haotian Xu, Peichu Xie 等OOPSLA 2026
它引用的 Paper10
- Chain-of-Thought Prompting Elicits Reasoning in Large Language ModelsJason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma 等NeurIPS 2022 · 22,562 次引用
- Self-Refine: Iterative Refinement with Self-FeedbackAman Madaan, Niket Tandon, Prakhar Gupta, Skyler Hallinan 等NeurIPS 2023 · 4,972 次引用
- Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code GenerationJiawei Liu, Chunqiu Steven Xia, Yuyao Wang, Lingming ZhangNeurIPS 2023 · 2,317 次引用
- Solving Quantitative Reasoning Problems with Language ModelsAitor Lewkowycz, Anders Andreassen, David Dohan, Ethan Dyer 等NeurIPS 2022 · 2,039 次引用
- Teaching Large Language Models to Self-DebugXinyun Chen, Maxwell Lin, Nathanael Schärli, Denny ZhouICLR 2024 · 1,085 次引用
相关 Paper
- Towards Understanding the Characteristics of Code Generation Errors Made by Large Language ModelsZhijie Wang, Zijie Zhou, Da Song, Yuheng Huang 等ICSE 2025 · 12 次引用
- Self-Edit: Fault-Aware Code Editor for Code GenerationKechi Zhang, Zhuo Li, Jia Li, Ge Li 等ACL 2023 · 42 次引用
- Incoherence as Oracle-less Measure of Error in LLM-Based Code GenerationThomas Jean-Michel Valentin, Ardi Madadi, Gaetano Sapia, Marcel BöhmeAAAI 2026 · 4 次引用
- The First Prompt Counts the Most! An Evaluation of Large Language Models on Iterative Example-Based Code GenerationYingjie Fu, Bozhou Li, Linyi Li, Wentao Zhang 等ISSTA 2025 · 3 次引用
- Do Large Language Models Pay Similar Attention Like Human Programmers When Generating Code?Bonan Kou, Shengmai Chen, Zhijie Wang, Lei Ma 等FSE 2024 · 8 次引用
