Lune

EMNLP2023Top-tier venue

CodeBERTScore: Evaluating Code Generation with Pretrained Models of Code

Shuyan Zhou, Uri Alon, Sumit Agarwal, Graham Neubig

Abstract

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

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

21 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • OctoPack: Instruction Tuning Code Large Language Models cites InCoder: A Generative Model for Code Infilling and Synthesis
  • OctoPack: Instruction Tuning Code Large Language Models cites DS-1000: A Natural and Reliable Benchmark for Data Science Code Generation
  • Beyond Accuracy: Evaluating Self-Consistency of Code Large Language Models with IdentityChain cites BERTScore: Evaluating Text Generation with BERT
  • InCoder: A Generative Model for Code Infilling and Synthesis cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • Can LLMs Replace Human Evaluators? An Empirical Study of LLM-as-a-Judge in Software Engineering cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • Can LLMs Replace Human Evaluators? An Empirical Study of LLM-as-a-Judge in Software Engineering cites BERTScore: Evaluating Text Generation with BERT
  • CodeJudge: Evaluating Code Generation with Large Language Models cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • CodeJudge: Evaluating Code Generation with Large Language Models cites BERTScore: Evaluating Text Generation with BERT
  • DS-1000: A Natural and Reliable Benchmark for Data Science Code Generation cites InCoder: A Generative Model for Code Infilling and Synthesis
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers21

  1. OctoPack: Instruction Tuning Code Large Language ModelsNiklas Muennighoff, Qian Liu, Armel Randy Zebaze, Qinkai Zheng et al.ICLR 2024 · 203 citations
  2. Beyond Accuracy: Evaluating Self-Consistency of Code Large Language Models with IdentityChainMarcus J. Min, Yangruibo Ding, Luca Buratti, Saurabh Pujar et al.ICLR 2024 · 39 citations
  3. CodeRosetta: Pushing the Boundaries of Unsupervised Code Translation for Parallel ProgrammingAli TehraniJamsaz, Arijit Bhattacharjee, Le Chen, Nesreen K. Ahmed et al.NeurIPS 2024 · 36 citations
  4. Can LLMs Replace Human Evaluators? An Empirical Study of LLM-as-a-Judge in Software EngineeringRuiqi Wang, Jiyu Guo, Cuiyun Gao, Guodong Fan et al.ISSTA 2025 · 27 citations
  5. CodeJudge: Evaluating Code Generation with Large Language ModelsWeixi Tong, Tianyi ZhangEMNLP 2024 · 25 citations

Builds on11

  1. BERTScore: Evaluating Text Generation with BERTTianyi Zhang, Varsha Kishore, Felix Wu, Kilian Q. Weinberger et al.ICLR 2020 · 8,443 citations
  2. CodeBERT: A Pre-Trained Model for Programming and Natural LanguagesZhangyin Feng, Daya Guo, Duyu Tang, Nan Duan et al.EMNLP Findings 2020 · 2,828 citations
  3. DS-1000: A Natural and Reliable Benchmark for Data Science Code GenerationYuhang Lai, Chengxi Li, Yiming Wang, Tianyi Zhang et al.ICML 2023 · 504 citations
  4. GLM-130B: An Open Bilingual Pre-trained ModelAohan Zeng, Xiao Liu, Zhengxiao Du, Zihan Wang et al.ICLR 2023 · 295 citations
  5. InCoder: A Generative Model for Code Infilling and SynthesisDaniel Fried, Armen Aghajanyan, Jessy Lin, Sida Wang et al.ICLR 2023 · 140 citations

Related papers

  1. MATCH: Task-Driven Code Evaluation through Contrastive LearningMarah Ghoummaid, Vladimir Tchuiev, Ofek Glick, Michal Moshkovitz et al.EMNLP Findings 2025
  2. What Do They Capture? - A Structural Analysis of Pre-Trained Language Models for Source CodeYao Wan, Wei Zhao, Hongyu Zhang, Yulei Sui et al.ICSE 2022 · 66 citations
  3. Large Language Models Meet NL2Code: A SurveyDaoguang Zan, Bei Chen, Fengji Zhang, Dianjie Lu et al.ACL 2023 · 104 citations
  4. Calibration of Large Language Models on Code SummarizationYuvraj Virk, Premkumar T. Devanbu, Toufique AhmedFSE 2025 · 5 citations
  5. CoderEval: A Benchmark of Pragmatic Code Generation with Generative Pre-trained ModelsHao Yu, Bo Shen, Dezhi Ran, Jiaxin Zhang et al.ICSE 2024 · 107 citations
Dusk over the sea between two cliffs drawn in fine vertical lines