Truth-Aware Context Selection: Mitigating Hallucinations of Large Language Models Being Misled by Untruthful Contexts

Tian Yu, Shaolei Zhang, Yang Feng

Abstract

Large Language Models (LLMs) are susceptible to "contextual interference," where they prioritize untruthful external information over their own internal parametric knowledge. This paper introduces Truth-Aware Context Selection (TACS), a lightweight, training-free intervention that identifies untruthful segments in the input context using internal model activations. By applying a binary attention mask to these segments, TACS prevents the model from attending to misleading information. Experimental results on TruthfulQA and ConflictQA show that TACS significantly enhances model robustness, outperforming existing methods like Inference-Time Intervention (ITI) in scenarios involving conflicting or false external context.

Introduction

While Retrieval-Augmented Generation (RAG) is widely used to ground LLMs in factual data, it introduces a vulnerability: the model may be misled by incorrect or hallucinated documents. Current LLMs often exhibit excessive "gullibility," following untruthful context even when it contradicts their internal knowledge. Existing solutions, such as Inference-Time Intervention (ITI), focus on model honesty but fail to address external misinformation. The challenge lies in developing a mechanism that allows LLMs to utilize helpful context while remaining "stubborn" against falsehoods.

Methodology

The proposed Truth-Aware Context Selection (TACS) framework operates without retraining the model, utilizing a three-phase pipeline:

  1. Truth Detection via Internal Probing: TACS analyzes the LLM's internal hidden states (activations) during context processing. The authors observe that activations differ significantly between truthful and untruthful tokens. Lightweight Support Vector Machine (SVM) classifiers are trained on these activations to predict truthfulness.
  2. Attention Masking: Identified untruthful segments are not deleted but are instead "hidden" from the model's reasoning engine. TACS constructs a binary attention mask where positions with truthfulness scores below a threshold $\theta$ are set to 0.
  3. Granularity: The method can be applied at the token level (TACS-T) for fine-grained filtering or at the sentence level (TACS-S) for improved coherence.
Overview of the TACS framework, showing truth detection via probing and subsequent attention masking to guide model output.

Experimental Results

The researchers evaluated TACS on Llama 2-Chat 7B and Mistral-7B-Instruct-v0.2 using the TruthfulQA and ConflictQA benchmarks. To assess performance, they introduced the Disturbance Adaptation Rate (DA Rate), which balances the model's ability to accept truthful information (TA Rate) with its resistance to untruthful information (UR Rate).

Key Insights

  • Middle-Layer Dominance: Probing across different layers revealed that truth-related information is most prominently represented in the middle layers (specifically layers 11-16). Classifiers trained on these layers achieved the highest accuracy, suggesting that the model's internal "understanding" of truth is localized within these latent representations.
Truth detection accuracy (Dev Acc) across model layers, highlighting the peak performance in the middle layers.
  • Cross-Model Generalization: SVM classifiers trained on Llama 2-Chat activations generalized well to homologous models like Vicuna, indicating a shared latent representation of truthfulness across similar architectures.
  • Performance Gains: On TruthfulQA, TACS-T improved Llama 2-Chat 7B’s accuracy from 39.5% to 45.6% in scenarios with misleading information. It consistently outperformed ITI, which often struggled or even regressed when faced with explicit external lies.

Conclusion

TACS provides a robust, lightweight solution to the problem of contextual interference in LLMs. By leveraging the model's own internal "gut feeling" about truthfulness, it effectively filters out misleading external context. Future work will explore providing corrective feedback instead of simple masking and refining threshold selection to better balance gullibility and stubbornness across diverse datasets.

Summary updated

BibTeX
@inproceedings{yu2024truth,
  author = {Tian Yu and Shaolei Zhang and Yang Feng},
  title = {{Truth-Aware Context Selection: Mitigating Hallucinations of Large Language Models Being Misled by Untruthful Contexts}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.findings-acl.645},
}
Figure