Hallucination Detection in LLMs with Topological Divergence on Attention Graphs
Alexandra Bazarova, Aleksandr Yugay, Andrey Shulga, Alina Ermilova, Andrei Volodichev, Konstantin Polev, Julia Belikova, Rauf Parchiev, Dmitry Simakov, Maxim Savchenko, Andrey Savchenko, Serguei Barannikov, Alexey Zaytsev
TL;DR
The paper addresses hallucinations in LLMs within retrieval-augmented generation by proposing TOHA, a training-free detector that exploits the topology of attention graphs to measure novelty via the topological divergence $MTop{-}Div_G(R, P)$. It identifies a small set of hallucination-aware attention heads and averages their divergence to detect hallucinations efficiently across diverse tasks and models. Empirical results show TOHA achieving state-of-the-art or competitive performance on QA and summarization benchmarks with minimal annotated data and significantly faster inference. The work demonstrates the value of combining topological data analysis with transformer attention to assess factual reliability, offering practical benefits for safe and scalable deployment of LLMs.
Abstract
Hallucination, i.e., generating factually incorrect content, remains a critical challenge for large language models (LLMs). We introduce TOHA, a TOpology-based HAllucination detector in the RAG setting, which leverages a topological divergence metric to quantify the structural properties of graphs induced by attention matrices. Examining the topological divergence between prompt and response subgraphs reveals consistent patterns: higher divergence values in specific attention heads correlate with hallucinated outputs, independent of the dataset. Extensive experiments - including evaluation on question answering and summarization tasks - show that our approach achieves state-of-the-art or competitive results on several benchmarks while requiring minimal annotated data and computational resources. Our findings suggest that analyzing the topological structure of attention matrices can serve as an efficient and robust indicator of factual reliability in LLMs.
