ReCode: Robustness Evaluation of Code Generation Models

37758

Authors

nan

Abstract

AbstractCode generation models have achieved impressive performance. However, they tend to be brittle as slight edits to a prompt could lead to very different generations; these robustness properties, critical for user experience when deployed in real-life applications, are not well understood. Most existing works on robustness in text or code tasks have focused on classification, while robustness in generation tasks is an uncharted area and to date there is no comprehensive benchmark for robustness in code generation. In this paper, we propose ReCode, a comprehensive robustness evaluation benchmark for code generation models. We customize over 30 transformations specifically for code on docstrings, function and variable names, code syntax, and code format. They are carefully designed to be natural in real-life coding practice, preserve the original semantic meaning, and thus provide multifaceted assessments of a model’s robustness performance. With human annotators, we verified that over 90% of the perturbed prompts do not alter the semantic meaning of the original prompt. In addition, we define robustness metrics for code generation models considering the worst-case behavior under each type of perturbation, taking advantage of the fact that executing the generated code can serve as objective evaluation. We demonstrate ReCode on SOTA models using HumanEval, MBPP, as well as function completion tasks derived from them. Interesting observations include: better robustness for CodeGen over InCoder and GPT-J; models are most sensitive to syntax perturbations; more challenging robustness evaluation on MBPP over HumanEval.

Keywords

nan

Full Content

Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics Volume 1: Long Papers, pages 13818–13843 July 9-14, 2023 ©2023 Association for Computational Linguistics ReCode: Robustness Evaluation of Code Generation Models Shiqi Wang1,∗,‡ Zheng Li2,∗,† Haifeng Qian1 Chenghao Yang3,† Zijian Wang1 Mingyue Shang1 Varun Kumar1 Samson Tan4 Baishakhi Ray1 Parminder Bhatia1 Ramesh Nallapati1 Murali Krishna Ramanathan1 Dan Roth1 Bing Xiang1 1AWS AI Labs 2Cornell University 3University of Chicago 4AWS AI Research & Education {wshiqi,qianhf,zijwan,bxiang}@amazon.com zl634@cornell.edu Abstract Code generation models have achieved impres- sive performance. However, they tend to be brittle as slight edits to a prompt could lead to very different generations; these robustness properties, critical for user experience when de- ployed in real-life applications, are not well un- derstood. Most existing works on robustness in text or code tasks have focused on classification, while robustness in generation tasks is an un- charted area and to date there is no comprehen- sive benchmark for robustness in code genera- tion. In this paper, we propose ReCode, a com- prehensive robustness evaluation benchmark for code generation models. We customize over 30 transformations specifically for code on docstrings, function and variable names, code syntax, and code format. They are carefully designed to be natural in real-life coding prac- tice, preserve the original semantic meaning, and thus provide multifaceted assessments of a model’s robustness performance. With hu- man annotators, we verified that over 90% of the perturbed prompts do not alter the semantic meaning of the original prompt. In addition, we define robustness metrics for code generation models considering the worst-case behavior un- der each type of perturbation, taking advantage of the fact that executing the generated code can serve as objective evaluation. We demonstrate ReCode on SOTA models using HumanEval, MBPP, as well as function completion tasks derived from them. Interesting observations include: better robustness for CodeGen over In- Coder and GPT-J; models are most sensitive to syntax perturbations; more challenging robust- ness evaluation on MBPP over HumanEval. 1 Introduction Code generation has emerged as an important AI application. Multiple models (Nijkamp et al., 2022; ‡Corresponding author. *Equal contribution. †Work done while the authors were at Amazon. Fried et al., 2022; Wang and Komatsuzaki, 2021) have been proposed and achieved impressive perfor- mance on generating code using a natural-language description, on completing partial lines and func- tions, and even on solving complex coding-contest problems. They can offer real-life help to soft- ware engineers and enhance their productivity, and multiple commercial offerings exist today for AI- powered code generation (Chen et al., 2021). However, one important aspect, robustness of the code generation models, is commonly overlooked. Anecdotally, people know that these models are sensitive to perturbations over prompts: sometimes just an extra space in a line or a slight change to a function name would lead to completely different generations, with potentially negative impacts to usability. In Fig. 1 and Fig. 2, we show two fail- ure cases on InCoder-6B (Fried et al., 2022) and CodeGen-16B-mono (Nijkamp et al., 2022) where they …

Content truncated to 500 words

Labeled Text

AbstractCode generation models have achieved impressive performance. However, they tend to be brittle as slight edits to a prompt could lead to very different generations; these robustness properties, critical for user experience when deployed in real-life applications, are not well understood. Most existing works on robustness in text or code tasks have focused on classification, while robustness in generation tasks is an uncharted area and to date there is no comprehensive benchmark for robustness in code generation. In this paper, we propose ReCode, a comprehensive robustness evaluation benchmark for code generation models. We customize over 30 transformations specifically for code on docstrings, function and variable names, code syntax, and code format. They are carefully designed to be natural in real-life coding practice, preserve the original semantic meaning, and thus provide multifaceted assessments of a model’s robustness performance. With human annotators, we verified that over 90% of the perturbed prompts do not alter the semantic meaning of the original prompt. In addition, we define robustness metrics for code generation models considering the worst-case behavior under each type of perturbation, taking advantage of the fact that executing the generated code can serve as objective evaluation. We demonstrate ReCode on SOTA models using HumanEval, MBPP, as well as function completion tasks derived from them. Interesting observations include: better robustness for CodeGen over InCoder and GPT-J; models are most sensitive to syntax perturbations; more challenging robustness evaluation on MBPP over HumanEval.

Publication Details

Paper ID:
37758
Year:
2023
Publication:
TIPSTER
Publication Type:
conf
DOI:
nan