Verification Is a Classification Problem, Not a Generation Problem
Part 21: How to check every answer against its evidence at query time, and why that check is a classification problem, with implementations
Recap
In Part 20, we measured what happens to retrieval quality after launch, as documents are revised and the embedding model is replaced.

With the ingest pipeline on a new model and the queries left on the old one, no question about a changed fact got its current block back in the top 10, from the first month on. No request failed.
A weekly run of the launch evaluation noticed the mixed index in week 1. A stamp checked on every write stopped it at the first new-model vector, for 0.112 µs per point.
With both revisions of a page in the index, dense search put the current block above its outdated twin about half the time.

Every check in Part 20 looked at the index. A current index brings the right passage back, and guarantees nothing about the answer written from it.
A generator can read the right passages and still write a sentence they do not support. The index, the latency and the retrieval evaluation look the same when it does.
Part 2 ran its faithfulness check offline, as an average over a test set. This part runs the same check on every answer, before the user sees it, and refuses the answer when a claim fails.

We build that gate and measure it on 1,219 questions about Halvern Logistics, the fictional company in Part 17's documents. About a quarter are answerable. For the rest, a refusal is a right outcome.
Along the way we measure:
- The wrong answers each step removes, from plain RAG to a gate on every claim.
- How well six judges separate supported claims from unsupported ones.
- A threshold that keeps wrong answers under a budget, with a bound that holds on new questions.
- What each judge costs, and what 50 answers a second would take.
- Longer answers, claims that need two passages, and outdated passages.
- What a generator knows about its own answers.
- Keeping the claims that pass instead of refusing the whole answer.
- Answers that six other models wrote, with labels people made.
You can run all of it from the code in the zip. The model outputs are cached in it, so every table rebuilds on a CPU.
We split the questions in half, one half to set the gate's threshold and the other, the test half, to measure the result.
On the test half, plain RAG with Qwen3-14B gave a wrong answer to 91 of 607 questions, most of them questions it should have refused or corrected.
Behind the full gate, with a 32-billion-parameter judge that reasons first, it answered 133 and got 3 wrong, 2.3 percent, under a 5.5 percent bound on its error rate, certified on the other half.
We also compared six judges, the generators' own confidence, and answers that six other models wrote.

By the end, you will have a gate that keeps wrong answers under a stated rate, and a way to certify that rate on your own answers.
Hallucination as selective prediction
A generator will sometimes be wrong. A better model or prompt lowers the rate, and none reaches zero on questions the documents cannot answer. A system can still choose which answers to give.
A classifier that may decline to answer is a selective classifier. It answers when a confidence score clears a threshold and abstains otherwise. Geifman and El-Yaniv (NeurIPS 2017) measure it with two numbers.
- Coverage is the share of questions answered.
- Selective risk is the share of answered questions that are wrong. An abstention lowers coverage and stays out of the risk.
Raising the threshold lowers coverage. With a score that ranks answers well, it lowers the risk too, and the risk-coverage curve traces that trade.
For a question-answering system, "wrong" depends on the question. We score every question as correct, wrong or abstained, in four strata.
- Answerable. The fact is in the corpus. Correct means the gold value and no other value of that kind.
- Near-miss unanswerable. A real entity, asked about something the corpus does not record for it. The right outcome is an abstention.
- False premise. The question presupposes a wrong value, such as why a trailer left at 06:17 when it left at 06:31. The true value is correct, and an abstention is also right.
- Off-topic. A question from the Natural Questions dataset that the corpus has nothing on. The right outcome is an abstention.

Near-miss questions are the hardest to refuse. The retriever finds the entity, so the passages look relevant, and the value the generator wants sits one row away in the same passage.
Each outcome gets the CRAG benchmark's score (Yang et al., 2024): +1 for correct, 0 for an abstention and −1 for a wrong answer.
An abstention scores 0 in every stratum, even where it is the right outcome. A system that refuses everything scores 0, and one that answers everything badly scores below it.
Part 2's prompts already told the model to say "I don't know!" when it did not know the answer, but nothing scored whether it did.
A gate in four steps
We build the gate one step at a time and score all four strata after each step.

