Skip to main content
QUICK REVIEW

[Paper Review] Codex Hacks HackerRank: Memorization Issues and a Framework for Code Synthesis Evaluation

Anjan Karmakar, Julian Aron Prenner|arXiv (Cornell University)|Dec 6, 2022
Software Engineering ResearchComputer Science9 citations
TL;DR

This paper evaluates OpenAI's Codex model on 115 HackerRank Python problems, revealing significant memorization behavior despite high zero-shot (96%) and few-shot (100%) success rates. The authors propose a mutation-based framework to systematically assess code synthesis generalization, highlighting risks of memorization, bias, and privacy leakage in large-scale code models.

ABSTRACT

The Codex model has demonstrated extraordinary competence in synthesizing code from natural language problem descriptions. However, in order to reveal unknown failure modes and hidden biases, such large-scale models must be systematically subjected to multiple and diverse evaluation studies. In this work, we evaluate the code synthesis capabilities of the Codex model based on a set of 115 Python problem statements from a popular competitive programming portal: HackerRank. Our evaluation shows that Codex is indeed proficient in Python, solving 96% of the problems in a zero-shot setting, and 100% of the problems in a few-shot setting. However, Codex exhibits clear signs of generating memorized code based on our evaluation. This is alarming, especially since the adoption and use of such models could directly impact how code is written and produced in the foreseeable future. With this in mind, we further discuss and highlight some of the prominent risks associated with large-scale models of source code. Finally, we propose a framework for code-synthesis evaluation using variations of problem statements based on mutations.

Motivation & Objective

  • To investigate whether Codex exhibits memorization behavior when generating code from natural language prompts.
  • To assess the generalization capabilities of Codex across modified problem statements using controlled mutations.
  • To identify risks associated with large-scale code models, including memorization, bias, and privacy leakage.
  • To propose a systematic evaluation framework based on problem statement variations for code synthesis models.
  • To improve the reliability and transparency of code generation by large language models in software engineering contexts.

Proposed method

  • The authors collected 115 Python problem statements from HackerRank as a benchmark for code synthesis evaluation.
  • They applied controlled mutations to problem descriptions—altering input-output specifications, problem wording, and variable names—to test generalization.
  • Codex was prompted with original and mutated versions of problems in zero-shot and few-shot settings with varying temperature settings.
  • The model's outputs were evaluated for correctness, memorization, and sensitivity to input variations.
  • The study introduces a mutation-based evaluation framework to systematically detect memorization and generalization failures.
  • The framework is applied to diverse problem types, including string manipulation, arithmetic logic, and hashing, to assess robustness.

Experimental results

Research questions

  • RQ1To what extent does Codex generate memorized code instead of synthesizing new solutions when prompted with modified problem statements?
  • RQ2How does Codex's performance vary when input-output specifications are omitted or altered in problem descriptions?
  • RQ3What are the failure modes of Codex when faced with semantically equivalent but syntactically different problem formulations?
  • RQ4How does the model's behavior change when prompted with only partial or ambiguous problem descriptions?
  • RQ5What are the implications of memorization for the reliability, security, and privacy of code generated by large language models?

Key findings

  • Codex achieved 96% success in zero-shot generation and 100% in few-shot settings on original HackerRank problems, indicating strong baseline performance.
  • Despite high success rates, Codex frequently generated code matching original problem specifications even when input-output examples were omitted, indicating memorization.
  • In some cases, Codex produced correct code using only the first sentence of a problem description, suggesting it relies on memorized patterns rather than reasoning.
  • For mutated problems involving string encoding, Codex correctly synthesized solutions for only 67% of variants, showing brittleness under input variation.
  • Codex exhibited inconsistent interpretation of natural language inputs—e.g., misreading 'twenty-three' as 2-3 instead of 23—indicating sensitivity to phrasing.
  • The study demonstrates that standard benchmarks like HackerRank may be biased due to model memorization of common code patterns from training data.

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.