[论文解读] Are LLMs Reliable Code Reviewers? Systematic Overcorrection in Requirement Conformance Judgement
研究表明 LLMs 在对比自然语言要求判断正确代码时经常判断错误,使用更详细的提示会增加误判;提出一种修复引导的验证方法来减轻这一偏差。
Large language models (LLMs) have become essential tools in software development, widely used for requirements engineering, code generation and review tasks. Software engineers often rely on LLMs to verify if code implementation satisfy task requirements, thereby ensuring code robustness and accuracy. However, it remains unclear whether LLMs can reliably determine code against the given task descriptions, which is usually in a form of natural language specifications. In this paper, we uncover a systematic failure of LLMs in matching code to natural language requirements. Specifically, with widely adopted benchmarks and unified prompts design, we demonstrate that LLMs frequently misclassify correct code implementation as non-compliant or defective. Surprisingly, we find that more detailed prompt design, particularly with those requiring explanations and proposed corrections, leads to higher misjudgment rates, highlighting critical reliability issues for LLM-based code assistants. We further analyze the mechanisms driving these failures and evaluate the reliability of rationale-required judgments. Building on these findings, we propose a Fix-guided Verification Filter that treats the model proposed fix as executable counterfactual evidence, and validates the original and revised implementations using benchmark tests and spec-constrained augmented tests. Our results expose previously under-explored limitations in LLM-based code review capabilities, and provide practical guidance for integrating LLM-based reviewers with safeguards in automated review and development pipelines.
研究动机与目标
- 评估在没有测试用例的情况下,LLMs 在判断代码是否符合自然语言要求方面的可靠性。
- 评价不同提示策略对错误拒绝(false rejection)与错误接受(false acceptance)之间权衡的影响。
- 表征导致错误判断和推理的机制。
- 探索减小基于 LLM 的代码评审管道中判断偏差的缓解措施。
提出的方法
- 从 HumanEval、MBPP 和 QuixBugs 汇集成统一基准,包含对照 canonical 与 buggy 实现(超过 1400 个实例)。
- 在三种提示模式(Direct、Direct+Explain、Full)下评估五种 LLM(三种闭源、两种开源)。
- 使用混淆矩阵指标(FPR、FNR)量化每种模型-提示-基准组合的假阳性/假阴性。
- 通过外部评估者使用自洽性与容错感知评估分析推理可靠性。
- 提出并评估利用可执行反事实与规格约束增强测试的 Fix-guided Verification Filter。

实验结果
研究问题
- RQ1RQ1: LLMs 在没有测试用例的情况下,评估代码是否符合规范的可靠性如何?
- RQ2RQ2: 提示设计如何影响符合性判断以及假阴性与假阳性之间的权衡?
- RQ3RQ3: 导致假接受与假拒绝的机制是什么,包括错误类型强调与推理模式?
- RQ4RQ4: 在需要推理的提示下产生的解释有多可靠,是否与判断结果一致?
- RQ5RQ5: 缓解策略能否有效减少基于 LLM 的评审中的判断偏差?
主要发现
- LLMs 在判断正确实现时存在显著的假阴性,显示出过度纠正的偏置。
- 提示复杂性常将错误从假阴性转向假阳性,揭示了权衡而非普遍改进的局面。
- GPT-4o 在更详细的提示下表现出最强的过度纠正,而某些模型在有漏洞的代码上表现出较高的“不安全接受”倾向。
- 推理输出可能与 verdict 不一致(自洽性问题),且未必能可靠反映带容错意识的推理。
- 开源模型通常表现出更高的错误率与对提示更强的敏感性,相较于一些闭源模型。

阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。