NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Boosting LLMs for Mutation Generation

Bo Wang, Ming Deng, Mingda Chen, Chengran Yang, Youfang Lin, Mark Harman, Mike Papadakis, Jie M. ZhangarXiv 2026

TL;DR

SMART (Semantic Mutation with Adaptive Retrieval and Tuning) is a new framework that dramatically improves LLM-based mutation testing by combining logic-based code chunking, retrieval-augmented generation (RAG) of real-world bugs, and supervised fine-tuning. This approach significantly increases the validity and realism of generated code faults, allowing smaller 7B open-source models to match or even outperform commercial giants like GPT-4o.

What Problem Does This Paper Address?

Mutation testing is a powerful software testing technique where developers intentionally inject small faults ("mutations") into a program to see if their existing test suites can catch them. If a test suite fails to detect these artificial bugs, it exposes a weakness in the testing infrastructure.

While traditional mutation testing relies on rigid, rule-based code modifications (like changing a + to a -), researchers have recently turned to Large Language Models (LLMs) to generate more complex, realistic, and semantically meaningful faults. However, current LLM approaches suffer from major bottlenecks: they rely on static, one-size-fits-all prompts, and they look at entire code methods at once. This often results in a high volume of uncompilable code, redundant mutants, and generic changes that look nothing like actual human developer errors.

Methods

To overcome these limitations, the authors introduce SMART, which optimizes mutation generation through three core pillars:

  1. Logic-Based Code Chunking: Instead of feeding an entire monolithic method into an LLM, SMART parses the code's Abstract Syntax Tree (AST) and breaks it down into semantically coherent chunks based on natural control-flow boundaries (like if, for, and try-catch blocks).
  2. Context-Aware Few-Shot Retrieval (RAG): SMART utilizes a vectorized database of 130,000 real-world single-hunk Java bug-fix pairs. Using CodeT5 embeddings and Euclidean distance, it dynamically retrieves the most relevant real-world bugs to serve as in-context examples for the target code chunk.
  3. Supervised Fine-Tuning (SFT): The authors perform full-parameter fine-tuning on open-source LLMs using a dataset of 13,760 high-quality mutations that are known to couple closely with real bugs, aligning the models specifically for the task of realistic fault generation.
Fig. 1. The Overview of Mutation Generation Process of SMART

Datasets

The framework was evaluated on 1,991 real-world Java bugs drawn from two prominent benchmarks:

  • Defects4J 2.0: A widely used benchmark containing historical bugs from open-source projects.
  • ConDefects: A complementary dataset featuring algorithmic defects from competitive programming contests.

For training the SFT models, the authors utilized a mutation dataset previously constructed by LLMut, strictly excluding the Lang and Cli projects from Defects4J during evaluation to prevent data leakage.

Key Insights and Ideas

  • Small Models Can Punch Above Their Weight: One of the most striking findings is that applying SMART to 7B-parameter open-source models (like Qwen-2.5-7B or Llama-3.1-8B) allows them to achieve performance competitive with or superior to GPT-4o.
  • Chunking is the Most Critical Component: Ablation studies revealed that logic-based code chunking provides the most significant performance gains. Breaking down the code reduces input complexity and forces the LLM to focus on fine-grained program logic.
  • Semantic Swaps Over Superficial Edits: By using RAG, the LLM learns to make sophisticated semantic changes—such as swapping row and column logic—rather than just blindly changing operators.
Fig. 2. The Example Mutation of SMART
  • Euclidean Distance Beats Cosine Similarity: In configuring the RAG component, the authors found that Euclidean distance consistently outperformed cosine and dot-product similarity metrics for retrieving semantically relevant code snippets.

Key Results

SMART was evaluated against state-of-the-art LLM mutation tools (LLMut and LLMorpheus) across several dimensions:

  • Mutation Validity: SMART raised the weighted average generation rate from 42.89% (LLMut) to 65.6%. It also boosted the non-duplicate rate to 95.62% and the compilable rate to 90.21%.
  • Mutation Effectiveness: SMART achieved a real bug detection rate of 92.61% (compared to just 57.86% for LLMut and 31.99% for LLMorpheus).
  • Downstream Applications: When applied to Mutation-Based Fault Localization (MBFL), SMART successfully localized significantly more bugs in the "Top-1" rank (ranking 64 more bugs as Top-1 under the MUSE formula and 57 more under Metallaxis compared to baselines).

Limitations and Future Work

  • Computational and Token Overhead: Because logic-based chunking splits a single method into multiple pieces, it increases the number of LLM invocations (averaging 4.6 queries per method). This results in a roughly 36.7% increase in total token consumption.
  • Fine-Tuning Resource Intensity: Supervised fine-tuning is resource-heavy; training the larger Qwen-2.5-32B model required up to 140GB of GPU memory. However, the authors note this is a one-time offline cost.
  • Language Scope: The current implementation and evaluation of SMART are strictly limited to Java. Future work could explore expanding the framework to multi-language repositories.

Summary updated

BibTeX
@misc{wang2026boosting,
  author = {Bo Wang and Ming Deng and Mingda Chen and Chengran Yang and Youfang Lin and Mark Harman and Mike Papadakis and Jie M. Zhang},
  title = {{Boosting LLMs for Mutation Generation}},
  year = {2026},
  eprint = {2603.24560},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2603.24560},
}
Figure