Table of Contents
Fetching ...

MeTMaP: Metamorphic Testing for Detecting False Vector Matching Problems in LLM Augmented Generation

Guanyu Wang, Yuekang Li, Yi Liu, Gelei Deng, Tianlin Li, Guosheng Xu, Yang Liu, Haoyu Wang, Kailong Wang

TL;DR

MeTMaP introduces a metamorphic testing framework to detect false vector matching in LLM-augmented generation by deriving eight metamorphic relations from six NLP datasets and testing 203 vector-matching configurations. The approach yields triplet-based test cases (base, positive, negative) and uses sentence metamorphoses to reveal semantic- and structure-based inconsistencies in vector retrieval. Evaluations across multiple embedding models, distance metrics, and open-source vector databases show substantial false-matching issues, with MeTMaP exposing accuracy drops to as low as 41.51% and frequently below 20% for many methods, outperforming baseline text-matching approaches. The findings emphasize the need for robust detection and mitigation of false vector matches in practical LLM-augmented systems and offer a blueprint for integrating metamorphic testing into vector-retrieval pipelines to improve reliability and trustworthiness.

Abstract

Augmented generation techniques such as Retrieval-Augmented Generation (RAG) and Cache-Augmented Generation (CAG) have revolutionized the field by enhancing large language model (LLM) outputs with external knowledge and cached information. However, the integration of vector databases, which serve as a backbone for these augmentations, introduces critical challenges, particularly in ensuring accurate vector matching. False vector matching in these databases can significantly compromise the integrity and reliability of LLM outputs, leading to misinformation or erroneous responses. Despite the crucial impact of these issues, there is a notable research gap in methods to effectively detect and address false vector matches in LLM-augmented generation. This paper presents MeTMaP, a metamorphic testing framework developed to identify false vector matching in LLM-augmented generation systems. We derive eight metamorphic relations (MRs) from six NLP datasets, which form our method's core, based on the idea that semantically similar texts should match and dissimilar ones should not. MeTMaP uses these MRs to create sentence triplets for testing, simulating real-world LLM scenarios. Our evaluation of MeTMaP over 203 vector matching configurations, involving 29 embedding models and 7 distance metrics, uncovers significant inaccuracies. The results, showing a maximum accuracy of only 41.51\% on our tests compared to the original datasets, emphasize the widespread issue of false matches in vector matching methods and the critical need for effective detection and mitigation in LLM-augmented applications.

MeTMaP: Metamorphic Testing for Detecting False Vector Matching Problems in LLM Augmented Generation

TL;DR

MeTMaP introduces a metamorphic testing framework to detect false vector matching in LLM-augmented generation by deriving eight metamorphic relations from six NLP datasets and testing 203 vector-matching configurations. The approach yields triplet-based test cases (base, positive, negative) and uses sentence metamorphoses to reveal semantic- and structure-based inconsistencies in vector retrieval. Evaluations across multiple embedding models, distance metrics, and open-source vector databases show substantial false-matching issues, with MeTMaP exposing accuracy drops to as low as 41.51% and frequently below 20% for many methods, outperforming baseline text-matching approaches. The findings emphasize the need for robust detection and mitigation of false vector matches in practical LLM-augmented systems and offer a blueprint for integrating metamorphic testing into vector-retrieval pipelines to improve reliability and trustworthiness.

Abstract

Augmented generation techniques such as Retrieval-Augmented Generation (RAG) and Cache-Augmented Generation (CAG) have revolutionized the field by enhancing large language model (LLM) outputs with external knowledge and cached information. However, the integration of vector databases, which serve as a backbone for these augmentations, introduces critical challenges, particularly in ensuring accurate vector matching. False vector matching in these databases can significantly compromise the integrity and reliability of LLM outputs, leading to misinformation or erroneous responses. Despite the crucial impact of these issues, there is a notable research gap in methods to effectively detect and address false vector matches in LLM-augmented generation. This paper presents MeTMaP, a metamorphic testing framework developed to identify false vector matching in LLM-augmented generation systems. We derive eight metamorphic relations (MRs) from six NLP datasets, which form our method's core, based on the idea that semantically similar texts should match and dissimilar ones should not. MeTMaP uses these MRs to create sentence triplets for testing, simulating real-world LLM scenarios. Our evaluation of MeTMaP over 203 vector matching configurations, involving 29 embedding models and 7 distance metrics, uncovers significant inaccuracies. The results, showing a maximum accuracy of only 41.51\% on our tests compared to the original datasets, emphasize the widespread issue of false matches in vector matching methods and the critical need for effective detection and mitigation in LLM-augmented applications.
Paper Structure (25 sections, 1 equation, 6 figures, 4 tables, 1 algorithm)

This paper contains 25 sections, 1 equation, 6 figures, 4 tables, 1 algorithm.

Figures (6)

  • Figure 1: Workflow for two types of LLM-based QA applications.
  • Figure 2: The overview of MeTMaP. Includes three parts: sentence pairs collection, triplet complementation, and simulation of vector matching.
  • Figure 3: An example of a real problem in a vector database.
  • Figure 4: The effect of metamorphosis on accuracy. \ref{['fig:distance1']} shows the accuracy without transformation. \ref{['fig:distance2']} gives the accuracy under MeTMaP. \ref{['fig:distance3']} is a statistic of the decrease in accuracy of the methods before and after the transformation.
  • Figure 5: Average positive and negative distances and accuracies on all sub-datasets.\ref{['fig:mean-cd']} shows the average positive and negative distances for the CD-based methods, where the left side of each column representes the positive one, and the right is the negative one. \ref{['fig:acc-cd']} is the accuracy of all CD-based methods on sub-datasets. \ref{['fig:mean-md']} shows the average distances for the MD-based methods. \ref{['fig:acc-md']} is the accuracy of all MD-based methods on sub-datasets.
  • ...and 1 more figures

Theorems & Definitions (7)

  • Definition 3.1
  • Definition 3.2
  • Definition 3.3
  • Definition 3.4
  • Definition 3.5
  • Definition 3.6
  • Definition 3.7