Table of Contents
Fetching ...

SPAD: Seven-Source Token Probability Attribution with Syntactic Aggregation for Detecting Hallucinations in RAG

Pengqian Lu, Jie Lu, Anjin Liu, Guangquan Zhang

TL;DR

SPAD tackles hallucinations in Retrieval-Augmented Generation by decomposing token probabilities into seven information sources and then aggregating these at the POS level to reveal syntax-driven anomalies. It delivers an exact probabilistic decomposition in a residual-transformer framework, uses logit-space head attribution to overcome non-linearity, and builds syntax-aware features that feed a fast, interpretable classifier. Across RAGTruth and Dolly benchmarks and multiple LLMs, SPAD achieves state-of-the-art or competitive results while offering mechanistic insight into when and why hallucinations arise. The method highlights signals beyond traditional FFN-RAG conflicts, including LayerNorm and user-query contributions, enabling more robust detection and potential real-time mitigation.

Abstract

Detecting hallucinations in Retrieval-Augmented Generation (RAG) remains a challenge. Prior approaches attribute hallucinations to a binary conflict between internal knowledge (stored in FFNs) and retrieved context. However, this perspective is incomplete, failing to account for the impact of other components in the generative process, such as the user query, previously generated tokens, the current token itself, and the final LayerNorm adjustment. To address this, we introduce SPAD. First, we mathematically attribute each token's probability into seven distinct sources: Query, RAG, Past, Current Token, FFN, Final LayerNorm, and Initial Embedding. This attribution quantifies how each source contributes to the generation of the current token. Then, we aggregate these scores by POS tags to quantify how different components drive specific linguistic categories. By identifying anomalies, such as Nouns relying on Final LayerNorm, SPAD effectively detects hallucinations. Extensive experiments demonstrate that SPAD achieves state-of-the-art performance

SPAD: Seven-Source Token Probability Attribution with Syntactic Aggregation for Detecting Hallucinations in RAG

TL;DR

SPAD tackles hallucinations in Retrieval-Augmented Generation by decomposing token probabilities into seven information sources and then aggregating these at the POS level to reveal syntax-driven anomalies. It delivers an exact probabilistic decomposition in a residual-transformer framework, uses logit-space head attribution to overcome non-linearity, and builds syntax-aware features that feed a fast, interpretable classifier. Across RAGTruth and Dolly benchmarks and multiple LLMs, SPAD achieves state-of-the-art or competitive results while offering mechanistic insight into when and why hallucinations arise. The method highlights signals beyond traditional FFN-RAG conflicts, including LayerNorm and user-query contributions, enabling more robust detection and potential real-time mitigation.

Abstract

Detecting hallucinations in Retrieval-Augmented Generation (RAG) remains a challenge. Prior approaches attribute hallucinations to a binary conflict between internal knowledge (stored in FFNs) and retrieved context. However, this perspective is incomplete, failing to account for the impact of other components in the generative process, such as the user query, previously generated tokens, the current token itself, and the final LayerNorm adjustment. To address this, we introduce SPAD. First, we mathematically attribute each token's probability into seven distinct sources: Query, RAG, Past, Current Token, FFN, Final LayerNorm, and Initial Embedding. This attribution quantifies how each source contributes to the generation of the current token. Then, we aggregate these scores by POS tags to quantify how different components drive specific linguistic categories. By identifying anomalies, such as Nouns relying on Final LayerNorm, SPAD effectively detects hallucinations. Extensive experiments demonstrate that SPAD achieves state-of-the-art performance

Paper Structure

This paper contains 37 sections, 2 theorems, 21 equations, 3 figures, 1 table.

Key Result

Theorem 1

The final probability for a target token $y$ is exactly the sum of the contribution from the initial embedding, the cumulative contributions from Attention and FFN blocks across all $L$ layers, and the adjustment from the final LayerNorm:

Figures (3)

  • Figure 1: Applying SPAD framework to a Llama2-7b response from RagTruth dataset niu2024ragtruth.
  • Figure 2: Overview of the SPAD framework. The attribution process consists of three progressive stages: (1) Coarse-Grained Decomposition: The final token probability is exactly decomposed into additive contributions from residual streams and LayerNorm components (Section \ref{['sec:decomposition']}). (2) Fine-Grained Attribution & Source Mapping: Attention contributions are apportioned to individual heads and subsequently mapped to four distinct input sources (Query, RAG, Past, Self) based on attention weights (Section \ref{['sec:attn_attr']}). (3) Syntax-Aware Feature Engineering: These source-specific attributions are aggregated by POS tags to construct the final syntax-aware feature representation for hallucination detection (Section \ref{['sec:source-mapping']}).
  • Figure 3: SHAP summary plots illustrating the decision logic. We visualize the top-10 features for classifiers trained on the RAGTruth subsets corresponding to Llama2-7B, Llama2-13B, and Llama3-8B. The x-axis represents the SHAP value, where positive values indicate a push towards classifying the response as a Hallucination. The color represents the feature value (Red = High attribution, Blue = Low).

Theorems & Definitions (5)

  • Theorem 1: Exact Probability Decomposition
  • proof
  • Proposition 1: Gradient-Based Linear Decomposition
  • proof
  • proof