Abstract
Retrieval-Augmented Generation (RAG) systems have shown promise in enhancing the performance of Large Language Models (LLMs). However, these systems face challenges in effectively integrating external knowledge with the LLM’s internal knowledge, often leading to issues with misleading or unhelpful information. This work provides a systematic study on knowledge checking in RAG systems. We conduct a comprehensive analysis of LLM representation behaviors and demonstrate the significance of using representations in knowledge checking. Motivated by the findings, we develop representation-based classifiers for knowledge filtering, showing substantial improvements in RAG performance, even when dealing with noisy knowledge databases.
Introduction: The Trust Problem in RAG
Retrieval-Augmented Generation (RAG) is the industry standard for reducing hallucinations by providing LLMs with relevant documents. However, it faces a significant "trust" problem. LLMs are often overconfident and tend to prioritize external context even when it is irrelevant (unhelpful) or incorrect (misleading).
Current solutions typically involve "self-checking" (prompting the model to evaluate context) or "probability-checking" (using metrics like perplexity or token confidence). These methods are often superficial; self-checking is prone to the same overconfidence as the initial generation, and probability scores can be too noisy to distinguish between genuine knowledge and lucky guesses. This paper addresses the need for a more robust, intrinsic way to verify if a model knows a fact or if retrieved context is truly beneficial.
Methodology: Probing Hidden States
The researchers propose looking "under the hood" at the LLM’s hidden states—specifically the representations of the last input token in the final layer. They frame knowledge checking as four distinct tasks:
- Internal Knowledge Checking: Does the model already know the answer?
- Uninformed Helpfulness: If the model doesn't know the answer, is the context useful?
- Informed Helpfulness: If the model does know the answer, does the context help or distract?
- Contradiction Checking: Does the context conflict with the model’s internal beliefs?
To perform these checks, they developed two representation-based approaches: rep-PCA, which uses Principal Component Analysis to identify discriminative dimensions in the hidden state space, and rep-con, which employs contrastive learning to cluster helpful representations while separating unhelpful ones.
Key Results
The representation-based methods consistently outperformed all baselines across all tasks. For instance, in contradiction detection, representation-based methods achieved approximately 95% accuracy, while prompting and probability-based methods failed to break 67%.
When integrated into a real RAG pipeline (Mistral-7B on Noisy NQ), these representation-based filters boosted system accuracy from 28.97% to 72.53%. This massive performance gain—recovering over 43% accuracy—effectively neutralized the impact of "poisoned" documents in the retrieval database.
Insights: The "Hidden" Truth
A striking insight from this work is that LLMs often "know" they are being misled internally, even if they repeat misinformation in their text output. The internal representation captures the semantic conflict even when the generation layer ignores it.
As shown in the ROC curves above, traditional metrics like perplexity are far less reliable than hidden states. In contradiction detection (panel d), these metrics perform worse than random chance (AUC < 0.5), whereas representation-based classifiers achieve high precision. Furthermore, these classifiers are highly efficient, requiring as few as 50 to 100 samples to train, and show strong generalization across different model architectures and topics.
Limitations and Future Work
While representation-based checking is powerful, determining absolute correctness when the model itself lacks internal knowledge remains a complex challenge. Future work will investigate the underlying mechanisms of how transformer architectures encode "truthfulness" and explore multi-source verification for cases where the model is truly uninformed.
Summary updated