arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2412.01333cs.SE
收藏

大型语言模型能否作为代码摘要的评估器?

Can Large Language Models Serve as Evaluators for Code Summarization?

Yang Wu, Yao Wan, Zhaoyang Chu, Wenting Zhao, Ye Liu, Hongyu Zhang, Xuanhua Shi, Philip S. Yu

AI总结:

本文提出基于角色扮演提示的 CODERPE,让 LLM 从多角色、多维度评估代码摘要,并验证其与人工判断的相关性显著优于 BERTScore。

摘要:

代码摘要通过将代码片段转换为自然语言描述,促进程序理解和软件维护。多年来,研究人员已为该任务开发了大量方法,但一个关键挑战仍然存在:有效评估生成摘要的质量。人工评估虽然能够有效判断代码摘要质量,却耗费人力且难以扩展。常用的自动指标,如 BLEU、ROUGE-L、METEOR 和 BERTScore,往往无法与人类判断紧密一致。本文探索大型语言模型(LLM)在评估代码摘要方面的潜力。我们提出 CODERPE(Role-Player for Code Summarization Evaluation,代码摘要评估角色扮演器),这是一种利用角色扮演提示来评估生成摘要质量的新方法。具体而言,我们提示 LLM 智能体扮演多种角色,例如代码审查者、代码作者、代码编辑和系统分析师。每个角色从连贯性、一致性、流畅性和相关性等关键维度评估代码摘要质量。我们还通过采用多种提示策略进一步探索 LLM 作为评估器的鲁棒性,包括思维链推理、上下文学习和定制评分表设计。结果表明,LLM 能够有效充当代码摘要方法的评估器。值得注意的是,我们基于 LLM 的评估器 CODERPE 与人工评估的 Spearman 相关性达到 81.59%,比现有 BERTScore 指标高出 17.27%。

英文摘要:

Code summarization facilitates program comprehension and software maintenance by converting code snippets into natural-language descriptions. Over the years, numerous methods have been developed for this task, but a key challenge remains: effectively evaluating the quality of generated summaries. While human evaluation is effective for assessing code summary quality, it is labor-intensive and difficult to scale. Commonly used automatic metrics, such as BLEU, ROUGE-L, METEOR, and BERTScore, often fail to align closely with human judgments. In this paper, we explore the potential of Large Language Models (LLMs) for evaluating code summarization. We propose CODERPE (Role-Player for Code Summarization Evaluation), a novel method that leverages role-player prompting to assess the quality of generated summaries. Specifically, we prompt an LLM agent to play diverse roles, such as code reviewer, code author, code editor, and system analyst. Each role evaluates the quality of code summaries across key dimensions, including coherence, consistency, fluency, and relevance. We further explore the robustness of LLMs as evaluators by employing various prompting strategies, including chain-of-thought reasoning, in-context learning, and tailored rating form designs. The results demonstrate that LLMs serve as effective evaluators for code summarization methods. Notably, our LLM-based evaluator, CODERPE , achieves an 81.59% Spearman correlation with human evaluations, outperforming the existing BERTScore metric by 17.27%.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