Search

Search papers and lessons

Solution Verifier

Level 4 · 10 min read

A solution verifier is a model trained to judge whether a finished answer is correct, so a system can sample many answers and keep the one the verifier trusts most.

On this page

  • Colour = topic mix
  • Discrete math
  • Calculus
  • Probability
  • Neural network basics
  • Linear algebra
  • Post-training
  • ReadReady to readNot yet

TL;DR

A solution verifier is a model that reads a finished answer to a problem and estimates the Probability that the answer is correct. It is trained on answers whose correctness is already known, so it learns to tell right answers from wrong ones. A system can then generate many candidate answers, score each with the verifier, and keep the one with the highest score.

Builds on: Best-of-N Sampling, Cross-Entropy Loss, Sigmoid Function · Leads to: process reward models (the step-level extension), reward models (the preference-trained alternative)

Where it's used

Language models make mistakes on multi-step problems, and a single sampled answer is often wrong even when the model can produce the right one. A verifier turns that spare capacity into accuracy: sample many answers, let the verifier pick. The idea was made concrete in 2021 by Cobbe and co-authors at OpenAI, who trained verifiers on about 8,500 grade-school math word problems (the GSM8K dataset). They reported that a verifier chosen from many samples beat a fine-tuned model that answered only once. Since then, sampling-and-verifying has become a standard way to spend extra compute at test time on math and code, where a candidate can be checked.

How it works

A generator that samples one answer gives an answer with some chance of being correct, call it pp. Sampling NN answers (best-of-N sampling) raises the chance that at least one is correct, but someone must still choose which one to report. Choosing by majority vote needs no extra model, but it fails when the right answer is rare among the samples. Choosing by a scorer needs a scorer that can tell right from wrong on answers it has never seen, and that is what the verifier is trained to do.

  1. Collect labelled answers. For each training problem, sample several answers from a generator and check each final answer against the known correct result. Each answer gets a label: correct or incorrect.
  2. Give the verifier one answer at a time. The verifier reads the problem and one candidate answer, and produces one number, a score ss.
  3. Turn the score into a probability. A sigmoid maps the score to a number between 00 and 11. Read that number as the verifier's estimate that the answer is correct.
  4. Train with cross-entropy. Compare the estimate with the label. The loss is large when the verifier is confident and wrong, and small when it is right. Gradient descent adjusts the verifier's weights to lower this loss over all labelled answers.
  5. Use the verifier at test time. For a new problem, sample NN answers, score each one, and report the answer with the highest estimated probability.

Tiny instance of step 3 and 4. Suppose the verifier has one feature, x=1x = 1 when every arithmetic check in an answer passes and x=0x = 0 otherwise, plus a bias. Start with weight 00 and bias 00, so the first estimate is 0.50.5 for every answer. A correct answer with x=1x = 1 gives an error of 0.5−1=−0.50.5 - 1 = -0.5. After one step of size 11, the weight and bias both become 0.50.5. The new estimate for that answer is σ(0.5+0.5)=σ(1)=0.731\sigma(0.5 + 0.5) = \sigma(1) = 0.731. Check: the estimate moved from 0.50.5 toward the label 11, as it should.

flowchart LR
  A["Problem"] --> B["Generator samples N answers"]
  B --> C["Verifier scores each answer"]
  C --> D["Keep the highest score"]
  D --> E["Reported answer"]

The math

Step 3 in symbols: the score and the estimate

Let the verifier map a problem and an answer to a score s=wTϕ(q,a)+bs = w^{T}\phi(q, a) + b, where ϕ(q,a)\phi(q, a) is a feature vector and ww, bb are learned. The estimated probability of correctness is

p(q,a)=σ(s)=11+e−s.p(q, a) = \sigma\bigl(s\bigr) = \frac{1}{1 + e^{-s}}.

Here σ\sigma is the sigmoid, which maps any real score into the open interval from 00 to 11. The form is that of logistic regression applied to learned features ϕ(q,a)\phi(q, a).

Step 4 in symbols: the training loss

