Benchmarking and Revisiting Code Generation Assessment: A Mutation-Based Approach

Longtian Wang, Tianlin Li, Xiaofei Xie, Yuhan Zhi, Jian Wang, Chao ShenarXiv 2025

TL;DR

This paper reveals a significant disconnect between how code generation models (CLLMs) are currently benchmarked and their real-world performance. By introducing a novel mutation-based evaluation approach with 10 strategies and 3 new metrics, the authors demonstrate that slight variations in problem descriptions can drastically alter CLLM performance, highlighting the need for more robust and realistic benchmarks.

What Problem Does This Paper Address?

The current evaluation of Code Large Language Models (CLLMs) for program synthesis heavily relies on manually curated benchmarks like HumanEval. These benchmarks typically present each coding problem with a single, "ideal" input prompt. However, in real-world development, problem descriptions can vary significantly due to typos, different phrasing, or the need for clarification. This paper argues that this "single-prompt" evaluation approach creates a substantial gap between benchmark results and actual CLLM performance, potentially leading to biased assessments and misguidance in future research. The core problem is that existing benchmarks don't account for the inherent variability and ambiguity present in how developers describe coding tasks.

Methods

The authors introduce a comprehensive methodology to address the limitations of current benchmarks. Their approach involves:

  • Mutation Strategies: They propose 10 distinct strategies to systematically alter input prompts. These include character-level typos (misspelling, keyboard typos), synonym substitution, LLM-based paraphrasing and summarization of descriptions, and manipulating the number of examples provided (insertion/removal). These mutations are applied to different parts of the prompt: function signature, problem description, and examples.
  • New Evaluation Metrics: To capture the impact of these mutations, they introduce three new metrics:
  • Correctness Variability (CV): Measures the difference in the number of correctly generated code samples between a mutated prompt and its original counterpart.
  • Mutation Bias (MB): Calculates the average absolute CV across a set of mutated prompts, quantifying the overall impact of mutations on a model's performance.
  • Best Pass@k (Pass@k_b): Determines the optimal Pass@k score achievable across a set of mutated prompts, representing the model's best-case performance under varied inputs.

The overall workflow involves mutating an initial prompt, feeding both the original and mutated prompts to a CLLM, generating code, and then evaluating the code's correctness using unit tests and the proposed metrics.

Datasets

The primary dataset used for evaluation is HumanEval. This is a widely-used benchmark consisting of 164 handwritten synthesis problems, each with a function signature, problem description, examples, and execution scripts. The authors also generated a new, larger benchmark by applying their mutation strategies to the HumanEval dataset, resulting in 12,834 generated prompt variants.

Key Insights and Ideas

  • The "Single Prompt" Fallacy: The most striking insight is the significant performance discrepancy observed between evaluations using original benchmarks and those incorporating mutated prompts. This strongly suggests that current benchmarks are not a fair representation of CLLM capabilities in real-world scenarios.
  • Sensitivity to Description: Even minor changes to problem descriptions (e.g., adding "Avoid the empty string") can significantly boost or hinder a model's performance. This highlights the critical role of prompt engineering and the potential for bias if only one phrasing is used for evaluation.
  • Varied Impact of Mutations: Different mutation strategies affect models differently. For instance, typos in variable names can sometimes improve performance for lower-performing models, while mutations in the problem description have a greater impact on high-performing models.
  • Model Robustness Varies: Models that perform well on standard benchmarks don't necessarily exhibit better robustness to prompt variations. In fact, some high-performing models show greater fluctuations in performance when faced with mutated inputs.
  • Example Usage is Nuanced: Providing more examples doesn't always improve code generation. For several models, removing examples led to better or similar performance compared to adding them, suggesting these models might not effectively utilize additional examples.

Key Results

The study evaluated five popular CLLMs (DeepSeek, Llama3.1, CodeLlama, CodeGen, InCoder) using the 12,834 mutated prompts. Key quantitative findings include:

  • Significant Discrepancy: The average Mutation Bias (MB) across all models and mutation strategies was non-zero, confirming that mutations impact correctness. For example, the average MB was 12.80 for DeepSeek and 11.46 for Llama3.1, indicating substantial variability.
  • Pass@k_b Outperforms Pass@1: The "best-case" Pass@k score (Pass@k_b) across mutated prompts consistently outperformed the standard Pass@1 on the initial prompt for all models. For instance, CodeGen achieved an average Pass@1 of 19.10 but an average Pass@k_b of 26.23.
  • Model-Specific Sensitivities:
    • For high-performing models like DeepSeek and Llama3.1, mutations in the problem description (e.g., Description Paraphrase, Description Summarize) had a greater impact (higher MB values).
  • For lower-performing models like InCoder, mutations in the function signature (e.g., Function Name Typo, Function Name Substitution) had a more significant effect.
  • Typos in variable names sometimes improved Pass@1 for DeepSeek (68.87 vs. 67.99 initial) and Llama3.1.

Limitations and Future Work

  • Limitations:
    • The study acknowledges that while they propose 10 mutation strategies, there's still room for improvement by incorporating even more diverse mutations.
  • The current evaluation still relies on unit tests for correctness, which might not capture all aspects of code quality.
  • Future Work:
    • The authors suggest an iteration-based evaluation approach where models could clarify prompts before generating code. This would involve refining prompts and addressing unclear aspects iteratively, leading to a more robust assessment.
  • Developing more comprehensive benchmarks that incorporate a broader range of prompt variations is crucial for a fairer and more informative evaluation of CLLMs.
  • Further research into understanding why certain mutations impact models differently and how to leverage this for better model development is recommended.

Summary updated

BibTeX
@misc{wang2025benchmarking,
  author = {Longtian Wang and Tianlin Li and Xiaofei Xie and Yuhan Zhi and Jian Wang and Chao Shen},
  title = {{Benchmarking and Revisiting Code Generation Assessment: A Mutation-Based Approach}},
  year = {2025},
  eprint = {2505.06880},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.06880},
}
Figure