AggTruth: Contextual Hallucination Detection using Aggregated Attention Scores in LLMs

Piotr Matys, Jan Eliasz, Konrad Kiełczyński, Mikołaj Langner, Teddy Ferdinan +2 more
6/23/2025
cs.AIcs.CL

No confident code implementation found for this paper.

Abstract

In real-world applications, Large Language Models (LLMs) often hallucinate, even in Retrieval-Augmented Generation (RAG) settings, which poses a significant challenge to their deployment. In this paper, we introduce AggTruth, a method for online detection of contextual hallucinations by analyzing the distribution of internal attention scores in the provided context (passage). Specifically, we propose four different variants of the method, each varying in the aggregation technique used to calculate attention scores. Across all LLMs examined, AggTruth demonstrated stable performance in both same-task and cross-task setups, outperforming the current SOTA in multiple scenarios. Furthermore, we conducted an in-depth analysis of feature selection techniques and examined how the number of selected attention heads impacts detection performance, demonstrating that careful selection of heads is essential to achieve optimal results.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{matys2025aggtruth,
  title  = {AggTruth: Contextual Hallucination Detection using Aggregated Attention Scores in LLMs},
  author = {Piotr Matys and Jan Eliasz and Konrad Kiełczyński and Mikołaj Langner and Teddy Ferdinan and Jan Kocoń and Przemysław Kazienko},
  year   = {2025},
  eprint = {2506.18628},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2506.18628v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2506.18628.svg)](https://codeofpaper.com/paper/2506.18628)

Discussion