One-to-many testing for code generation from (just) natural language

Mansi Uniyal, Mukul Singh, Gust Verbruggen, Sumit Gulwani, Vu Le

Abstract

Evaluating Large Language Models (LLMs) on code generation tasks is often hindered by rigid benchmarks that penalize valid solutions due to underspecified prompts. We introduce MBUPP (Mostly Basic Underspecified Python Programs), a benchmark designed to address flaws in the popular MBPP dataset. By implementing a "one-to-many" testing framework and refining natural language descriptions, MBUPP reveals that modern LLMs are significantly more capable than previously measured, showing an average 45% increase in solvability when flexible evaluation is applied.

Introduction

The "Mostly Basic Python Programs" (MBPP) dataset has long served as a standard for evaluating LLM code generation. However, researchers have identified three critical issues: signature guessing, where models must intuit unstated function signatures; instruction mismatch, where prompts contain unverified implementation hints; and data contamination, where models may simply memorize public test cases.

At the heart of these issues is underspecification. In real-world scenarios, a natural language prompt can be interpreted in multiple valid ways. Standard benchmarks typically enforce a single "correct" interpretation, leading to false negatives when a model produces a logically sound but syntactically different solution.

Methodology: From MBPP to MBUPP

To rectify these flaws, the authors developed MBUPP using a two-phase approach focused on intent and flexibility.

Phase 1: Natural Language Refinement

The first phase involved stripping implementation-specific hints (e.g., "use regex") to focus purely on the user's intent. These descriptions were then paraphrased into multiple variations using GPT-4-Turbo. A human voting process was employed to select the most natural and clear version for the final benchmark.

Phase 2: One-to-Many Testing

The core innovation of MBUPP is the "one-to-many" evaluation framework. Instead of a single set of assertions, each problem is associated with multiple assertion sets representing different valid interpretations of the prompt (e.g., returning a list vs. a boolean). A model's output is considered correct if it passes any of these valid assertion sets.

The MBUPP methodology: prompt refinement (right) and the one-to-many evaluation framework (left).

Key Results and Insights

The shift to flexible evaluation led to a dramatic increase in measured model performance. Across a variety of models, including GPT-4o, Phi, and Mistral, the researchers observed an average 45% jump in solvability.

  • GPT-4o performance increased from 62.88% on the original MBPP to 88.20% on MBUPP.
  • Mistral saw a massive relative improvement, rising from 41.42% to 63.95%.
  • Small Models: Models like phi and mistral benefited the most (48-54% gains), suggesting they possess strong logical reasoning but struggle with the "signature guessing" required by rigid benchmarks.

Quantifying Underspecification

The necessity of the one-to-many approach is underscored by the distribution of test sets required for the benchmark. While many problems are straightforward, a significant portion of the dataset required multiple assertion sets to capture the range of valid model interpretations.

Frequency of updated test sets across the MBUPP benchmark, illustrating the prevalence of underspecification.

Discussion

The study also highlighted the impact of temperature and contamination. Interestingly, higher temperatures (increased randomness) improved scores in MBUPP, as models were more likely to explore different valid solution paths. Furthermore, the improved performance on cleaned prompts suggests that the original MBPP prompts were often confusing or poorly aligned with their corresponding tests, rather than models simply failing to understand the logic.

Conclusion

MBUPP demonstrates that current evaluation methods for AI code generation are overly pessimistic. By moving toward intent-based, "one-to-many" testing, we can more accurately measure the true reasoning capabilities of LLMs. The release of the MBUPP dataset and evaluation code provides a path forward for more realistic and robust assessment of AI programming assistants.

Summary updated

BibTeX
@inproceedings{uniyal2024one,
  author = {Mansi Uniyal and Mukul Singh and Gust Verbruggen and Sumit Gulwani and Vu Le},
  title = {{One-to-many testing for code generation from (just) natural language}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.findings-emnlp.902},
}
Figure