用大模型评估代码质量,效果接近人类,比传统方法更准。
Can LLMs Replace Human Evaluators? An Empirical Study of LLM-as-a-Judge in Software Engineering
- 让大模型直接输出评价结果,避免依赖参考答案。
- 在代码生成和翻译任务中,相关性达81.32和68.51,接近人类水平。
- 适合需要自动化评估的软件工程研究与实践者。
近年来,大语言模型(LLMs)被广泛用于代码生成等软件工程(SE)任务,显著推动了自动化进程。然而,评估生成代码与文本的质量仍具挑战:传统通过测试的Pass@k指标需大量测试用例和配置环境,成本高;而BLEU等基于词法相似性的指标无法衡量语义质量。为此,出现了“大模型作为裁判”(LLM-as-a-judge)的新趋势,声称能更贴近人类判断且无需高质量参考答案。但其在软件工程任务中的人类对齐程度尚未被实证。本文针对代码翻译、生成与摘要三类任务,选取七种通用大模型及两种专门微调的评估模型,对大模型生成的结果进行人工评分后,由这些模型进行自动评估,并与人工评分对比。结果表明,基于输出的方法在代码翻译与生成任务中分别达到81.32和68.51的皮尔逊相关性,显著优于最佳传统指标ChrF++(分别为34.23和64.92),且评分分布更接近人类模式。
原文摘要 · Abstract (English)
Recently, large language models (LLMs) have been deployed to tackle various software engineering (SE) tasks like code generation, significantly advancing the automation of SE tasks. However, assessing the quality of these LLM-generated code and text remains challenging. The commonly used Pass@k metric necessitates extensive unit tests and configured environments, demands a high labor cost, and is not suitable for evaluating LLM-generated text. Conventional metrics like BLEU, which measure only lexical rather than semantic similarity, have also come under scrutiny. In response, a new trend has emerged to employ LLMs for automated evaluation, known as LLM-as-a-judge. These LLM-as-a-judge methods are claimed to better mimic human assessment than conventional metrics without relying on high-quality reference answers. Nevertheless, their exact human alignment in SE tasks remains unexplored. In this paper, we empirically explore LLM-as-a-judge methods for evaluating SE tasks, focusing on their alignment with human judgments. We select seven LLM-as-a-judge methods that utilize general-purpose LLMs, alongside two LLMs specifically fine-tuned for evaluation. After generating and manually scoring LLM responses on three recent SE datasets of code translation, code generation, and code summarization, we then prompt these methods to evaluate each response. Finally, we compare the scores generated by these methods with human evaluation. The results indicate that output-based methods reach the highest Pearson correlation of 81.32 and 68.51 with human scores in code translation and generation, achieving near-human evaluation, noticeably outperforming ChrF++, one of the best conventional metrics, at 34.23 and 64.92. Such output-based methods prompt LLMs to output judgments directly, and exhibit more balanced score distributions that resemble human score patterns. Finally, we provide...
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。