arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2106.13928cs.SEcs.AIcs.PL
收藏

使用接受和排序模型降低代码完成的隐藏成本

Toward Less Hidden Cost of Code Completion with Acceptance and Ranking Models

Huawei Technologies Co., Ltd(华为技术有限公司)

Jingxuan Li, Rui Huang, Wei Li, Kai Yao, Weiguo Tan

摘要:

代码完成被软件开发人员广泛使用,以提供给定部分编写的代码片段的编码建议。除了传统的代码完成方法,它只支持在最小的位置,最近的研究表明,能够提供更长的代码完成在更灵活的位置。然而,这种频繁触发且较长的完成结果降低了整体精度,因为它们生成更多无效结果。此外,不同的研究大多互不相容。因此,开发一个集成框架是至关重要的,该框架可以将多个模型的结果结合起来,以吸取每个模型的优点并弥补其缺陷。本文进行了一个编码模拟,从代码上下文和不同的代码完成模型收集数据,然后将数据应用于两个任务。首先,我们引入了一个验收模型,它可以动态地控制是否显示完成的结果给开发人员。它使用模拟特征来预测这些模型的输出中是否存在正确的结果。我们的最佳模型将假阳性完成的百分比从55.09%降低到17.44%。其次,我们设计了一个融合排序方案,可以自动识别的优先级完成结果和排序的候选人从多个代码完成模型。该方案灵活地处理各种模型,而不考虑其完成结果的类型或长度。我们将这个排名方案与两个频率模型和一个GPT-2风格的语言模型以及接受模型相结合,使TOP1和TOP5的准确率分别提高了27.80%和37.64%。此外,我们提出了一个新的代码完成评估指标,效益成本比(BCR),考虑到节省成本的好处和完成列表浏览的隐藏成本,这是更接近真实的编码体验场景。

英文摘要:

Code completion is widely used by software developers to provide coding suggestions given a partially written code snippet. Apart from the traditional code completion methods, which only support single token completion at minimal positions, recent studies show the ability to provide longer code completion at more flexible positions. However, such frequently triggered and longer completion results reduce the overall precision as they generate more invalid results. Moreover, different studies are mostly incompatible with each other. Thus, it is vital to develop an ensemble framework that can combine results from multiple models to draw merits and offset defects of each model. This paper conducts a coding simulation to collect data from code context and different code completion models and then apply the data in two tasks. First, we introduce an acceptance model which can dynamically control whether to display completion results to the developer. It uses simulation features to predict whether correct results exist in the output of these models. Our best model reduces the percentage of false-positive completion from 55.09% to 17.44%. Second, we design a fusion ranking scheme that can automatically identify the priority of the completion results and reorder the candidates from multiple code completion models. This scheme is flexible in dealing with various models, regardless of the type or the length of their completion results. We integrate this ranking scheme with two frequency models and a GPT-2 styled language model, along with the acceptance model to yield 27.80% and 37.64% increase in TOP1 and TOP5 accuracy, respectively. In addition, we propose a new code completion evaluation metric, Benefit-Cost Ratio(BCR), taking into account the benefit of keystrokes saving and hidden cost of completion list browsing, which is closer to real coder experience scenario.

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

↑