arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2112.02650cs.SEcs.CLcs.LGcs.PL
收藏

VarCLR:基于对比学习的可变语义表示预训练

VarCLR: Variable Semantic Representation Pre-training via Contrastive Learning

Carnegie Mellon University(卡内基梅隆大学);Carnegie Mellon University Software Engineering Institute(卡内基梅隆大学软件工程研究所)

Qibin Chen, Jeremy Lacomis, Edward J. Schwartz, Graham Neubig, Bogdan Vasilescu, Claire Le Goues

摘要:

变量名对于传达预期的程序行为至关重要。基于机器学习的程序分析方法将变量名表示用于广泛的任务,诸如建议新变量名和错误检测。理想情况下,这种方法可以捕获名称之间的语义关系,而不仅仅是语法相似性,例如,平均值和平均值的名称相似。不幸的是,以前的研究发现,即使是最好的表示方法,也主要捕捉相关性(两个变量是否有联系),而不是相似性(它们是否具有相同的含义)。我们提出了一种新的学习变量名称的语义表示的方法,有效地捕捉变量的相似性,在这个更严格的意义上。我们观察到这个问题非常适合对比学习,其目的是最小化显式相似输入之间的距离,同时最大化不同输入之间的距离。这需要标记的训练数据,因此我们从GitHub编辑中构建了一个新的弱监督变量重命名数据集。我们表明,Varnish可以有效地应用复杂的,通用的语言模型,如BERT,变量名称表示,因此也相关的下游任务,如变量名称相似性搜索或拼写校正。Varnish生成的模型显著优于IdBench上的最新技术,IdBench是一个现有的基准,可以明确捕获变量相似性(与相关性不同)。最后,我们贡献了所有数据,代码和预训练模型的版本,旨在为依赖变量名称的现有或未来程序分析中使用的变量表示提供一个直接替代。

英文摘要:

Variable names are critical for conveying intended program behavior. Machine learning-based program analysis methods use variable name representations for a wide range of tasks, such as suggesting new variable names and bug detection. Ideally, such methods could capture semantic relationships between names beyond syntactic similarity, e.g., the fact that the names average and mean are similar. Unfortunately, previous work has found that even the best of previous representation approaches primarily capture relatedness (whether two variables are linked at all), rather than similarity (whether they actually have the same meaning). We propose VarCLR, a new approach for learning semantic representations of variable names that effectively captures variable similarity in this stricter sense. We observe that this problem is an excellent fit for contrastive learning, which aims to minimize the distance between explicitly similar inputs, while maximizing the distance between dissimilar inputs. This requires labeled training data, and thus we construct a novel, weakly-supervised variable renaming dataset mined from GitHub edits. We show that VarCLR enables the effective application of sophisticated, general-purpose language models like BERT, to variable name representation and thus also to related downstream tasks like variable name similarity search or spelling correction. VarCLR produces models that significantly outperform the state-of-the-art on IdBench, an existing benchmark that explicitly captures variable similarity (as distinct from relatedness). Finally, we contribute a release of all data, code, and pre-trained models, aiming to provide a drop-in replacement for variable representations used in either existing or future program analyses that rely on variable names.

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

↑