arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2402.03773cs.SE
收藏

编码版本历史上下文以改进代码表示

Encoding Version History Context for Better Code Representation

Huy Nguyen, Christoph Treude, Patanamon Thongtanunam

AI总结:

本文提出编码版本历史上下文以增强代码表示,通过ASTNN和CodeBERT实验验证其对克隆预测和分类的积极影响,并规划未来研究方向。

摘要:

随着生成源代码的AI工具呈指数级增长,理解软件变得至关重要。当开发人员理解程序时,他们可能会参考额外的上下文来查找信息,例如程序文档或历史代码版本。因此,我们认为编码这些额外的上下文信息也可能有益于深度学习的代码表示。最近的论文将上下文数据(如调用层次结构)纳入向量表示以解决程序理解问题。这促使进一步研究探索额外的上下文,如版本历史,以增强模型对程序的理解。即,从版本历史中获得的见解能够识别代码随时间演变的模式、反复出现的问题以及过去解决方案的有效性。我们的论文提供了初步证据,表明编码来自版本历史的上下文信息可能有助于预测代码克隆和执行代码分类。我们使用两个具有代表性的深度学习模型ASTNN和CodeBERT进行实验,以研究将额外上下文与不同聚合方式结合是否有利于下游任务。实验结果证实了在所有场景中将版本历史纳入源代码表示的积极影响;然而,为确保该技术表现一致,我们需要在更大的代码库上使用不同的上下文、聚合方式和模型组合进行整体调查。因此,我们提出一个研究议程,旨在探索编码额外上下文的各个方面,以改进代码表示及其在特定情境中的最优利用。

英文摘要:

With the exponential growth of AI tools that generate source code, understanding software has become crucial. When developers comprehend a program, they may refer to additional contexts to look for information, e.g. program documentation or historical code versions. Therefore, we argue that encoding this additional contextual information could also benefit code representation for deep learning. Recent papers incorporate contextual data (e.g. call hierarchy) into vector representation to address program comprehension problems. This motivates further studies to explore additional contexts, such as version history, to enhance models' understanding of programs. That is, insights from version history enable recognition of patterns in code evolution over time, recurring issues, and the effectiveness of past solutions. Our paper presents preliminary evidence of the potential benefit of encoding contextual information from the version history to predict code clones and perform code classification. We experiment with two representative deep learning models, ASTNN and CodeBERT, to investigate whether combining additional contexts with different aggregations may benefit downstream activities. The experimental result affirms the positive impact of combining version history into source code representation in all scenarios; however, to ensure the technique performs consistently, we need to conduct a holistic investigation on a larger code base using different combinations of contexts, aggregation, and models. Therefore, we propose a research agenda aimed at exploring various aspects of encoding additional context to improve code representation and its optimal utilisation in specific situations.

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

↑