mlsanityData to 7 Oct 2026

Mutation-based Consistency Testing for Evaluating the Code Understanding Capability of LLMs

arXiv 2401.05940 ↗First posted 11 Jan 2024cs.SE cs.AIcited by 6

Not on the map. Why?

Abstract (arXiv)

Large Language Models (LLMs) have shown remarkable capabilities in processing both natural and programming languages, which have enabled various applications in software engineering, such as requirement engineering, code generation, and software testing. However, existing code generation benchmarks do not necessarily assess the code understanding performance of LLMs, especially for the subtle inconsistencies that may arise between code and its semantics described in natural language. In this paper, we propose a novel method to systematically assess the code understanding performance of LLMs, particularly focusing on subtle differences between code and its descriptions, by introducing code mutations to existing code generation datasets. Code mutations are small changes that alter the semantics of the original code, creating a mismatch with the natural language description. We apply different types of code mutations, such as operator replacement and statement deletion, to generate inconsistent code-description pairs. We then use these pairs to test the ability of LLMs to correctly detect the inconsistencies. We propose a new LLM testing method, called Mutation-based Consistency Testing (MCT), and conduct a case study on the two popular LLMs, GPT-3.5 and GPT-4, using the state-of-the-art code generation benchmark, HumanEval-X, which consists of six programming languages (Python, C++, Java, Go, JavaScript, and Rust). We compare the performance of the LLMs across different types of code mutations and programming languages and analyze the results. We find that the LLMs show significant variation in their code understanding performance and that they have different strengths and weaknesses depending on the mutation type and language.

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

Builds on

15 of 48 references.

References · 15

  1. 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
  2. 2020Language Models are Few-Shot Learnerscited by 32,199
  3. 2019RoBERTa: A Robustly Optimized BERT Pretraining Approachcited by 13,266
  4. 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,302
  5. 2021Evaluating Large Language Models Trained on Codecited by 8,053
  6. 2021Program Synthesis with Large Language Modelscited by 3,509
  7. 2020A Primer in BERTology: What we know about how BERT workscited by 807
  8. 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 732
  9. 2021Prompt Programming for Large Language Models: Beyond the Few-Shot Paradigmcited by 599
  10. 2023Language Agent Tree Search Unifies Reasoning Acting and Planning in Language Modelscited by 551
  11. 2023CodeGeeX: A Pre-Trained Model for Code Generation with Multilingual Benchmarking on HumanEval-Xcited by 294
  12. 2023Is ChatGPT the Ultimate Programming Assistant -- How far is it?cited by 72
3 more
  1. 2019Code Generation as a Dual Task of Code Summarizationcited by 62
  2. 2022Benchmarking Language Models for Code Syntax Understandingcited by 8
  3. 2021Practical Mutation Testing at Scalecited by 3

Built on by

Cited by year

Citing papers per year: 2024: 2; 2025: 4.

6 papers.