一句话:在统一框架下实证比较多种融合句法信息的 Transformer 变体,覆盖代码补全、函数命名与缺陷修复任务。
源码虽与自然语言格式相似,但具有严格语法结构。近年许多工作为 Transformer 引入句法信息,却因任务不同、实现各异而难以比较。本文在统一框架中复现多种捕获句法的 Transformer 修改,并在代码补全、函数命名和缺陷修复三个任务上系统评估。实验表明,Transformer 仅依赖句法信息也能做出有意义的预测;同时作者总结出将句法信息纳入模型以提升性能的最佳实践。
Initially developed for natural language processing (NLP), Transformers are now widely used for source code processing, due to the format similarity between source code and text. In contrast to natural language, source code is strictly structured, i.e., it follows the syntax of the programming language. Several recent works develop Transformer modifications for capturing syntactic information in source code. The drawback of these works is that they do not compare to each other and consider different tasks. In this work, we conduct a thorough empirical study of the capabilities of Transformers to utilize syntactic information in different tasks. We consider three tasks (code completion, function naming and bug fixing) and re-implement different syntax-capturing modifications in a unified framework. We show that Transformers are able to make meaningful predictions based purely on syntactic information and underline the best practices of taking the syntactic information into account for improving the performance of the model.