CodeBERTScore: Evaluating Code Generation with Pretrained Models of Code

By Shuyan Zhou, Uri Alon, Sumit Agarwal, Graham Neubig. 2023

194 citations recorded by the source corpus.

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

Subfields: Artificial Intelligence, Information Systems, Materials Chemistry, Evaluation & Benchmarks, Code Generation & Program Synthesis

How researchers see this paper

The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.

In Artificial Intelligence

  1. Graham Neubig
  2. Luke S. Zettlemoyer
  3. Caiming Xiong
  4. Mohit Bansal
  5. Percy Liang
  6. Dragomir R. Radev
  7. Noah A. Smith
  8. Jianfeng Gao

In Information Systems

  1. Graham Neubig
  2. Dragomir R. Radev
  3. Tao Yu
  4. Uri Alon
  5. Daniel Fried
  6. Luke S. Zettlemoyer
  7. Caiming Xiong
  8. Ruiqi Zhong

In Materials Chemistry

  1. Graham Neubig
  2. Luke S. Zettlemoyer
  3. Caiming Xiong
  4. Shafiq R. Joty
  5. Yiming Yang
  6. Uri Alon

In Evaluation & Benchmarks

  1. Luke S. Zettlemoyer
  2. Caiming Xiong
  3. Dragomir R. Radev
  4. Shafiq R. Joty
  5. Graham Neubig
  6. Arman Cohan
  7. Aman Madaan
  8. Semih Yavuz

In Code Generation & Program Synthesis

  1. Graham Neubig
  2. Daniel Fried
  3. Luke S. Zettlemoyer
  4. Uri Alon
  5. Tao Yu
  6. Dragomir R. Radev
  7. Frank F. Xu
  8. Dzmitry Bahdanau

Citations in the corpus