Towards Knowledge Checking in Retrieval-augmented Generation: A Representation Perspective

Shenglai Zeng, Jiankun Zhang, Bingheng Li, Yuping Lin, Tianqi Zheng, Dante Everaert, Hanqing Lu, Hui Liu, Yue Xing, Monica Xiao Cheng, Jiliang Tang

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:

  1. Internal Knowledge Checking: Does the model already know the answer?
  2. Uninformed Helpfulness: If the model doesn't know the answer, is the context useful?
  3. Informed Helpfulness: If the model does know the answer, does the context help or distract?
  4. 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%.

Performance comparison of representation-based methods (Rep-PCA, Rep-Con) against traditional baselines across four knowledge-checking tasks.

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.

ROC curves for baseline metrics (Perplexity, Average Score, Lowest Score) across different tasks, demonstrating their limited reliability compared to the proposed representation-based signals.

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

BibTeX
@inproceedings{zeng2025towards,
  author = {Shenglai Zeng and Jiankun Zhang and Bingheng Li and Yuping Lin and Tianqi Zheng and Dante Everaert and Hanqing Lu and Hui Liu and Yue Xing and Monica Xiao Cheng and Jiliang Tang},
  title = {{Towards Knowledge Checking in Retrieval-augmented Generation: A Representation Perspective}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2025},
  url = {https://openreview.net/forum?id=Ay5wU0I0qO},
}
Figure