- Plain RAG. Retrieve five passages and answer from them.
- An abstain token. The prompt asks for a citation after each sentence, and for the word ABSTAIN when the passages do not hold the answer. A deterministic check drops any citation outside the five passages.
- An evidence grade. The generator is asked whether the passages contain what the question asks for. The answer is withheld when the generator's probability of "yes" is below 0.5.
- A claim gate. The answer is split into claims, and a judge scores each claim against the passages. The answer is shown only if its weakest claim clears a threshold.
Step 2 only lengthens the prompt, and step 3 adds one short call. Step 4 needs a claim splitter and a judge call per claim.
The weakest claim decides, because one unsupported sentence is enough to make an answer wrong. That rule refuses more as answers grow longer, so we report coverage by the number of claims per answer.
The splitter turns each sentence into short claims that each state one thing, and each claim gets its own probability.

In this example the judge was wrong, because the passage is headed as an extract of the master haulage agreement, which supports the second claim.
At the threshold shown, a correct answer was refused.
No score the gate reports would flag an error like this.
Why verification is classification
Part 2's checker asked an LLM to explain each verdict before giving it: "Provide a brief explanation for each statement before arriving at a verdict (Yes/No)."
An offline report can afford that explanation. A gate in front of every answer pays for it in time and tokens. It also needs a number to set a threshold on, and an explanation is not a number.
The gate asks a yes-or-no question about two texts: do these passages support this claim? That is binary classification, and it comes with a standard toolkit for measuring a classifier and choosing its threshold.
Every judge here turns a claim and its passages into one probability that the claim is supported, in one of five ways.

- A generator judging with yes or no. Qwen3-4B and Qwen3-14B answer "yes" or "no". The probability comes from the first token's log-probabilities over those two words, so it takes one forward pass and one token.
- A judge that reasons first. Qwen3-32B writes up to 1,024 tokens of reasoning, then a verdict, and the probability is read from the verdict token. This is Part 2's checker, made to give a number.
- An NLI model. A DeBERTa-v3 model trained on natural language inference reads each passage as a premise and the claim as a hypothesis. The claim gets its highest entailment probability over the passages.
- MiniCheck. A Flan-T5 model trained by Tang, Laban and Durrett (EMNLP 2024) to check claims against documents. It reads the passages in chunks of up to 500 words and keeps the best chunk's support probability.
- A decision model. A 2-billion-parameter model built to answer yes-or-no questions about a context. Its readout head returns a probability of "yes" without generating text, and its model card calls that probability calibrated.
The 32B model also judges every claim a second time with its reasoning switched off, answering yes or no at once. Comparing the two runs shows what the explanation buys on the same weights.
Where the lesson says the 32B judge without naming a run, it means the one that reasons first.
A probability is only useful if it ranks claims well and means what it says. Three measures check that:
- AUROC, the probability that a randomly chosen supported claim scores higher than a randomly chosen unsupported one, with ties counting half. It reads the ranking only, so it is the same for any threshold. An AUROC of 0.5 is a coin flip, and 1.0 a perfect ranking.
- Balanced accuracy at 0.5, the mean of the share of supported claims scored at or above 0.5 and the share of unsupported claims scored below it. It is the headline measure of LLM-AggreFact, the benchmark introduced with MiniCheck.
- Expected calibration error (ECE), as Guo et al. (ICML 2017) compute it. Group the claims into 15 bins by probability, and in each bin compare the mean probability with the share supported. ECE is the weighted mean gap.

