RAG LLM Output Screening via VAE Latent Hallucination Detection
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Retrieval-Augmented Generation (RAG) enhanced Large Language Models (LLMs) suffer from AI-generated hallucinations, leading to incorrect, illogical, or factually incoherent outputs, which undermines their reliability and utility, particularly in critical applications like customer support and information retrieval.
Innovation Solution
Implement a Variational Autoencoder (VAE) to characterize the distribution of normal and hallucination outputs in a latent space by training it with labeled datasets, allowing for the detection of candidate hallucinations by comparing encoder output vectors against learned distributions.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If RAG models incorporate external knowledge bases to enhance contextual relevance and factual accuracy, then the quality of outputs is improved, but hallucinations (incorrect, illogical, or factually incoherent outputs) still persist
Solution Approach 1:
A Variational Autoencoder (VAE) is introduced as an intermediary system between the RAG model and the final output. The VAE encodes the generated text into a latent space representation and compares it against the distribution of training data, acting as a mediator to detect hallucinations without directly modifying the RAG model's generation process
Solution Approach 2:
The system implements a feedback mechanism where the VAE continuously monitors the encoded representation of generated text and provides feedback about its deviation from normal data distributions. This feedback loop enables real-time detection and flagging of potential hallucinations in the output
2Measurement precision
If the VAE uses a high-dimensional latent space to capture complex output distributions, then detection accuracy is improved, but computational complexity increases
Solution Approach 1:
The patent transforms the high-dimensional text output into a lower-dimensional latent space representation through the VAE encoder. This dimensionality reduction preserves the essential characteristics needed for hallucination detection while significantly reducing computational complexity and enabling more efficient processing
Solution Approach 2:
The system changes the parameter space by representing text in terms of probabilistic distributions in latent space rather than raw high-dimensional vectors. This parameter transformation allows for more efficient comparison and detection while maintaining detection accuracy
Data Source
Figure 1
Figure 2
Figure 3
AI summary
The disclosure provides runtime and training methods, computing apparatus, and computer readable media for use in detecting candidate hallucinations in outputs of a Retrieval-Augmented Generation (RAG) enhanced Large Language Model (LLM) trained to retrieve documents from a closed domain knowledge base responsive to an input query, and generate an LLM output vector based on the query and any retrieved documents. The method comprises inputting an LLM output vector received from an LLM to an encoder part of a Variational Autoencoder and receiving from an encoder output layer thereof an encoder output vector having values representing a distribution of the LLM output vector in a dimensionally reduced latent space. The Variational Autoencoder is trained using a training dataset of LLM output vectors generated by the LLM labelled as normal outputs of the LLM or hallucination outputs of the LLM, thereby generating characteristic distributions of normal outputs and hallucination outputs of the LLM in the latent space based on the documents in the closed domain knowledge base. By comparing the encoder output vector with the learned characteristic distribution of normal outputs of the LLM and/or the distribution of hallucination outputs of the LLM, an indication of whether or not the LLM output vector is likely to be a hallucination is generated.