paperbot · PL 论文追踪

全部论文 待读 收藏

P2 CrystalBLEU: Precisely and Efficiently Measuring the Similarity of Code

CrystalBLEU:精确且高效地度量代码相似性
ASE Proceedings of the 37th IEEE/ACM International Conference on Automated Software Engineering2022匹配度 2/10 · 论文提出面向代码相似度的 BLEU 变体评估指标,属于程序语言与机器学习的交叉,但核心是代码预测的评估度量,而非静态分析、Agentic 程序分析、浮点程序分析或贝叶斯程序分析。它与用户当前追踪的 PL↔AI 具体问题关联较弱,仅可能作为代码生成/Agent 评估的边角工具。引用 39 inbox
Aryaz Eghbali, Michael Pradel
crossref: 2026-09-12

AI 速览

一句话:提出 CrystalBLEU,通过降低平凡共享 n-gram 噪声,更精确高效地评估代码预测的相似性。

近年来代码预测任务(如代码补全、迁移、修复和自然语言到代码翻译)广泛使用 BLEU 这类 n-gram 指标进行自动评估。然而,编程语言的语法冗长和编码惯例导致不相关代码也共享大量 n-gram,削弱了 BLEU 区分真正相似代码的能力。本文提出 CrystalBLEU,通过降低这些平凡共享 n-gram 带来的噪声,同时保留 BLEU 语言无关、可处理不完整或部分错误代码且高效等优点,从而更精确高效地度量代码相似性。作者在两个已有数据集和一个新构建的语义等价程序标注数据集上评估,结果显示 CrystalBLEU 区分相似与不相似代码的效果比原始 BLEU 及先前面向代码的 BLEU 变体高 1.9–4.5 倍。

问题
BLEU 等 n-gram 指标用于代码预测评估时,因编程语言语法冗长、编码惯例导致大量平凡共享 n-gram,难以区分真正相似与仅同语言的代码。
方法
提出 CrystalBLEU,在 BLEU 基础上降低平凡共享 n-gram 的噪声,同时保留语言无关、支持不完整或部分错误代码以及高效等性质。
评估
在两个已有数据集和一个新标注的语义等价程序数据集上评估,区分相似与不相似代码的效果比原始 BLEU 和先前代码 BLEU 变体提升 1.9–4.5 倍。
原文摘要(Abstract)

Recent years have brought a surge of work on predicting pieces of source code, e.g., for code completion, code migration, program repair, or translating natural language into code. All this work faces the challenge of evaluating the quality of a prediction w.r.t. some oracle, typically in the form of a reference solution. A common evaluation metric is the BLEU score, an n-gram-based metric originally proposed for evaluating natural language translation, but adopted in software engineering because it can be easily computed on any programming language and enables automated evaluation at scale. However, a key difference between natural and programming languages is that in the latter, completely unrelated pieces of code may have many common n-grams simply because of the syntactic verbosity and coding conventions of programming languages. We observe that these trivially shared n-grams hamper the ability of the metric to distinguish between truly similar code examples and code examples that are merely written in the same language. This paper presents CrystalBLEU, an evaluation metric based on BLEU, that allows for precisely and efficiently measuring the similarity of code. Our metric preserves the desirable properties of BLEU, such as being language-agnostic, able to handle incomplete or partially incorrect code, and efficient, while reducing the noise caused by trivially shared n-grams. We evaluate CrystalBLEU on two datasets from prior work and on a new, labeled dataset of semantically equivalent programs. Our results show that CrystalBLEU can distinguish similar from dissimilar code examples 1.9–4.5 times more effectively, when compared to the original BLEU score and a previously proposed variant of BLEU for code.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@inproceedings{paperbot7179,
  title = {CrystalBLEU: Precisely and Efficiently Measuring the Similarity of Code},
  author = {Aryaz Eghbali and Michael Pradel},
  booktitle = {ASE},
  year = {2022},
  doi = {10.1145/3551349.3556903}
}