Hallucinated Span Detection with Multi-View Attention Features (2025)

Abstract: This study addresses the problem of hallucinated span detection in the outputs of large language models. It has received less attention than output-level hallucination detection despite its practical importance. Prior work has shown that attentions often exhibit irregular patterns when hallucinations occur. Motivated by these findings, we extract features from the attention matrix that provide complementary views capturing (a) whether certain tokens are influential or ignored, (b) whether attention is biased toward specific subsets, and (c) whether a token is generated referring to a narrow or broad context, in the generation. These features are input to a Transformer-based classifier to conduct sequential labelling to identify hallucinated spans. Experimental results indicate that the proposed method outperforms strong baselines on hallucinated span detection with longer input contexts, such as data-to-text and summarisation tasks.

## introduction large language models (llms) have significantly advanced natural language processing and demonstrated high performance across tasks @xcite . however, hallucinations persisting in texts generated by llms have been identified as a serious issue, which undermines llm safety @xcite . to tackle this challenge, hallucination detection has been actively studied @xcite . model-level (e.g., @xcite ) or responselevel (e.g., @xcite ) hallucination detection has been proposed. however, identification of the hallucinated span is less explored despite its practical importance. hallucinated span detection enables understanding and manually editing the problematic portion of the output. it also provides clues to mitigate hallucinations in llm development. to address this, we tackle hallucinated span detection. while there have been various types of hallucinations @xcite , this study targets hallucinations on contextualised generations that add baseless and contradictive information against the given input context. motivated by the findings that irregular attention patterns are observed when hallucination occurs @xcite , we extract features to characterise the distributions of attention weights. specifically, the proposed method extracts an attention matrix from an llm by inputting a set of prompt, context, and llm output of concern. it then assembles features for each token from the attention matrix: average and diversity of incoming attention as well as diversity of outgoing attention, which complementarily capture the attention patterns of language models. the former two features indicate whether attention is distributed in a balanced manner for tokens in the output text. the last feature reveals if an output token was generated by broadly attending to other tokens. these features are then fed to a transformer encoder with a conditional random field layer on top to conduct sequential labelling to determine whether a token is hallucinated or not. experimental results on hallucinated span detection confirmed that the proposed method outperforms strong baselines on data-to-text and summarisation tasks, improving token-level f1 score for 4.9 and 2.9 points, respectively. an in-depth analysis reveals that the proposed method is capable of handling longer input contexts. our code is available at https://github.com/ogamon958/ mva_hal_det . ## related work this section discusses hallucination detection that utilises various internal states of llms. attention-based hallucination detection lookback lens @xcite is the most relevant method to our study, which identifies hallucinations using only attention matrices. it computes the "lookback" ratio of attention to assess whether generated tokens attend well to the input context. in contrast, our features primarily focus on the attention of output texts and capture more nuanced and structural attention patterns. alti+ @xcite tracks token interactions across layers. alti+ has been applied to hallucination detection in machine translation, highlighting cases where the model fails to properly utilise source text information. a drawback of alti+ is its computational cost. it computes a token-to-token contribution matrix for each layer and for each attention head. therefore, memory consumption linearly increases depending on the length of context and output as well as llm sizes. indeed, @xcite excluded sequences longer than 400 tokens due to gpu memory constraints. ## proposed method the proposed method is illustrated in figure 1 . it conducts sequential labelling, i.e., predicts binary labels that indicate whether a token in text, which has been generated by a certain llm, is hallucinated or not. specifically, the proposed method takes a set of prompt, input context, and output generated by an llm of concern as input to another llm and obtains the attention matrix of the output text span. it then extracts features from the attention matrix (sections 3.1 and 3.2). these features are fed to a transformer encoder model with the prediction head of a conditional random field (crf) to conduct sequential labelling to identify hallucinated spans (section 3.3). as the attention matrix provides crucial information for our method, we compare the raw attention and a variation based on the analysis of attention mechanism @xcite (section 3.4). we remark that only the hallucination detection model needs training, i.e., the llm for attention matrix extraction is kept frozen, which makes our method computationally efficient. our method applies to both scenarios where the llm that generated outputs and the llm for hallucinated span detection are the same or different. in practice, the latter setting is expected to be more common in an era where llms are widely used for writing tasks. in addition, we cannot access the internal state of proprietary llms. our experiments assume the scenario where the llm for generation and the llm for detection are different. ## evaluation we evaluate the effectiveness of the proposed method for hallucinated span detection. ## conclusion we proposed the hallucinated span detection method using features that assemble attention weights from different views. our experiments confirmed that these features are useful in combination for detecting hallucinated spans, outperforming a previous method that also uses attention weights. this study focused on hallucination detection, but our method may also apply to broader abnormal behaviour detection of llms. as future work, we plan to explore its potential for detecting backdoored llms @xcite , which behave normally on regular inputs but produce malicious outputs when triggered. since our approach analyses attention distributions, it may detect anomalous attention patterns caused by the triggers.