Pre-trained code representation models such as CodeBERT have demonstrated superior performance in a variety of software engineering tasks, yet they are often heavy in complexity, quadratically with the length of the input sequence. Our empirical analysis of CodeBERT's attention reveals that CodeBERT pays more attention to certain types of tokens and statements such as keywords and data-relevant statements. Based on these findings, we propose DietCode, which aims at lightweight leverage of large pre-trained models for source code. DietCode simplifies the input program of CodeBERT with three strategies, namely, word dropout, frequency filtering, and an attention-based strategy which selects statements and tokens that receive the most attention weights during pre-training. Hence, it gives a substantial reduction in the computational cost without hampering the model performance. Experimental results on two downstream tasks show that DietCodeBERT provides comparable results to CodeBERT with 40% less computational cost in fine-tuning and testing.
翻译:诸如 DCBERT 等经过事先训练的代码代表模型在各种软件工程任务中表现出了优异的性能,然而,它们往往十分复杂,随输入序列的长度而四分五裂。我们对编码BERT 注意的经验分析表明,编码BERT 更多地注意某些类型的符号和声明,例如关键词和数据相关说明。根据这些调查结果,我们提议了MetCode,其目的是利用经过预先训练的大型源代码模型的轻量级杠杆。DiefCode 简化了编码BERT 输入程序,采用三种战略,即单词退出、频率过滤和基于关注的战略,选择在培训前最受重视的语句和符号。因此,它大大降低了计算成本,而不妨碍模型的性能。关于两项下游任务的实验结果表明,DieCodeBERT 向编码提供可比的结果,在微调和测试方面计算成本降低了40%。