RefBERT:一种用于自动重命名重构的两阶段预训练框架
RefBERT: A Two-Stage Pre-trained Framework for Automatic Rename Refactoring
AI总结:
本文提出两阶段预训练框架RefBERT,通过先预测子词元数量再生成子词元,并结合受限掩码语言建模、对比学习与词元袋损失,实现更准确的变量名自动重命名重构。
摘要:
重构是软件演化中提高源代码质量和可维护性不可或缺的实践。重命名重构是最常执行的重构类型,当标识符命名不佳时,它会为标识符建议一个新名称以增强可读性。然而,大多数现有工作仅识别两个源代码版本之间的重命名活动,很少有工作关注如何建议新名称。在本文中,我们研究变量名的自动重命名重构,这被认为比其他重命名重构活动更具挑战性。我们首先指出重命名重构与各种流行的学习范式之间的联系,以及重命名重构与自然语言处理中一般文本生成之间的差异。基于我们的观察,我们提出了 RefBERT,一种用于变量名重命名重构的两阶段预训练框架。RefBERT 首先预测新名称中子词元(sub-token)的数量,然后相应地生成子词元。多种技术,包括受限掩码语言建模、对比学习和词元袋(bag-of-tokens)损失,被整合到 RefBERT 中,使其适用于变量名的自动重命名重构。通过在我们构建的重构数据集上进行大量实验,我们表明 RefBERT 生成的变量名比现有方法生成的变量名更准确、更有意义。
英文摘要:
Refactoring is an indispensable practice of improving the quality and maintainability of source code in software evolution. Rename refactoring is the most frequently performed refactoring that suggests a new name for an identifier to enhance readability when the identifier is poorly named. However, most existing works only identify renaming activities between two versions of source code, while few works express concern about how to suggest a new name. In this paper, we study automatic rename refactoring on variable names, which is considered more challenging than other rename refactoring activities. We first point out the connections between rename refactoring and various prevalent learning paradigms and the difference between rename refactoring and general text generation in natural language processing. Based on our observations, we propose RefBERT, a two-stage pre-trained framework for rename refactoring on variable names. RefBERT first predicts the number of sub-tokens in the new name and then generates sub-tokens accordingly. Several techniques, including constrained masked language modeling, contrastive learning, and the bag-of-tokens loss, are incorporated into RefBERT to tailor it for automatic rename refactoring on variable names. Through extensive experiments on our constructed refactoring datasets, we show that the generated variable names of RefBERT are more accurate and meaningful than those produced by the existing method.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。