Fact Grounded Attention: Eliminating Hallucination in Large Language Models Through Attention Level Knowledge Integration
Aayush Gupta
TL;DR
This work tackles the pervasive hallucination problem in large language models by introducing Fact Grounded Attention (FGA), an architectural modification that injects verifiable external facts directly into the transformer’s attention mechanism. FGA combines an external knowledge base with an attention-grounding matrix, a learnable gate to route factual grounding, and hard vocabulary constraints to guarantee deterministic correctness when KB coverage is complete. Empirically, FGA dramatically improves factual accuracy on 1,107 technical queries (from 6.3% baseline to 99.7% with fine-tuning) and enables instant knowledge updates in under a second, with only a small computational overhead (~3%). The approach yields strong gains on public benchmarks, offers traceability and domain adaptability, and lays a foundation for deterministic, knowledge-driven neural generation in knowledge-intensive domains. ${S}_{FGA} = S + \alpha \odot G$ and $B_{qf} = \frac{QK_{fact}^T}{\sqrt{d_k}}$ are central formulas governing grounding in the attention scores.
Abstract
"The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge." Large Language Models have conquered natural language but remain prisoners of their own probabilistic nature--confidently hallucinating facts they never truly knew. We present Fact Grounded Attention (FGA), a novel architectural modification that transforms unreliable language models into deterministic truth tellers by injecting verifiable knowledge directly into the attention mechanism. Unlike existing approaches that patch hallucinations after generation or prepend retrieved text, FGA intervenes at the mathematical heart of the transformer--the pre-softmax attention scores--creating a model that cannot hallucinate when facts exist in its knowledge base. Our experiments across 1,107 technical queries spanning smartphones, laptops, and electric vehicles demonstrate a transformation from 6.3% accuracy in vanilla Llama 3.2 to 99.7% accuracy with FGA. More critically, knowledge updates occur in under one second without retraining, compared to hours for parameter editing approaches. FGA doesn't just reduce hallucination--it eliminates it entirely for verifiable facts, marking a fundamental shift from probabilistic approximation to deterministic precision in neural language generation.
