In this article
  1. Before you start
  2. Why interviewers ask this
  3. Detecting hallucinations with semantic entropy from first principles
  4. Worked example
  5. Trade-offs and edge cases
  6. How to answer it in an interview
  7. Common mistakes
  8. Follow-up questions
  9. Sources

Before you start

This topic is part of large language model (LLM) evaluation; the transformer overview explains how a model produces text one token at a time.

Why interviewers ask this

Any team that ships a large language model (LLM) feature has to decide when to trust an answer, and semantic entropy is a well-known research answer to that question. Interviewers use it to see whether a candidate can reason about uncertainty without a labelled answer key, and whether they know where the method stops working.

A weak answer says "it measures how unsure the model is." A strong answer explains why the raw token probabilities mislead, what the grouping step fixes, and what the score cannot see. A Staff-level answer adds the cost (several samples plus pairwise comparisons), names the cheaper variants, and says what to run next to the score: a golden set, retrieval checks, or a judge model.

Detecting hallucinations with semantic entropy from first principles

Confabulation
A confabulation is a fluent claim from a language model that is both wrong and arbitrary, meaning the answer changes with irrelevant details such as the random seed. It is the subset of hallucinations that semantic entropy targets, not every kind of error.
Semantic cluster
A semantic cluster is a set of sampled answers that mean the same thing, so each cluster stands for one distinct claim.

In plain words

Ask ten colleagues where the company party is. If nine say "Friday at the Harbour Hall" in nine different phrasings, you trust it. If they name four different venues, you do not, even though each sounded sure. The analogy breaks in one place: colleagues can be unanimous and wrong together, and so can a model.

In one precise sentence, semantic entropy asks the model the same question many times and measures disagreement in meaning, not in wording. The authors of the Nature paper (Farquhar et al., 2024) argue that the plain token-level entropy mixes two things: many ways to say one thing, and many different things to say. Only the second signals trouble.

Step 1: Sample several answers to the same question

Semantic entropy starts by asking the model the same question several times and keeping every answer. Input: one prompt. Output: a list of answers. The Nature paper samples at temperature 1 with nucleus sampling (probability mass 0.9) and top-K sampling (K of 50), and uses ten sampled answers per question.

Sampling is needed because a confabulation shows itself only as inconsistency: a key test is whether a different random seed gives a different answer. You now have a pile of answers; the next step decides which of them are really the same answer.

Step 2: Group the answers by meaning with bidirectional entailment

The grouping step puts two answers in one semantic cluster when each one entails the other. Entailment means that if sentence A is true, sentence B must be true; checking it in both directions is called bidirectional entailment. The Nature paper uses exactly this test to define a cluster.

Input: the list of answers (with the question as context). Output: clusters. A general language model can judge entailment, or a cheaper dedicated natural language inference (NLI) model can, as the Oxford blog post notes. This is the step that turns "Paris", "It is Paris." and "The capital is Paris" into one cluster. Skip it and every wording counts as a separate outcome. You now know how many distinct claims the model made.

Step 3: Measure the entropy over the clusters

Semantic entropy is the entropy of the distribution over clusters. In the discrete variant, each cluster's probability is its share of the samples: a cluster holding nc of M answers gets pc=nc/M. The score is

H=−∑cpclnpc

Input: cluster sizes. Output: one number in natural-log units (nats). The Nature paper describes this discrete form as ignoring token probabilities, so it needs only sampled text and works on models reachable only through an application programming interface (API). The full version instead sums the model's length-normalised sequence probabilities inside each cluster. One cluster gives zero; the more evenly answers spread over clusters, the higher the score.

Step 4: Read the score and decide what to do

A high semantic entropy marks the question as likely to produce a wrong answer, so the system can refuse, retry, retrieve more context or send the case to a person. A low value means the model is consistent, which is not the same as correct.

Input: the score and a threshold you choose on labelled data. Output: accept, flag or abstain. The Oxford blog post describes the area under the rejection accuracy curve (AURAC) as measuring how much accuracy improves when you refuse the questions you are most unsure about. That is the practical use: abstain on the uncertain tail, answer the rest.

Semantic entropy measures spread over meanings, not wordingsFlow of four stages: several answers are sampled for one question, answers that entail each other are grouped into meaning clusters, the entropy of the clusters is computed, and a high score flags an unreliable answer.Sampleanswerssame questionGroup bymeaningmutualentailmentEntropyover clustersFlag oraccepthigh isunreliableDiagram: Interview Clozo, CC BY 4.0 ·interview.clozo.ai/blog/detecting-hallucinations-in-large-language-models-using.html