Each labelled answer has a label y=1y = 1 if the answer is correct and y=0y = 0 otherwise. The cross-entropy loss for one answer is

L=−[ylog⁡p+(1−y)log⁡(1−p)].L = -\bigl[y\log p + (1 - y)\log(1 - p)\bigr].

Over a dataset of labelled answers, training minimises the average of LL. The gradient of this loss with respect to the score ss is p−yp - y, so the update is w←w−η (p−y) ϕw \leftarrow w - \eta\,(p - y)\,\phi and b←b−η (p−y)b \leftarrow b - \eta\,(p - y), where η\eta is the learning rate.

Step 5 in symbols: choosing among samples

Given NN samples a1,…,aNa_1, \ldots, a_N for a problem qq, the reported answer is

a^=arg⁡max⁡i  p(q,ai).\hat a = \arg\max_{i}\; p(q, a_i).

If the verifier were perfect and the samples were independent with success probability rr each, the chance that the reported answer is correct would be the chance that at least one sample is correct:

P(at least one correct)=1−(1−r)N.P(\text{at least one correct}) = 1 - (1 - r)^N.

This is the ceiling a verifier can reach. A real verifier falls short of it, and the samples are not independent.

Worked examples

Example
Example 1: one gradient step on one answer (tiny)
  1. Start with w=0w = 0 and b=0b = 0. The score is s=0s = 0 for every answer, so p=σ(0)=0.5p = \sigma(0) = 0.5.
  2. Take a correct answer with feature x=1x = 1. Its label is y=1y = 1.
  3. Compute the loss. L=−log⁡(0.5)=0.693L = -\log(0.5) = 0.693.
  4. Compute the gradient factor. p−y=0.5−1=−0.5p - y = 0.5 - 1 = -0.5.
  5. Update with learning rate η=1\eta = 1. The weight becomes w=0−1×(−0.5)×1=0.5w = 0 - 1 \times (-0.5) \times 1 = 0.5, and the bias becomes b=0−1×(−0.5)=0.5b = 0 - 1 \times (-0.5) = 0.5.
  6. Compute the new score. s=0.5×1+0.5=1s = 0.5 \times 1 + 0.5 = 1.
  7. Compute the new estimate. p=σ(1)=0.731p = \sigma(1) = 0.731.
  8. Recompute the loss. L=−log⁡(0.731)=0.313L = -\log(0.731) = 0.313, down from 0.6930.693.
  9. Interpret. One step moved the estimate toward the correct label and reduced the loss, which is all gradient descent promises for a single example.
Example
Example 2: choosing among four candidates (standard)

A verifier gives these scores to four sampled answers: s=(2.0,−1.0,0.5,−0.5)s = (2.0, -1.0, 0.5, -0.5).

  1. Convert each score with the sigmoid. σ(2.0)=0.8808\sigma(2.0) = 0.8808.
  2. Continue the conversions. σ(−1.0)=0.2689\sigma(-1.0) = 0.2689, σ(0.5)=0.6225\sigma(0.5) = 0.6225 and σ(−0.5)=0.3775\sigma(-0.5) = 0.3775.
  3. Pick the largest estimate. It is 0.88080.8808, from the first candidate.
  4. Report that answer, and note the stakes. If the first answer was in fact wrong, its loss under cross-entropy would be −log⁡(1−0.8808)=−log⁡(0.1192)=2.127-\log(1 - 0.8808) = -\log(0.1192) = 2.127. A confident wrong answer is expensive during training, which is why the loss pushes the verifier to be careful.
  5. Interpret. The selection did not need the estimates to be calibrated, only ordered correctly. A verifier that ranks the correct answer above the wrong ones is useful even if its numbers are off.
Example
Example 3: how many samples are worth it (realistic)