A judge can rank well and still be miscalibrated. Ranking decides how much a threshold can separate. Calibration decides whether 0.9 can be read as nine in ten, which matters when a threshold is chosen by hand.
A threshold with a guarantee
Where to set a gate's threshold is a product decision. A higher threshold refuses more answers, and the answers that remain are safer.
This section is the one piece of statistics the gate needs. It is short, and the panel at its end lets you try it.
Picking the threshold by eye on the test questions would report a risk that new questions would not reproduce. So we split the questions in half, by stratum and by the kind of fact asked about.
The threshold is chosen on the calibration half, and every risk and coverage we report comes from the test half.
On the calibration half, each candidate threshold answers some questions and gets some of them wrong.
From n answers with k wrong, the Clopper-Pearson bound gives the highest true risk that could plausibly have produced a result this good.
"Plausibly" needs a level. At a level of 5 percent, the bound is the highest error rate under which seeing k or fewer wrong in n answers still has a probability of at least 5 percent.
Above that rate, a result this good would have less than a 5 percent chance.
We test 15 thresholds, from 0.99 down to 0.01, fixed before any run.
Testing many thresholds makes it likelier that one passes by luck, so each bound uses a level of a third of a percent, 0.05 divided by 15.
This is Learn then Test (Angelopoulos et al., 2021) with a Bonferroni correction. A threshold passes when its bound is within the budget, the highest share of wrong answers the product will accept, and the gate keeps the lowest one that passes, since it answers the most.
With probability at least 95 percent over the draw of the calibration half, every passing threshold's true risk on questions like these is within the budget.
All 15 bounds hold together, so the lowest of them is a guarantee too, with no budget fixed in advance. For each pair of a generator and a judge, we call the threshold that reaches it the certified threshold, and that bound the certified bound.
A search at a fixed budget keeps the lowest threshold that passes, and we call the one kept at a 10 percent budget the 10 percent threshold. The two can differ. For Qwen3-14B with the 32B judge reasoning first, both are 0.01. With NLI, the 10 percent threshold is 0.01, and the lowest bound comes at a threshold of 0.95.
At a threshold of 0.01, Qwen3-14B with the 32B judge reasoning first kept 140 calibration answers, 1 of them wrong.

The bound depends on how many questions were answered. With no wrong answers, a 5 percent budget needs at least 112 answers at this correction.
With 1 wrong answer, a 5 percent budget needs at least 155 answered calibration questions at our correction. After step 3, before the claim gate refused any, Qwen3-4B had answered 166 and Qwen3-14B 147, the most any threshold could keep.
Our calibration half has 612 questions, but for nearly three in four of them a refusal is a right outcome, so far fewer come through as answers.
Labels no judge produced
Measuring a judge needs claims whose answer is known without asking a judge.
Every label here comes from the corpus's own structured facts.
Each of the 326 facts has an entity, a kind, a value and the passage that states it, and no two facts share a value.
That makes most claims checkable by string rules.

- A claim that gives a fact's value with that fact's entity, with the fact's passage retrieved, is supported.
- A claim that gives one entity's value to another, a value under another date, or a value or name that appears in neither the passages nor the question is unsupported.
- Anything else, such as a claim about the passages themselves, is left unlabelled and kept out of the judge metrics.
A stress set adds two claims for every fact: a paraphrase of it, which is supported, and an edit of it, which is not. An edit swaps the entity, swaps the value or negates the sentence.
Rules can be wrong, so we audited them.
We drew 200 claims at random, half from the gate and half from the stress set.
Two independent passes, each blind to the labels and to the other, checked every claim against its passages.
A label counted as wrong when both passes disagreed with it and the passages bore the passes out, so the count below is a floor.
Of the 200, 7 labels were wrong, all of them "supported". Of those, 4 claims gave a logged value under the wrong day, and 1 gave a trailer's temperature as a distance.
Those were gaps in two rules, and we fixed the rules rather than the labels, which changed 18 labels across all claims.
The other 2 added a condition the passages do not state, such as a place, which no string rule here can see. They stay wrong, and the stress half of the sample had no wrong label.
Labels made from rules can also give themselves away in the wording. A classifier that reads only the claim, never the passages, tests for that.
Hands-on
Every model in this part is open.
The language models ran in Kaggle notebooks with two NVIDIA T4 GPUs, and everything else ran on a cloud VM with 16 vCPUs, apart from the NLI and MiniCheck scores of Experiments 6 and 7, which ran on a T4.

Experiments 6 and 7 ran the same path in three more GPU sessions, which the README calls E to G, as did the claims whose sentence number named no sentence (Step 4).
On 300 of the gate's claims scored on both, the T4's NLI and MiniCheck scores were within 0.005 of the CPU's.
Setup
To get started, download this particular project zip file and open it in the terminal.
