Hallucination Detection on a Budget: Efficient Bayesian Estimation of Semantic Entropy

Kamil Ciosek, Nicolò Felicioni, Sina Ghiassian

Abstract

Detecting whether an LLM hallucinates is an important research challenge. One promising way of doing so is to estimate the semantic entropy (Farquhar et al., 2024) of the distribution of generated sequences. We propose a new algorithm for doing that, with two main advantages. First, due to us taking the Bayesian approach, we achieve a much better quality of semantic entropy estimates for a given budget of samples from the LLM. Second, we are able to tune the number of samples adaptively so that 'harder' contexts receive more samples. We demonstrate empirically that our approach systematically beats the baselines, requiring only 53% of samples used by Farquhar et al. (2024) to achieve the same quality of hallucination detection as measured by AUROC. Moreover, quite counterintuitively, our estimator is useful even with just one sample from the LLM.

Introduction

Large Language Models (LLMs) frequently generate "hallucinations"—responses that are linguistically fluent but factually incorrect. A robust method for detecting these errors is Semantic Entropy (SE). The core intuition behind SE is that high uncertainty in the meaning of generated responses indicates a lack of model confidence, which correlates with hallucination. If multiple independent samples from an LLM convey the same semantic meaning, the model is likely correct; if they diverge into multiple meanings, it is likely confabulating.

Despite its effectiveness, standard SE estimation is computationally expensive. It requires generating a large number of independent responses and performing quadratic comparisons to cluster them by meaning. This paper introduces a Bayesian framework to make SE estimation significantly more efficient, reducing the computational budget required for reliable hallucination detection.

Methodology

The proposed approach treats entropy estimation as a probabilistic inference problem rather than a frequentist counting task. The methodology incorporates three key innovations:

  1. Bayesian Dirichlet Modeling: The distribution of semantic meanings is modeled using a Dirichlet distribution. By employing a prior learned from training data, the estimator can reason about potential meanings that may not have appeared in a small sample set.
  2. Incorporating Sequence Probabilities: Unlike standard estimators that only consider the final text, this method utilizes the log-probabilities of the generated sequences. These probabilities are used to truncate the Dirichlet distribution, providing tighter bounds on the true entropy.
  3. Adaptive Sampling: To optimize compute, the authors implement a stopping rule based on the variance of the Bayesian belief. For prompts where the model is clearly certain, sampling stops early; for ambiguous prompts, more samples are drawn. This ensures that the computational budget is allocated where it is most needed.

Experimental Evaluation

The method was evaluated across four diverse benchmarks: TriviaQA (general knowledge), SQuAD (reading comprehension), SVAMP (math word problems), and Natural Questions (NQ) (search queries). The experiments utilized a variety of models, including Llama-2-7B, Llama-3.2-3B, Mistral-Small-24B, and Llama-3.3-70B.

Results and Discussion

The Bayesian estimator demonstrates substantial efficiency gains, requiring approximately 47% to 53% fewer samples than previous state-of-the-art methods to achieve comparable AUROC scores.

Performance comparison of SE-Bayes against baselines across various models and datasets for budgets of N=2 (top) and N=5 (bottom). SE-Bayes consistently achieves higher AUROC scores.

As shown in the experimental results, the Bayesian approach (SE-Bayes) consistently outperforms baseline estimators like Histogram and Rescaled SE, particularly at very low budgets ($N=2$ and $N=5$). Notably, the estimator remains useful even with a single sample ($N=1$) because it can infer the potential for alternative meanings from the sequence probabilities alone.

Furthermore, the results highlight the importance of measuring uncertainty in "meaning space" rather than "token space." By clustering semantically identical but lexically different responses, the Bayesian approach provides a more accurate reflection of model uncertainty in low-data regimes.

Conclusion

This work presents a "plug-and-play" solution for efficient hallucination detection that is robust to hyperparameter choices and significantly reduces GPU costs. While the method currently relies on an external entailment oracle (e.g., DeBERTa) for semantic clustering, future work could explore more expressive hierarchical priors to better capture the long tail of meanings in creative tasks. The release of derivative datasets with 100 generations per prompt will further enable the research community to iterate on efficient entropy estimators.

Summary updated

BibTeX
@article{ciosek2025hallucination,
  author = {Kamil Ciosek and Nicolò Felicioni and Sina Ghiassian},
  title = {{Hallucination Detection on a Budget: Efficient Bayesian Estimation of Semantic Entropy}},
  journal = {Accepted by TMLR},
  year = {2025},
  url = {https://openreview.net/forum?id=j2N2RuNdbC},
}
Figure