How Important are Good Method Names in Neural Code Generation? A Model Robustness Perspective

Author:

Yang Guang1,Zhou Yu1,Yang Wenhua1,Yue Tao2,Chen Xiang3,Chen Taolue4

Affiliation:

1. Nanjing University of Aeronautics and Astronautics, China

2. Beihang University, China

3. Nantong University, China

4. Birkbeck, University of London, UK

Abstract

Pre-trained code generation models (PCGMs) have been widely applied in neural code generation which can generate executable code from functional descriptions in natural languages, possibly together with signatures. Despite substantial performance improvement of PCGMs, the role of method names in neural code generation has not been thoroughly investigated. In this paper, we study and demonstrate the potential of benefiting from method names to enhance the performance of PCGMs, from a model robustness perspective. Specifically, we propose a novel approach, namedRADAR(neuRAl coDe generAtorRobustifier).RADARconsists of two components:RADAR-Attack andRADAR-Defense. The former attacks a PCGM by generating adversarial method names as part of the input, which are semantic and visual similar to the original input, but may trick the PCGM to generate completely unrelated code snippets. As a countermeasure to such attacks,RADAR-Defense synthesizes a new method name from the functional description and supplies it to the PCGM. Evaluation results show thatRADAR-Attack can reduce the CodeBLEU of generated code by 19.72% to 38.74% in three state-of-the-art PCGMs (i.e., CodeGPT, PLBART, and CodeT5) in the fine-tuning code generation task, and reduce the Pass@1 of generated code by 32.28% to 44.42% in three state-of-the-art PCGMs (i.e., Replit, CodeGen, and CodeT5+) in the zero-shot code generation task. Moreover,RADAR-Defense is able to reinstate the performance of PCGMs with synthesized method names. These results highlight the importance of good method names in neural code generation and implicate the benefits of studying model robustness in software engineering.

Publisher

Association for Computing Machinery (ACM)

Subject

Software

Reference104 articles.

1. Rajas Agashe , Srinivasan Iyer , and Luke Zettlemoyer . 2019 . JuICe: A Large Scale Distantly Supervised Dataset for Open Domain Context-based Code Generation . In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP). 5436–5446 . Rajas Agashe, Srinivasan Iyer, and Luke Zettlemoyer. 2019. JuICe: A Large Scale Distantly Supervised Dataset for Open Domain Context-based Code Generation. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP). 5436–5446.

2. Unified Pre-training for Program Understanding and Generation

3. An information-theoretic perspective of tf–idf measures

4. A Survey of Machine Learning for Big Code and Naturalness

5. Moustafa Alzantot , Yash Sharma , Ahmed Elgohary , Bo-Jhang Ho , Mani Srivastava , and Kai-Wei Chang . 2018 . Generating Natural Language Adversarial Examples . In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing. 2890–2896 . Moustafa Alzantot, Yash Sharma, Ahmed Elgohary, Bo-Jhang Ho, Mani Srivastava, and Kai-Wei Chang. 2018. Generating Natural Language Adversarial Examples. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing. 2890–2896.

Cited by 2 articles. 订阅此论文施引文献 订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献

1. A survey on robustness attacks for deep code models;Automated Software Engineering;2024-08-09

2. Robustness-Enhanced Assertion Generation Method Based on Code Mutation and Attack Defense;Lecture Notes of the Institute for Computer Sciences, Social Informatics and Telecommunications Engineering;2024

同舟云学术

1.学者识别学者识别

2.学术分析学术分析

3.人才评估人才评估

"同舟云学术"是以全球学者为主线,采集、加工和组织学术论文而形成的新型学术文献查询和分析系统,可以对全球学者进行文献检索和人才价值评估。用户可以通过关注某些学科领域的顶尖人物而持续追踪该领域的学科进展和研究前沿。经过近期的数据扩容,当前同舟云学术共收录了国内外主流学术期刊6万余种,收集的期刊论文及会议论文总量共计约1.5亿篇,并以每天添加12000余篇中外论文的速度递增。我们也可以为用户提供个性化、定制化的学者数据。欢迎来电咨询!咨询电话:010-8811{复制后删除}0370

www.globalauthorid.com

TOP

Copyright © 2019-2024 北京同舟云网络信息技术有限公司
京公网安备11010802033243号  京ICP备18003416号-3