arXiv:2505.16222cs.CLcs.SE2025-05Conference of the …被引 24

LLM评估代码时易受变量名、格式等表面差异干扰,影响评分公平性。

Don't Judge Code by Its Cover: Exploring Biases in LLM Judges for Code Evaluation

  • 测试六类表面差异对代码评估的影响,发现偏差普遍存在。
  • 五种语言下多个LLM均出现评分偏高或偏低现象。
  • 即使先生成测试用例,仍难避免偏差,需更稳健的评估方法。

随着大型语言模型(LLMs)被广泛用作代码评估工具,其在无需参考实现的情况下评估生成代码正确性的能力日益重要。然而,这一方法面临一个关键问题:LLM能否公平、可靠地评估语义等价但表面形式不同的代码?功能正确的代码常因变量名、注释或格式不同而存在差异,这些不应影响其正确性。我们首次系统研究了代码评估中的六类潜在偏差,并在五种编程语言和多个LLM上实证发现,所有测试的LLM裁判均存在正向与负向偏差,导致评分被夸大或不公平降低。此外,即便在评分前提示生成测试用例,偏差依然显著,凸显出构建更鲁棒代码评估方法的迫切需求。

原文摘要 · Abstract (English)

With the growing use of large language models(LLMs) as evaluators, their application has expanded to code evaluation tasks, where they assess the correctness of generated code without relying on reference implementations. While this offers scalability and flexibility, it also raises a critical, unresolved question: Can LLM judges fairly and robustly evaluate semantically equivalent code with superficial variations? Functionally correct code often exhibits variations-such as differences in variable names, comments, or formatting-that should not influence its correctness. Yet, whether LLM judges can reliably handle these variations remains unclear. We present the first comprehensive study of this issue, defining six types of potential bias in code evaluation and revealing their systematic impact on LLM judges. Across five programming languages and multiple LLMs, we empirically demonstrate that all tested LLM judges are susceptible to both positive and negative biases, resulting in inflated or unfairly low scores. Moreover, we observe that LLM judges remain vulnerable to these biases even when prompted to generate test cases before scoring, highlighting the need for more robust code evaluation methods.

代码评估大模型偏差分析

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。