Abstract
Hallucination detection in Retrieval-Augmented Generation (RAG) is a critical challenge for ensuring the reliability of Large Language Models (LLMs). We present SPAD (Seven-Source Token Probability Attribution with Syntactic Aggregation), a white-box framework that identifies hallucinations by mathematically decomposing a model's internal decision-making process. By attributing next-token probabilities to seven distinct architectural sources and aggregating these scores by part-of-speech (POS) tags, SPAD captures the unique mechanical "fingerprints" of hallucinations. Evaluated on the RAGTruth and Dolly (AC) benchmarks, SPAD achieves state-of-the-art performance, including an F1 score of 0.8702 on Mistral-7B, while providing human-interpretable insights into model behavior.
Introduction
While Retrieval-Augmented Generation (RAG) helps ground LLMs in external facts, models frequently "hallucinate" by ignoring retrieved context or over-relying on internal parametric memory. Current detection methods typically treat models as black boxes, focusing on output uncertainty or consistency. However, these methods often fail to capture the nuanced internal conflicts between a model's training data and the provided context. SPAD addresses this by moving beyond binary conflicts, analyzing how components like the user query, final LayerNorm, and specific linguistic categories (e.g., nouns vs. verbs) contribute to truthful or hallucinated generation.
Methodology
The SPAD framework operates through a three-stage pipeline designed to extract high-fidelity features from the model's internal activations.
- Coarse-Grained Decomposition: Using a technique similar to the "logit lens," the framework decomposes the final probability of a generated token into contributions from the initial embedding, attention blocks, Feed-Forward Networks (FFNs), and the final LayerNorm.
- Fine-Grained Attribution (7-Source Split): To resolve the internal workings of attention blocks, SPAD uses attention weights and logit-based apportionment to trace probability back to four specific inputs: the User Query, RAG Context, Past Tokens, and the Self Token. Combined with the coarse steps, this creates a comprehensive 7-source attribution vector for every token.
- Syntax-Aware Aggregation: Raw attribution scores are often noisy. SPAD utilizes Part-of-Speech (POS) tagging to group these scores, calculating the mean attribution profile for 18 linguistic categories. This results in a 126-dimensional feature vector (7 sources × 18 tags) that serves as the input for a final XGBoost classifier.
Results and Interpretability
SPAD achieved state-of-the-art (SOTA) performance across multiple benchmarks. On Mistral-7B, it reached an F1 score of 0.8702, outperforming the previous best method (Novo) by 7%. It also secured statistically significant "Rank-1" results on both Llama2-7B and 13B for F1 and AUC metrics.
A key advantage of SPAD is its interpretability. By applying SHAP (SHapley Additive exPlanations), we can visualize which architectural-syntactic features most strongly signal a hallucination.
Analysis of these features revealed that hallucination "fingerprints" are often model-specific. For example, in Llama2-7B, a high contribution from the final LayerNorm to numeral tokens is a strong hallucination signal, whereas in Llama2-13B, this same pattern correlates with factuality. By aggregating by POS tags, the detector learns to ignore benign internal knowledge usage (such as for grammar) and focus on anomalies in factual entities like Nouns and Proper Nouns.
Conclusion and Future Work
SPAD provides a robust, white-box approach to detecting hallucinations in RAG systems by leveraging the inherent relationship between model architecture and linguistic syntax. While currently requiring access to internal model weights and activations, it offers a level of precision and interpretability that black-box methods cannot match. Future research will focus on extending this attribution to phrase-level units and exploring real-time intervention strategies to mitigate hallucinations as they occur during the generation process.
Summary updated