Diet Code Is Healthy: Simplifying Programs for Pre-trained Models of Code

Zhaowei Zhang, Hongyu Zhang, Beijun Shen, Xiaodong Gu
6/29/2022
82 citations
cs.SE

Official code: 9erxis/DietCode (20 stars, Python, last commit 2023-03-06).

Abstract

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.

Show full abstract

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.

View on arXivView PDF

Code Implementations(1)

9erxis/DietCodeOfficial100%
204PythonJun 16, 20223 years ago

Similar Papers

Cite this paper

@article{zhang2022diet,
  title  = {Diet Code Is Healthy: Simplifying Programs for Pre-trained Models of Code},
  author = {Zhaowei Zhang and Hongyu Zhang and Beijun Shen and Xiaodong Gu},
  year   = {2022},
  eprint = {2206.14390},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2206.14390}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2206.14390.svg)](https://codeofpaper.com/paper/2206.14390)

Discussion