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.
翻译:由于源代码和文本的格式相似,最初为自然语言处理开发的变换器现在被广泛用于源代码处理(NLP),因为源代码和文本的格式相似。与自然语言不同,源代码的结构严格,即遵循编程语言的语法。最近的一些作品开发了变换器修改,以在源代码中捕捉合成信息。这些作品的缺点是,它们不相互比较并考虑不同的任务。在这项工作中,我们对变换器在不同任务中利用合成信息的能力进行了彻底的经验性研究。我们考虑了三个任务(代码完成、函数命名和错误修正)和在一个统一的框架中重新实施不同的拼法缩略修改。我们表明,变换器能够纯粹根据合成信息做出有意义的预测,并强调将合成信息考虑在内以改善模型性能的最佳做法。