Abstract
In-context Learning (ICL) has achieved notable success in the applications of large language models (LLMs). By adding only a few input-output pairs that demonstrate a new task, the LLM can efficiently learn the task during inference without modifying the model 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 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.
Introduction
In-Context Learning (ICL) has revolutionized how we interact with Large Language Models (LLMs), allowing them to perform complex tasks by providing just a few examples within a prompt. However, ICL is notoriously brittle; a model's performance can fluctuate significantly based on the choice of examples, their ordering, or the presence of minor noise.
While numerous benchmarks exist to evaluate LLM performance, there is a critical gap in evaluating the evaluators themselves. We lack standardized methods to determine if a test suite is robust enough to detect these inherent instabilities. This paper introduces MILE, a mutation testing framework designed to assess the quality and "fault-revealing power" of test data used for ICL systems.
The MILE Framework
MILE adapts the software engineering principle of mutation testing to the domain of LLM prompting. In traditional software testing, developers introduce small changes (mutants) into the source code to see if existing tests can detect the resulting errors. In MILE, the "program" is the ICL prompt, and the "mutants" are strategically altered versions of that prompt.
Mutation Operators
The framework utilizes six specialized mutation operators categorized into two distinct levels:
1. Demonstration-level Mutators
These operators modify individual examples within the prompt:
- Noisy Labels (NL): Randomly flips a label to an incorrect class to test sensitivity to label accuracy.
- Out-of-distribution Labels (OL): Replaces a label with a random, non-task token (e.g., a symbol like
&). - Blurred Inputs (BI): Truncates the input text to its prefix, testing how much context the model requires.
2. Prompt-level Mutators
These operators modify the structural relationship between examples:
- Demonstration Shuffle (DS): Randomizes the order of the provided examples.
- OOD Demonstrations (OD): Replaces a task-relevant example with one from a completely unrelated task (e.g., inserting a translation example into a sentiment analysis prompt).
- Demonstration Repetition (DR): Repeats a single example multiple times, testing for bias toward specific inputs.
Evaluation Metrics
To quantify the effectiveness of a test set, MILE employs two primary metrics:
- Standard Mutation Score ($MS_S$): The percentage of mutants "killed" (detected) by the test set. A mutant is considered killed if the model's prediction on the mutated prompt differs from its prediction on the original prompt.
- Group-wise Mutation Score ($MS_G$): A more sophisticated metric that measures the diversity of defects a test set can identify. This prevents a test set from appearing high-quality if it only detects one specific type of mutation (e.g., only sensitive to shuffling).
Experimental Results
We evaluated MILE across five NLP classification benchmarks—SST-2, AGnews, RTE, MRPC, and QNLI—using three open-source LLMs: Vicuna-7b, Llama-2-chat-7b, and Falcon-7b-instruct.
Dataset Quality Correlation
A key finding of our research is that mutation scores serve as a reliable proxy for dataset quality. We compared "Uniform" datasets (high-quality, class-balanced) against "Non-uniform" datasets (low-quality, biased).
- Uniform datasets achieved an average $MS_S$ of 67.6% and an $MS_G$ of 32.7%.
- Non-uniform datasets lagged significantly, with an average $MS_S$ of 44.2% and an $MS_G$ of 14.3%.
This demonstrates that high-quality test suites are substantially better at revealing the vulnerabilities and sensitivities of ICL systems.
Model Sensitivity
Our experiments highlighted specific vulnerabilities shared across different LLMs. Models were found to be most sensitive to Noisy Labels (NL) and Demonstration Shuffle (DS). The NL mutator had the highest average kill rate at 52.4%, confirming that label accuracy remains a primary pillar of prompt stability. Interestingly, these sensitivities were relatively consistent across different model architectures, suggesting that MILE's mutators capture fundamental characteristics of the ICL mechanism.
Conclusion and Future Work
MILE provides a rigorous, automated framework for evaluating the reliability of ICL test suites. By shifting the focus from model performance to test set quality, we provide researchers with the tools to build more robust benchmarks.
Future work will focus on expanding MILE beyond classification tasks to generative and regression tasks. Additionally, we aim to explore the use of LLMs to automatically generate more nuanced, adversarial mutators that can further stress-test the boundaries of In-Context Learning.
Summary updated