一句话:发现并分析 LLM 判断代码是否满足自然语言规约时存在系统性误判,并提出缓解提示策略。
该论文研究大语言模型能否可靠判断代码实现是否满足自然语言任务规约这一问题。作者在广泛使用的基准上采用统一提示让 LLM 判定代码正确性,结果发现 LLM 经常将正确实现误判为“不满足需求”或“存在潜在缺陷”,呈现系统性失败。更出乎意料的是,引入解释与修正建议等更复杂的提示工程反而提高了误判率,暴露了 LLM 作为代码审查助手的关键可靠性问题。作者进一步分析了误判的根因,并提出两种改进的提示策略以缓解该问题。该工作首次揭示 LLM 在代码与需求匹配上的未被认识到的局限,为自动化代码审查和任务导向智能体场景提供了新的洞见与实践指导。
Large language models (LLMs) have become essential tools in software development, widely used for requirements engineering, code generation and review tasks. Software engineers increasingly rely on LLMs to assess whether system code implementation satisfy task requirements, thereby enhancing code robustness and accuracy. However, it remains unclear whether LLMs can reliably determine whether the code complies fully with the given task descriptions, which is usually natural language specifications. In this paper, we uncover a systematic failure of LLMs in evaluating whether code aligns with natural language requirements. Specifically, using widely adopted benchmarks, we employ unified prompts to judge code correctness. Our results reveal that LLMs frequently misclassify correct code implementations as either "not satisfying requirements" or containing potential defects. Surprisingly, more complex prompting, especially when leveraging prompt engineering techniques involving explanations and proposed corrections, leads to higher misjudgment rate, which highlights the critical reliability issues in using LLMs as code review assistants. We further analyze the root causes of these misjudgments, and propose two improved prompting strategies for mitigation. For the first time, our findings reveals unrecognized limitations in LLMs to match code with requirements. We also offer novel insights and practical guidance for effective use of LLMs in automated code review and task-oriented agent scenarios.
DOI 原文 ·
@inproceedings{paperbot9471,
title = {Uncovering Systematic Failures of LLMs in Verifying Code Against Natural Language Specifications},
author = {Haolin Jin and Huaming Chen},
booktitle = {ASE},
year = {2025},
doi = {10.1109/ase63991.2025.00323}
}