MILE: A Mutation Testing Framework of In-Context Learning Systems

Zeming Wei, Yihao Zhang, Meng Sun

TL;DR

MILE is a novel mutation testing framework designed to evaluate the quality and reliability of test suites used for In-Context Learning (ICL). By injecting artificial "faults" into LLM prompts—such as flipping labels or shuffling example order—MILE measures how effectively a test set can detect these vulnerabilities, providing a rigorous metric for dataset quality in the era of few-shot prompting.

What Problem Does This Paper Address?

In-Context Learning (ICL) allows Large Language Models (LLMs) to perform new tasks simply by providing a few examples (demonstrations) in the prompt. While powerful, ICL is notoriously "brittle." Performance can swing wildly based on the choice of examples, their order, or even minor label noise.

The challenge is that while we have many benchmarks to evaluate ICL, we lack a way to evaluate the evaluators. How do we know if a test suite is actually high-quality? Does it have the "fault-revealing" power to catch an LLM's sensitivity to prompt instability? Current evaluation methods often treat the test set as a static gold standard, ignoring whether the data is diverse or robust enough to provide a meaningful assessment of the model's reliability.

Methods

The authors adapt the classic software engineering concept of Mutation Testing to the world of LLM prompting. In traditional software testing, you modify the source code (create a "mutant") and see if your tests can "kill" it (detect the change). In MILE, the "program" being tested is the ICL prompt.

The framework operates in two stages:

  1. Mutant Generation: The authors propose six specialized mutators categorized into two levels:
  2. Demonstration-level: Modifying individual examples.
  3. Noisy Labels (NL): Randomly flipping a label to a wrong class.
  4. Out-of-distribution Labels (OL): Replacing a label with a random token like &.
  5. Blurred Inputs (BI): Truncating the input text to its prefix.
  6. Prompt-level: Modifying the relationship between examples.
  7. Demonstration Shuffle (DS): Randomizing the order of examples.
  8. OOD Demonstrations (OD): Replacing a task-relevant example with one from a completely different task (e.g., translation).
  9. Demonstration Repetition (DR): Repeating the same example multiple times.
  10. Test Set Evaluation: The framework calculates two primary scores:
  11. Standard Mutation Score ($MS_S$): The ratio of mutants "killed" (detected) by the test set.
  12. Group-wise Mutation Score ($MS_G$): A more nuanced metric that measures the diversity of defects a test set can identify, preventing score inflation from test cases that only catch one type of error.

Datasets

The authors evaluated MILE using five popular NLP classification benchmarks:

  • SST-2 (Sentiment analysis)
  • AGnews (News categorization)
  • RTE (Textual entailment)
  • MRPC (Paraphrase detection)
  • QNLI (Natural language inference)

They tested these across three open-source LLMs: Vicuna-7b, Llama-2-chat-7b, and Falcon-7b-instruct. To validate MILE, they compared "Uniform" (high-quality, balanced) datasets against "Non-uniform" (low-quality, biased) datasets.

Key Insights and Ideas

  • The "Aha" Moment for Dataset Quality: The paper demonstrates that a "good" test set (balanced classes) consistently yields a higher mutation score than a "bad" one (biased classes). This proves that mutation testing can serve as a proxy for dataset quality.
  • Sensitivity Mapping: The experiments reveal exactly what makes ICL tick. LLMs were found to be most sensitive to Noisy Labels (NL) and Demonstration Shuffle (DS). This quantifies the long-held suspicion that label accuracy and example ordering are the "load-bearing" pillars of a prompt.
  • Transferability: Interestingly, the sensitivity of models to specific mutators was relatively consistent across different LLMs and tasks. This suggests that a core set of mutators can be used to benchmark ICL systems generally, regardless of the specific architecture.

Key Results

  • Quality Correlation: On average, uniform (high-quality) datasets achieved a standard mutation score ($MS_S$) of 67.6%, compared to only 44.2% for non-uniform datasets.
  • Diversity Matters: The Group-wise Mutation Score ($MS_G$) showed an even sharper divide: 32.7% for uniform sets vs. 14.3% for non-uniform sets. This highlights that high-quality test suites are significantly better at catching a variety of prompt defects.
  • Mutator Lethality: The Noisy Label (NL) mutator had the highest average "kill rate" (52.4%), followed closely by Demonstration Shuffle (58.8% for prompt-level), confirming that these are the most critical areas for ICL robustness.

Limitations and Future Work

  • Model Scale: The study was limited to 7B parameter models due to computational constraints. The authors acknowledge that larger or closed-source models (like GPT-4) might exhibit different sensitivities.
  • Task Variety: The current framework focuses primarily on classification. Adapting MILE for generative tasks (like summarization or creative writing) or regression tasks would require defining new "kill" conditions beyond simple label mismatch.
  • Automated Mutator Selection: While the six mutators cover common issues, future work could involve using an LLM to automatically generate even more "nuanced" or "adversarial" mutators tailored to specific domains.

Summary updated

Abstract

In-context Learning (ICL) has achieved notable success in large language models (LLMs) applications. By adding only a few input-output pairs demonstrating a new task, LLMs can efficiently learn the task during inference without modifying their parameters. Such mysterious ability of LLMs has attracted great research interests in understanding, formatting, and improving the in-context demonstrations, while still suffering from drawbacks like black-box mechanisms and sensitivity against the selection of examples. In this work, inspired by the foundations of adopting testing techniques in machine learning (ML) systems, we propose a mutation testing framework designed to characterize the quality and effectiveness of test data for ICL systems. First, we propose several mutation operators specialized for ICL demonstrations, as well as the corresponding mutation scores for ICL test sets. With comprehensive experiments, we showcase the effectiveness of our framework in evaluating the reliability and quality of ICL test suites. Our code is available at https://github.com/weizeming/MILE.
BibTeX
@inproceedings{wei2024mile,
  author = {Zeming Wei and Yihao Zhang and Meng Sun},
  title = {{MILE: A Mutation Testing Framework of In-Context Learning Systems}},
  booktitle = {SETTA},
  year = {2024},
  url = {https://openreview.net/forum?id=9KGFxAYABL},
}

Loading related content...

Figure