Real-Time Hallucination Detection in Resource-Constrained LLMs via Logit-Level Shannon Entropy Mapping
Deploying Large Language Models (LLMs) on resource-constrained edge and consumer hardware presents severe reliability challenges due to the computational infeasibility of secondary evaluator models and multi-sample consensus mechanisms for hallucination mitigation. While state-of-the-art frameworks such as Semantic Entropy and SelfCheckGPT achieve strong detection accuracy in cloud environments, their reliance on K-fold stochastic generation and auxiliary Natural Language Inference (NLI) models multiplies memory bandwidth and latency by 5× to 10×, exceeding the strict memory envelopes of edge devices. This paper introduces a lightweight, single-pass telemetry framework that intercepts pre-softmax logit distributions during the auto-regressive forward pass to compute token-level Shannon Entropy (H(X)) in real time. Utilizing a custom C#/.NET visual diagnostic architecture (Forensic Canvas) interfaced via native P/Invoke hooks with a 4-bit quantized 8-billion-parameter model (Meta-Llama-3-8B-Instruct, Q4_K_M) executing entirely within an 8 GB RAM CPU environment, we demonstrate that structural and semantic hallucinations are consistently preceded by deterministic spikes in vocabulary probability dispersion. Empirical evaluations across 200 factual question-answering prompts derived from TruthfulQA and HaluEval benchmarks reveal that our single-pass logit entropy monitor achieves an Area Under the Receiver Operating Characteristic curve (AUROC) of 0.819, outperforming single-pass Maximum Softmax Probability (0.682) and Sequence Perplexity (0.714) while matching multi-pass SelfCheckGPT (0.815) at only 1.2 ms/token latency overhead and < 15 MB additional memory. Furthermore, we propose a deterministic “Entropy Kill-Switch” (τH = 4.5 bits) that proactively halts hallucinatory inference streams prior to factual divergence, reducing wasted auto-regressive compute cycles by 41.8% on power-limited edge hardware.
Authors
- Badar Munir (ORCID: https://orcid.org/0009-0002-1311-6398)
Publication Details
- Journal
- Zenodo (CERN European Organization for Nuclear Research)
- Published
- 2026-11-11
- DOI
- https://doi.org/10.5281/zenodo.24128928
- Primary Topic
- Topic Modeling
- Type
- preprint