NatGen: generative pre-training by “naturalizing” source code
Authors:
Top Cited Papers
Open Access
- 7 November 2022
- conference paper
- Published by Association for Computing Machinery (ACM)
- p. 18-30
Abstract
Pre-trained Generative Language models (e.g., PLBART, CodeT5, SPT-Code) for source code yielded strong results on several tasks in the past few years, including code generation and translation. These models have adopted varying pre-training objectives to learn statistics of code construction from very large-scale corpora in a self-supervised fashion; the success of pre-trained models largely hinges on these pre-training objectives. This paper proposes a new pre-training objective, “Naturalizing” of source code, exploiting code’s bimodal, dual-channel (formal & natural channels) nature. Unlike natural language, code’s bimodal, dual-channel nature allows us to generate semantically equivalent code at scale. We introduce six classes of semantic preserving transformations to introduce unnatural forms of code, and then force our model to produce more natural original programs written by developers. Learning to generate equivalent, but more natural code, at scale, over large corpora of open-source code, without explicit manual supervision, helps the model learn to both ingest & generate code. We fine-tune our model in three generative Software Engineering tasks: code generation, code translation, and code refinement with limited human-curated labeled data and achieve state-of-the-art performance rivaling CodeT5. We show that our pre-trained model is especially competitive at zero-shot and few-shot learning, and better at learning code properties (e.g., syntax, data flow)Keywords
All Related Versions
Funding Information
- National Science Foundation (CCF-2107405, SHF-1845893, SHF-1414172, SHF-2107592, IIS-2221943)
- IBM (Faculty Award)
- UC Davis College of Engineering (Dean?s Distinguished Fellowship)
This publication has 31 references indexed in Scilit:
- Recovering clear, natural identifiers from obfuscated JS names2017
- Are deep neural networks the best choice for modeling source code?2017
- Overcoming catastrophic forgetting in neural networksProceedings of the National Academy of Sciences of the United States of America, 2017
- Deep learning code fragments for code clone detection2016
- On the "naturalness" of buggy code2016
- On the naturalness of softwareCommunications of the ACM, 2016
- Summarizing Source Code using a Neural Attention Model2016
- Suggesting accurate method and class names2015
- Code completion with statistical language modelsACM SIGPLAN Notices, 2014
- On the naturalness of software2012