When Knowledge Changes: Metamorphic Testing of RAG Systems with Mutations
Jinhan Kim, Samuele Pasini, Paolo Tonella
Abstract
Retrieval-Augmented Generation (RAG)-based LLM systems rely on external document corpora that can evolve and change over time. However, current evaluation methodologies (e.g., RAGAS) assess correctness against static snapshots, failing to detect faults when routine updates, factual changes, or noise alter the underlying data. We introduce a metamorphic testing framework that evaluates the consistency of RAG systems under corpus evolution. We formalise a fault taxonomy and 11 mutation operators that systematically perturb the system at both the pre-chunk (retrieval index) and post-chunk (retrieved context) levels. An empirical evaluation across five datasets and over 28k mutants reveals metamorphic violation rates of 4.9-10.2%. In a meta-evaluation against ground truth, our metamorphic oracle achieves F1 scores of 0.927-1.000, while the best RAGAS metric reaches only 0.570. Finally, we provide actionable insights into mitigating these faults through retrieval re-configuration, generator upgrades, and LLM-based reranking.
Create a lesson
Related papers
CASPER-Change-Aware Slice Prioritization for Efficient Regression Testing of LLM-based systems
Shared title terminology · Biruk Asmare Muse, Lionel Briand, Yiwei Lu et al.
Metamorphic Testing of Transpilers via Mutation Consistency of Programs
Shared title terminology · Enea Raffaele Ilario Papaleo, Luca Guglielmo, Giovanni Denaro
Input Relation Prompting for Metamorphic Testing on Query-Based Systems
Shared title terminology · Eng-Shen Tu, Shin-Jie Lee
Delta Debugging for Cyber-Physical Systems with Flaky Test Executions
Shared title terminology · Pablo Valle, Shaukat Ali, Aitor Arrieta
Metamorphic Testing for Clinical ML Models: A Framework Proposal and Pilot Study
Shared title terminology · Jie JW Wu, Feiyu E, Bo Chen
Do Coverage and Mutation Scores of LLM-Generated Test Suites Correlate with Their Effectiveness? (Replicability Study)
Shared title terminology · Junda Zhao, Shurui Zhou, Eldan Cohen