Semantic Entropy
Semantic entropy measures an LLM's uncertainty over the meanings of its sampled answers rather than their wording, flagging likely confabulations.
Semantic entropy is a measure of how uncertain a large language model (LLM) is about the meaning of its answer, computed by sampling several answers to the same question, grouping those that say the same thing, and taking the entropy over the groups. If ten samples phrase one answer ten ways, semantic entropy is zero; if they give three different answers, it is high, and the model is likely guessing. Lorenz Kuhn, Yarin Gal, and Sebastian Farquhar at the University of Oxford introduced it at ICLR 2023 in Semantic Uncertainty: Linguistic Invariances for Uncertainty Estimation in Natural Language Generation, and a 2024 Nature paper by Farquhar, Jannik Kossen, Kuhn, and Gal applied it to detecting hallucinations.
The Nature paper targets one kind of hallucination, which it calls confabulation: claims that are both wrong and arbitrary, changing with the random seed used for sampling. Ordinary entropy over the generated tokens cannot isolate it, because "Paris", "It's Paris", and "The capital is Paris" are different token sequences with one meaning, so a model that knows the answer still looks uncertain.
How Semantic Entropy Is Computed#
- Sample about 10 answers to the same prompt with a nonzero sampling temperature.
- Cluster the answers by bidirectional entailment: two answers share a meaning if each one implies the other, as judged by a natural language inference model such as DeBERTa-large-MNLI or by a general LLM, which was GPT-3.5 in the main Nature experiments. This step is a form of natural language understanding (NLU).
- Estimate each cluster's probability by summing the sequence probabilities of its answers, or, when a closed API hides token probabilities, by the share of samples in the cluster, a variant called discrete semantic entropy.
- Compute the entropy over the cluster probabilities.
Discrete semantic entropy needs only the answers and their clusters. The snippet below compares it with naive entropy over the raw strings for two questions, with clusters assigned as an entailment model would assign them:
from collections import Counter
from scipy.stats import entropy
# Five sampled answers per question, and the meaning cluster entailment checks assign to each
samples = {
"Capital of Australia?": (
["Canberra", "Canberra.", "It's Canberra.", "Canberra, ACT", "Canberra"],
["Canberra"] * 5,
),
"Year Canberra was founded?": (
["1913", "In 1913.", "1908", "1927", "1913"],
["1913", "1913", "1908", "1927", "1913"],
),
}
for question, (answers, meanings) in samples.items():
# Naive entropy counts distinct strings; semantic entropy counts distinct meanings
naive = entropy(list(Counter(answers).values()), base=2)
semantic = entropy(list(Counter(meanings).values()), base=2)
print(f"{question} naive: {naive:.2f} bits, semantic: {semantic:.2f} bits")Both questions produce four distinct strings out of five samples, so naive entropy is 1.92 bits for each. Semantic entropy separates them: 0.00 bits for the capital, where every sample means Canberra, and 1.37 bits for the founding year, where the samples mix 1913, the correct year, with 1908, when the site was chosen, and 1927, when Parliament moved there.
Results and Limitations#
Across 30 combinations of question answering datasets (TriviaQA, SQuAD, BioASQ, NQ-Open, and SVAMP) and models (LLaMA 2 Chat, Falcon Instruct, and Mistral Instruct), semantic entropy separated wrong answers from right ones with an average area under the ROC curve (AUROC) of 0.790, against 0.691 for naive entropy and 0.698 for P(True), which asks the model whether its own answer is correct. On biographies that GPT-4 wrote about 21 people, split into 150 factual claims of which 45 were wrong, discrete semantic entropy also beat both baselines at flagging the false claims.
The method has clear limits:
- Cost: About 10 generations plus pairwise entailment checks per question. Semantic entropy probes, introduced by Kossen and colleagues in 2024, cut this to one generation by predicting semantic entropy from the model's hidden states.
- Consistent errors: A model that learned a misconception from its training data gives the same wrong answer every time, so semantic entropy stays low, and only a check against external sources, as in retrieval-augmented generation (RAG), exposes the error.
- Long answers: Paragraphs are first split into individual claims, as in the biography experiment, before their meanings can be compared.
Semantic entropy is one tool of uncertainty quantification for text. Perplexity scores how predictable a fixed text is to a model, self-consistency takes a majority vote over sampled chain-of-thought answers, and conformal prediction turns scores like these into sets with guaranteed coverage. Benchmarks such as Humanity's Last Exam measure the same gap from the other side, by comparing the confidence models state with how often they are right.
The same check applies to vision-language models (VLMs) that describe what a detector found. The Ultralytics LLM interface sends an image and a question to any OpenAI-compatible model and forwards request arguments unchanged, so a pipeline can ask the same question several times about an image in which YOLO26 detected an object of interest and cluster the descriptions it gets back.