Suppose a generator solves a given problem correctly with probability r=0.3r = 0.3 on each independent sample, and a verifier could pick out a correct sample whenever one exists.

  1. Write the ceiling for NN samples: 1−(1−r)N=1−0.7N1 - (1 - r)^N = 1 - 0.7^N.
  2. For N=4N = 4: 0.74=0.24010.7^4 = 0.2401, so the ceiling is 0.75990.7599.
  3. For N=8N = 8: 0.78=0.057650.7^8 = 0.05765, so the ceiling is 0.94240.9424.
  4. Compare. Going from 4 samples to 8 doubles the compute and raises the ceiling by about 0.180.18.
  5. Interpret. The gain is real but shrinks as NN grows, and the number is an upper bound. Samples from one model on one problem are correlated, so the true ceiling is lower.

Try it: a generator has r=0.1r = 0.1. How many samples NN are needed for the ceiling to reach 0.90.9?

Answer: we need 1−0.9N≥0.91 - 0.9^N \ge 0.9, so 0.9N≤0.10.9^N \le 0.1. Then N≥ln⁡(0.1)/ln⁡(0.9)=2.303/0.1054=21.9N \ge \ln(0.1)/\ln(0.9) = 2.303/0.1054 = 21.9, so N=22N = 22 samples.

Common mistakes and tradeoffs

It is tempting to think a verifier is the same as a reward model. In fact a reward model is usually trained on human preference comparisons between two answers, while a verifier is trained on whether an answer is correct. The two can be combined, but they answer different questions.

It is tempting to think a high verifier score means the answer is right. In fact the score is an estimate. A verifier can learn surface cues such as length or formatting that correlate with correctness in its training data, and then fail on answers that look different.

It is tempting to think a verifier that checks only the final answer is enough. In fact a correct final answer can come from wrong step-by-step reasoning. A process reward model scores each step and can locate the error, at the cost of step-level labels.

When to use a learned verifier: you have many answers to score, you have labels for correctness, and no exact checker exists. When not to use it: when a program can check the answer exactly, such as running unit tests or recomputing arithmetic, because an exact check is more reliable and cheaper. Alternatives include majority voting over samples, which needs no extra model but fails when the right answer is rare, and the reward-model route, which needs preference data rather than correctness labels.

History

Choosing the best of several outputs with a learned scorer is much older than language models. Reranking candidate translations or parses with a trained scoring function was common in machine translation and parsing long before 2021. The new step in the verifier work was training the scorer on whether a whole solution was correct, and then using that score to choose among many samples from a large generator.

Recap

  • A solution verifier estimates the probability that a finished answer is correct, using a sigmoid over a learned score.
  • It is trained with cross-entropy on answers labelled correct or incorrect, the same loss used for any binary classifier.
  • At test time, sample NN answers (best-of-N) and keep the one with the highest estimate. The gain is bounded by 1−(1−r)N1 - (1 - r)^N for a perfect verifier.
  • Its limits are surface cues and final-answer-only scoring. Read next: process reward models for step-level scoring, and reward models for the preference-trained alternative.

Check yourself

QuestionRecall: what does a solution verifier output for one answer, and what is that output read as?Show answer
A single score, passed through a sigmoid to give a number between 0 and 1. The number is read as the verifier's estimated probability that the answer is correct.
QuestionComputation: a verifier gives an answer the score s=0s = 0. What is its estimated probability, and what is the cross-entropy loss if the answer is actually correct?Show answer
The sigmoid of 0 is 0.50.5. The loss for a correct answer is −log⁡(0.5)=0.693-\log(0.5) = 0.693.
QuestionWhy: why does choosing the answer with the highest score need the verifier to rank answers well, not to give exact probabilities?Show answer
Selection by argmax only uses the order of the scores. A verifier that puts correct answers above incorrect ones will pick a correct one even if its probabilities are miscalibrated. Calibration matters for other uses, such as deciding how much to trust one answer.
QuestionApplied: a team uses a verifier trained on short arithmetic answers and then deploys it on long multi-step proofs. Give one reason its scores might mislead them.Show answer
The verifier may have learned cues that hold for short answers, such as their length or format, and these cues may not indicate correctness for long proofs. The scores then reflect the surface style of the answer rather than its correctness. A held-out check on the new kind of problem would reveal this before deployment.

Sources