Semantic entropy measures spread over meanings, not over wordings, so only real disagreement raises the score.CC BY 4.0 — source: Detecting hallucinations in large language models using semantic entropy
Step-by-step description
  1. Ask the same question several times.
  2. Answers that entail each other share a cluster.
  3. Measure the spread over clusters.
  4. A high score flags a likely wrong answer.
  • Several answers are sampled for one question.
  • Two answers share a semantic cluster when each one entails the other.
  • The entropy over the clusters is the semantic entropy.
  • A high score flags an unreliable answer.

Knowing it is half the job. Saying it is the other half.

Interview Clozo is an AI interview copilot for real interview rounds: it hears the question and puts a strong answer on your screen, and you say it in your own words. See the features or how it works.

Start Free Trial →

Worked example

Take one factual question and ten sampled answers (illustrative numbers). Group them by meaning, then apply the formula. The cluster sizes below are illustrative; the entropies follow by arithmetic.1

If all ten answers fall in one cluster, the score is 0. If eight agree and two give a different claim, it is 0.5004 nats. If the ten answers split 4, 3, 2 and 1 across four claims, it is 1.2799 nats, and the most any ten answers can score, ten different claims, is 2.3026 nats.1

Now the contrast that motivates the method. Suppose ten answers use ten different wordings of one fact. Naive entropy over the word strings sees ten distinct outcomes and scores 2.3026 nats, as high as ten different claims (this toy is the idealised case; the paper's naive entropy uses length-normalised sequence probabilities). Semantic entropy sees one cluster and scores 0.1

Ten paraphrases of one fact score zero semantic entropy but 2.3026 nats of naive entropy over strings, so grouping by meaning removes false alarms.
Case (ten answers, illustrative)Cluster sizesSemantic entropy (nats)
Consistent, one wording100
Ten wordings, one meaning100 (naive string entropy 2.3026)
Mostly agree8, 20.5004
Confabulation4, 3, 2, 11.2799
Every answer differentten clusters of 12.3026

Cost is visible here too. Comparing each new answer with one representative of each existing cluster takes between 9 pairs (all answers agree) and 45 pairs (all differ) for ten answers, each pair checked in both directions.1

A wider spread of meanings gives a higher entropy scoreBar chart of semantic entropy in nats for ten illustrative answers: 0 when all agree, 0.5004 for an 8 and 2 split, 1.2799 for a 4, 3, 2 and 1 split, and 2.3026 when every answer differs.Semantic entropy (nats)0123108, 24, 3, 2, 1ten of 1Cluster sizes of ten answers00.50041.27992.3026Diagram: Interview Clozo, CC BY 4.0 ·interview.clozo.ai/blog/detecting-hallucinations-in-large-language-models-using.html
The more evenly the ten answers spread across meanings, the higher the score; ten paraphrases of one meaning score zero.CC BY 4.0 — source: Detecting hallucinations in large language models using semantic entropy
Text description of the diagram
  • Ten answers in one cluster give a semantic entropy of 0.
  • An 8 and 2 split gives 0.5004 nats.
  • A split of 4, 3, 2 and 1 gives 1.2799 nats.
  • Ten different claims give 2.3026 nats.

Trade-offs and edge cases

Semantic entropy beats the simpler scores. Averaged across thirty combinations of tasks and models, the Nature paper reports that semantic entropy reaches an average area under the receiver operating characteristic curve (AUROC) of 0.790. Naive entropy, which takes the entropy over word sequences without grouping them by meaning, scores 0.691. P(True), which asks the model whether its own sampled answer is true, scores 0.698. The embedding regression baseline, which trains a small classifier on the model's embeddings to predict whether an answer is correct, scores 0.687.

AUROC is the chance that a randomly chosen right answer gets a lower uncertainty score than a randomly chosen wrong one: 0.5 is chance level, and 1.0 ranks every right answer above every wrong one. The averages are not per-question accuracy. The 0.790 average covers open models from three families (LLaMA, Falcon, Mistral) of 7 billion to 70 billion parameters; a separate experiment applied the discrete variant to generative pre-trained transformer (GPT)-4 (generative pre-trained transformer 4) on paragraph-length biographies.

Semantic entropy separates right from wrong answers bestBar chart of average AUROC over thirty task and model combinations reported by Farquhar et al. in 2024: semantic entropy 0.790, naive entropy 0.691, P(True) 0.698 and an embedding regression baseline 0.687.Average AUROC00.51SemanticNaiveP(True)EmbeddingMethod0.790.6910.6980.687Diagram: Interview Clozo, CC BY 4.0 ·interview.clozo.ai/blog/detecting-hallucinations-in-large-language-models-using.html
Averaged over thirty task and model pairs, semantic entropy separates right from wrong answers better than the baselines.CC BY 4.0 — source: Detecting hallucinations in large language models using semantic entropy
Text description of the diagram
  • Semantic entropy reaches an average AUROC of 0.790.
  • Naive entropy scores 0.691, P(True) scores 0.698 and the embedding regression baseline scores 0.687.

Edge cases and limits:

  • Consistent errors pass. The authors say the method does not ensure factual correctness, because it does not help when outputs are systematically bad. The Oxford post lists further blind spots: training that instilled a wrong style of reasoning, a new setting the training did not cover, and deliberate deception.
  • Clustering can be wrong. The Oxford post shows answers split by granularity, a specific date against a bare year, which makes a fine answer look uncertain. It also warns that "brain" and "central nervous system" can be wrongly merged, and advises checking real examples before production use.
  • Cost. You pay for extra samples plus pairwise entailment checks: for ten answers, between 9 and 45 cluster comparisons, each checked in both directions.1 Semantic entropy probes (SEPs), described by Kossen, Han, Razzak et al. (2024), are trained on the hidden states of one generation and need no extra samples at test time, which cuts the overhead to near zero.

Pair the score with other checks: a judge model, guardrails and, for retrieval systems, metrics such as those in Ragas.

How to answer it in an interview

Interviewer asks

How would you detect hallucinations in an LLM without labelled answers?

A strong answer

I would use semantic entropy. I sample several answers to the same question, group them by meaning using bidirectional entailment, and compute the entropy over the groups. Grouping matters because ten paraphrases of one fact would otherwise look uncertain. High entropy flags a confabulation, an arbitrary wrong answer. It misses consistent errors learned in training, and it costs extra samples and entailment checks, so I would pair it with a golden set and use it to decide when to abstain.

The spoken structure: sample, group by meaning, take entropy over groups, then name the blind spot and the cost.

Common mistakes

  • "Semantic entropy detects all hallucinations." (wrong) It targets confabulations, the arbitrary ones. (right) "It flags answers that change between samples; consistent errors need other checks."
  • "Low entropy means the answer is correct." (wrong) It means the model is consistent, and a consistently wrong answer scores low. (right) "Low entropy is necessary for trust, not sufficient."
  • "It is just token-level entropy." (wrong) Token entropy counts wordings as different outcomes. (right) "It takes the entropy over meaning clusters, which is why it beats naive entropy."
  • "It needs access to the model's logits." (wrong) The discrete variant needs only sampled text. (right) "Discrete semantic entropy works through an API."
  • "It is free." (wrong) It needs several samples and entailment checks. (right) "It trades extra compute for a better uncertainty signal."

Follow-up questions

What is semantic entropy?

Semantic entropy is the entropy of a model's answers measured over groups of equal meaning rather than over word sequences. It was introduced by Kuhn, Gal and Farquhar (2023) as an unsupervised method that uses one model and needs no changes to it.

What is the difference between a hallucination and a confabulation?

Hallucination is the broad term for output that is wrong or unsupported. A confabulation is the subset where the claim is wrong and arbitrary, which is the subset the method is built to detect.

How many samples do you need to compute semantic entropy?

The Nature paper uses ten sampled answers per question; fewer samples cost less but give a noisier estimate.

Does semantic entropy work on a model you can only call through an API?

Yes for the discrete variant, because it counts sampled answers per cluster and ignores token probabilities. The paper used it for all GPT-4 results.

Can semantic entropy catch a consistently wrong answer?

No. If the model gives the same wrong answer every time, there is one cluster and the score is zero. Use a golden set, retrieval grounding or a judge for those cases.

How do you make semantic entropy cheaper?

Use fewer samples, a small entailment model instead of a large one, or semantic entropy probes that estimate the score from one generation's hidden states.

Key takeaways
  • Semantic entropy samples several answers, groups them by meaning and takes the entropy over the groups.
  • It targets confabulations: answers that are wrong and change from sample to sample.
  • Grouping by bidirectional entailment stops paraphrases from looking like uncertainty.
  • Averaged over thirty task and model pairs, it scored 0.790 AUROC against 0.691 for naive entropy.
  • A low score means consistent, not correct; pair it with a golden set and expect extra cost.

Sources

  1. Detecting hallucinations in large language models using semantic entropy — Nature 630, 625-630 (Farquhar, Kossen, Kuhn, Gal), 19 Jun 2024
  2. Detecting hallucinations in large language models using semantic entropy (blog post) — OATML, University of Oxford, 19 Jun 2024
  3. Semantic Uncertainty: Linguistic Invariances for Uncertainty Estimation in Natural Language Generation (arXiv 2302.09664) — arXiv (Kuhn, Gal, Farquhar; ICLR 2023), 15 Apr 2023
  4. Semantic Entropy Probes: Robust and Cheap Hallucination Detection in LLMs (arXiv 2406.15927) — arXiv (Kossen, Han, Razzak et al.), 22 Jun 2024