arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2302.05527cs.SEcs.LGcs.PL
收藏

CodeBERTScore:使用代码预训练模型评估代码生成

CodeBERTScore: Evaluating Code Generation with Pretrained Models of Code

Carnegie Mellon University(卡内基梅隆大学)

Shuyan Zhou, Uri Alon, Sumit Agarwal, Graham Neubig

AI总结:

本文提出代码生成评估指标 CodeBERTScore,在 BERTScore 基础上额外编码自然语言输入以建模代码与上下文一致性,并在四种语言上验证其与人类偏好和功能正确性的相关性优于现有指标。

摘要:

自从神经自然语言到代码模型(NL->Code)兴起以来,这类模型能够生成长表达式和语句,而不仅仅是单个下一个 token,可靠地评估其生成输出一直是一个主要问题。在本文中,我们提出 CodeBERTScore:一种用于代码生成的评估指标,它建立在 BERTScore(Zhang et al., 2020)之上。与 BERTScore 仅对生成的 token 进行编码不同,CodeBERTScore 还对生成代码之前的自然语言输入进行编码,从而同时建模生成代码与其给定自然语言上下文之间的一致性。我们在四种编程语言上对 CodeBERTScore 进行了广泛评估。我们发现,CodeBERTScore 与人类偏好以及与功能正确性之间的相关性高于所有现有指标。也就是说,在 CodeBERTScore 中获得更高分数的生成代码更有可能被人类偏好,并且在执行时更有可能正确运行。我们发布了五个特定语言的预训练模型,可与我们公开可用的代码一起使用。我们的特定语言模型已从 Huggingface Hub 下载超过 1,000,000 次。我们的代码和数据可在 https://github.com/neulab/code-bert-score 获取。

英文摘要:

Since the rise of neural natural-language-to-code models (NL->Code) that can generate long expressions and statements rather than a single next-token, one of the major problems has been reliably evaluating their generated output. In this paper, we propose CodeBERTScore: an evaluation metric for code generation, which builds on BERTScore (Zhang et al., 2020). Instead of encoding only the generated tokens as in BERTScore, CodeBERTScore also encodes the natural language input preceding the generated code, thus modeling the consistency between the generated code and its given natural language context as well. We perform an extensive evaluation of CodeBERTScore across four programming languages. We find that CodeBERTScore achieves a higher correlation with human preference and with functional correctness than all existing metrics. That is, generated code that receives a higher score by CodeBERTScore is more likely to be preferred by humans, as well as to function correctly when executed. We release five language-specific pretrained models to use with our publicly available code. Our language-specific models have been downloaded more than 1,000,000 times from the Huggingface Hub. Our code and data are available at https://github.com/neulab/code-bert-score

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

↑