paperbot · PL 论文追踪

全部论文 待读 收藏

P2 IdBench: Evaluating Semantic Representations of Identifier Names in Source Code

IdBench:评估源代码中标识符名称的语义表示
ICSE 2021 IEEE/ACM 43rd International Conference on Software Engineering (ICSE)2021匹配度 3/10 · 论文聚焦标识符语义表示的基准构建,属于PL与ML交叉,但与用户核心关注的静态分析(尤其是LLM/Agent结合、浮点程序分析、贝叶斯程序分析)无直接关联;虽涉及名称分析,但未触及用户提出的具体研究问题。引用 37 inbox
Yaza Wainakh, Moiz Rauf, Michael Pradel
crossref: 2026-09-12dblp: 2026-09-12

AI 速览

一句话:提出首个基于500名开发者评分的标识符语义表示基准,发现现有嵌入能表示语义相关性但难以表示语义相似性。

标识符名称蕴含代码意图的语义信息,基于名称的程序分析(如缺陷检测、类型预测、可读性改进)依赖标识符的语义表示(如学习嵌入)。但这些表示在多大程度上符合开发者感知的语义相关性与相似性尚不清楚。本文提出 IdBench:首个以500名开发者对数千标识符对的评分为真值的基准,并评估自然语言嵌入、代码专用嵌入及词汇字符串距离函数。结果显示,各技术效果差异显著:最佳嵌入能表示语义相关性,却无法令人满意地表示语义相似性,甚至将含义相反的标识符判为相似,可能导致重构工具等严重错误。不同技术具有互补性,作者据此提出集成模型,明显优于最佳单一表示。

问题
标识符语义表示被广泛用于基于名称的程序分析,但其与开发者感知的语义相关性和相似性是否一致尚不清楚。
方法
构建 IdBench 基准,以500名开发者的数千条评分为真值,系统评估自然语言嵌入、代码专用嵌入和词汇字符串距离函数。
评估
通过开发者评分真值比较不同表示的效果,分析其互补性,并提出集成模型;实验表明集成模型明显优于最佳单一语义表示。
原文摘要(Abstract)

Identifier names convey useful information about the intended semantics of code. Name-based program analyses use this information, e.g., to detect bugs, to predict types, and to improve the readability of code. At the core of name-based analyses are semantic representations of identifiers, e.g., in the form of learned embeddings. The high-level goal of such a representation is to encode whether two identifiers, e.g., len and size, are semantically similar. Unfortunately, it is currently unclear to what extent semantic representations match the semantic relatedness and similarity perceived by developers. This paper presents IdBench, the first benchmark for evaluating semantic representations against a ground truth created from thousands of ratings by 500 software developers. We use IdBench to study state-of-the-art embedding techniques proposed for natural language, an embedding technique specifically designed for source code, and lexical string distance functions. Our results show that the effectiveness of semantic representations varies significantly and that the best available embeddings successfully represent semantic relatedness. On the downside, no existing technique provides a satisfactory representation of semantic similarities, among other reasons because identifiers with opposing meanings are incorrectly considered to be similar, which may lead to fatal mistakes, e.g., in a refactoring tool. Studying the strengths and weaknesses of the different techniques shows that they complement each other. As a first step toward exploiting this complementarity, we present an ensemble model that combines existing techniques and that clearly outperforms the best available semantic representation.

链接与引用

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

BibTeX
@inproceedings{WainakhRP21,
  title = {IdBench: Evaluating Semantic Representations of Identifier Names in Source Code},
  author = {Yaza Wainakh and Moiz Rauf and Michael Pradel},
  booktitle = {ICSE},
  year = {2021},
  doi = {10.1109/icse43902.2021.00059}
}