BashExplainer:基于微调CodeBERT的检索增强Bash代码注释生成
BashExplainer: Retrieval-Augmented Bash Code Comment Generation based on Fine-tuned CodeBERT
摘要:
开发人员将shell命令用于许多任务,例如文件系统管理、网络控制和进程管理。Bash是最常用的shell之一,在Linux系统开发和维护中起着重要的作用。由于Bash代码的语言灵活性,不熟悉Bash的开发人员通常很难理解Bash代码的目的和功能。本文研究了Bash代码注释生成问题,提出了一种基于两阶段训练策略的自动生成方法BashExplainer。在第一阶段,我们训练一个Bash编码器微调CodeBERT我们构建的Bash代码语料库。在第二阶段中,我们首先从代码库中检索最相似的代码为目标代码的语义和词汇相似性的基础上。然后我们使用训练好的Bash编码器生成两个矢量表示。最后,我们通过融合层融合这两个矢量表示,并通过解码器生成代码注释。为了显示我们所提出的方法的竞争力,我们构建了一个高质量的语料库相结合的语料库共享在以前的NL2Bash研究和共享的语料库在NLC2CMD竞争。该语料库包含10,592个Bash代码和相应的注释。然后,我们从以前关于自动代码注释生成的研究中选择了十个基线,其中包括信息检索方法,深度学习方法和混合方法。
英文摘要:
Developers use shell commands for many tasks, such as file system management, network control, and process management. Bash is one of the most commonly used shells and plays an important role in Linux system development and maintenance. Due to the language flexibility of Bash code, developers who are not familiar with Bash often have difficulty understanding the purpose and functionality of Bash code. In this study, we study Bash code comment generation problem and proposed an automatic method BashExplainer based on two-stage training strategy. In the first stage, we train a Bash encoder by fine-tuning CodeBERT on our constructed Bash code corpus. In the second stage, we first retrieve the most similar code from the code repository for the target code based on semantic and lexical similarity. Then we use the trained Bash encoder to generate two vector representations. Finally, we fuse these two vector representations via the fusion layer and generate the code comment through the decoder. To show the competitiveness of our proposed method, we construct a high-quality corpus by combining the corpus shared in the previous NL2Bash study and the corpus shared in the NLC2CMD competition. This corpus contains 10,592 Bash codes and corresponding comments. Then we selected ten baselines from previous studies on automatic code comment generation, which cover information retrieval methods, deep learning methods, and hybrid methods.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。