Skip to main content
QUICK REVIEW

[Paper Review] On the Robustness of Code Generation Techniques: An Empirical Study on GitHub Copilot

Antonio Mastropaolo, Luca Pascarella|arXiv (Cornell University)|Feb 1, 2023
Software Engineering ResearchComputer Science7 citations
TL;DR

The paper empirically studies how semantically equivalent natural language descriptions affect GitHub Copilot’s Java method generation, finding that input paraphrasing changes predictions in about 46% of cases and can reduce correctness in about 28% of scenarios.

ABSTRACT

Software engineering research has always being concerned with the improvement of code completion approaches, which suggest the next tokens a developer will likely type while coding. The release of GitHub Copilot constitutes a big step forward, also because of its unprecedented ability to automatically generate even entire functions from their natural language description. While the usefulness of Copilot is evident, it is still unclear to what extent it is robust. Specifically, we do not know the extent to which semantic-preserving changes in the natural language description provided to the model have an effect on the generated code function. In this paper we present an empirical study in which we aim at understanding whether different but semantically equivalent natural language descriptions result in the same recommended function. A negative answer would pose questions on the robustness of deep learning (DL)-based code generators since it would imply that developers using different wordings to describe the same code would obtain different recommendations. We asked Copilot to automatically generate 892 Java methods starting from their original Javadoc description. Then, we generated different semantically equivalent descriptions for each method both manually and automatically, and we analyzed the extent to which predictions generated by Copilot changed. Our results show that modifying the description results in different code recommendations in ~46% of cases. Also, differences in the semantically equivalent descriptions might impact the correctness of the generated code ~28%.

Motivation & Objective

  • Evaluate whether automated paraphrasing can test the robustness of DL-based code generators like Copilot.
  • Quantify to what extent Copilot's generated code changes when given semantically equivalent descriptions.
  • Assess how paraphrase-induced changes affect prediction correctness using tests and similarity metrics.
  • Provide replication data and a workflow to automate Copilot interactions for robustness studies.

Proposed method

  • Assemble a dataset of 892 Java methods with associated Javadoc first sentences as natural language descriptions.
  • Generate semantically equivalent paraphrases using PEGASUS and Translation Pivoting, plus manual paraphrases.
  • Automate Copilot interactions to generate method bodies from original and paraphrased descriptions under two context settings (full and partial context).
  • Evaluate predictions with test results, CodeBLEU, and token-level Levenshtein distance to measure similarity and correctness.
  • Analyze how paraphrase quality and input context influence Copilot outputs and correctness.

Experimental results

Research questions

  • RQ1RQ0: Can automated paraphrasing techniques test the robustness of DL-based code generators?
  • RQ2RQ1: To what extent is Copilot’s output influenced by the input code description?
  • RQ3(Implicit) How do paraphrase-derived changes correlate with prediction similarity and test results.

Key findings

  • Paraphrasing the original description changes Copilot’s code prediction in about 46% of cases.
  • About 13% of predictions pass tests, ~15% fail or produce errors, and ~72-73% do not produce a valid method.
  • PEGASUS generated 666 equivalent paraphrases (75%), TP generated 688 equivalent paraphrases (77%).
  • Considering only equivalent paraphrases, Copilot’s outputs remain similar on average but can diverge significantly in CodeBLEU and Levenshtein metrics.
  • In 28% of test-passing cases, the paraphrase leads to a different prediction that would not pass the same test, indicating robustness issues."
  • Some paraphrase-induced predictions pass tests yet differ semantically from the target implementation, highlighting potential gaps in test-based evaluation.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.