mlsanityData to 7 Oct 2026

Validating LLM-Generated Programs with Metamorphic Prompt Testing

arXiv 2406.06864 ↗First posted 11 Jun 2024cs.SE cs.AIcited by 6

Not on the map. Why?

Abstract (arXiv)

The latest paradigm shift in software development brings in the innovation and automation afforded by Large Language Models (LLMs), showcased by Generative Pre-trained Transformer (GPT), which has shown remarkable capacity to generate code autonomously, significantly reducing the manual effort required for various programming tasks. Although, the potential benefits of LLM-generated code are vast, most notably in efficiency and rapid prototyping, as LLMs become increasingly integrated into the software development lifecycle and hence the supply chain, complex and multifaceted challenges arise as the code generated from these language models carry profound questions on quality and correctness. Research is required to comprehensively explore these critical concerns surrounding LLM-generated code. In this paper, we propose a novel solution called metamorphic prompt testing to address these challenges. Our intuitive observation is that intrinsic consistency always exists among correct code pieces but may not exist among flawed code pieces, so we can detect flaws in the code by detecting inconsistencies. Therefore, we can vary a given prompt to multiple prompts with paraphrasing, and to ask the LLM to acquire multiple versions of generated code, so that we can validate whether the semantic relations still hold in the acquired code through cross-validation. Our evaluation on HumanEval shows that metamorphic prompt testing is able to detect 75 percent of the erroneous programs generated by GPT-4, with a false positive rate of 8.6 percent.

Key facts. Cited by 6 papers in the map (data through 7 Oct 2026). Builds on 9 of its 28 references that are in the map. First posted on arXiv 11 Jun 2024.

Builds on

9 of 28 references.

References · 9

  1. 2021Evaluating Large Language Models Trained on Codecited by 8,053
  2. 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,332
  3. 2023LEVER: Learning to Verify Language-to-Code Generation with Executioncited by 228
  4. 2023OctoPack: Instruction Tuning Code Large Language Modelscited by 178
  5. 2023An Empirical Study of the Non-determinism of ChatGPT in Code Generationcited by 134
  6. 2022Programming Is Hard -- Or at Least It Used to Be: Educational Opportunities And Challenges of AI Code Generationcited by 97
  7. 2019Paraphrasing with Large Language Modelscited by 35
  8. 2020Automated Source Code Generation and Auto-completion Using Deep Learning: Comparing and Discussing Current Language-Model-Related Approachescited by 6
  9. 2022Unveiling Hidden DNN Defects with Decision-Based Metamorphic Testingcited by 5

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2024: 1; 2025: 2; 2026: 3.

6 papers.