Skip to main content
QUICK REVIEW

[Paper Review] Exploring the Robustness of Large Language Models for Solving Programming Problems

Atsushi Shirafuji, Yutaka Watanobe|arXiv (Cornell University)|Jun 26, 2023
Software Engineering ResearchComputer Science5 citations
TL;DR

This paper evaluates the robustness of large language models (LLMs) like Codex, CodeGen, InstructGPT, and ChatGPT in solving introductory programming problems by modifying problem descriptions and prompt formats. It finds that older models like Codex are highly sensitive to superficial changes—especially variable names—while newer models like ChatGPT show significantly improved robustness due to RLHF fine-tuning, indicating progress toward deeper understanding over memorization.

ABSTRACT

Using large language models (LLMs) for source code has recently gained attention. LLMs, such as Transformer-based models like Codex and ChatGPT, have been shown to be highly capable of solving a wide range of programming problems. However, the extent to which LLMs understand problem descriptions and generate programs accordingly or just retrieve source code from the most relevant problem in training data based on superficial cues has not been discovered yet. To explore this research question, we conduct experiments to understand the robustness of several popular LLMs, CodeGen and GPT-3.5 series models, capable of tackling code generation tasks in introductory programming problems. Our experimental results show that CodeGen and Codex are sensitive to the superficial modifications of problem descriptions and significantly impact code generation performance. Furthermore, we observe that Codex relies on variable names, as randomized variables decrease the solved rate significantly. However, the state-of-the-art (SOTA) models, such as InstructGPT and ChatGPT, show higher robustness to superficial modifications and have an outstanding capability for solving programming problems. This highlights the fact that slight modifications to the prompts given to the LLMs can greatly affect code generation performance, and careful formatting of prompts is essential for high-quality code generation, while the SOTA models are becoming more robust to perturbations.

Motivation & Objective

  • To investigate whether LLMs solve programming problems through genuine understanding or by retrieving memorized solutions based on superficial cues.
  • To assess how prompt formatting and modifications affect code generation performance across multiple SOTA LLMs.
  • To determine the extent to which variable names and semantic changes influence model behavior in code generation tasks.
  • To evaluate the robustness of LLMs to both superficial and semantic perturbations in problem descriptions.
  • To provide empirical insights into the limitations and capabilities of current LLMs in automatic programming problem solving.

Proposed method

  • The study uses problem descriptions from Aizu Online Judge (AOJ) as prompts for LLMs to generate Python code.
  • Two main experiments are conducted: (1) superficial formatting variations (e.g., line breaks, punctuation) and (2) semantic and superficial modifications (e.g., inverse problem specification, variable name randomization).
  • Performance is measured by code correctness using hidden test cases, with solved rate as the primary metric.
  • Models evaluated include CodeGen, Codex, InstructGPT, and ChatGPT, representing a range of training methodologies including RLHF.
  • Variable name anonymization using UUIDs is used to test reliance on lexical cues in prompts.
  • The study compares model responses across perturbed inputs to assess sensitivity and generalization ability.
Figure 1 : Task of automatically solving programming problems by an LM evaluated by a judge system based on hidden test cases, an example of a problem named ITP1_1_C from AOJ.
Figure 1 : Task of automatically solving programming problems by an LM evaluated by a judge system based on hidden test cases, an example of a problem named ITP1_1_C from AOJ.

Experimental results

Research questions

  • RQ1To what extent do LLMs rely on superficial cues such as formatting and variable names when generating code?
  • RQ2How does prompt formatting affect the code generation performance of different LLMs?
  • RQ3How do semantic modifications (e.g., inverse problem specification) impact model output and correctness?
  • RQ4How does the inclusion of RLHF fine-tuning influence robustness to prompt perturbations?
  • RQ5Can LLMs generalize to problems that are semantically opposite to the original prompt?

Key findings

  • Codex showed a 25.9% performance improvement between worst and best prompt formatting, indicating high sensitivity to formatting.
  • CodeGen exhibited a 14.7% performance variation across formatting changes, also indicating strong formatting dependence.
  • Randomizing variable names (e.g., using UUIDs) reduced Codex’s solved rate significantly, showing heavy reliance on variable name semantics.
  • ChatGPT and InstructGPT demonstrated superior robustness to both formatting and variable name perturbations, suggesting deeper understanding.
  • Codex sometimes generated correct code for the original problem even when the prompt was semantically inverted (e.g., sum → product), indicating memorization over reasoning.
  • Models often rejected using anonymized variable names in generated code, preferring original names, which further confirms reliance on lexical cues.
Figure 2 : Illustration of the experiments consisting of problem formatting, prompt formatting, code generation, and evaluation.
Figure 2 : Illustration of the experiments consisting of problem formatting, prompt formatting, code generation, and 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.