Search, Reflection, and Test-Time Compute › Worked Example
Language AI HandbookAll chapters Start with four problems to see how the coverage ceiling and the accuracy of two selection rules differ before we compare them on a larger simulated suite.
Take four problems with per-draw success probabilities . For each problem, draw times independently from its fixed distribution.
The coverage ceiling, , is:
| Problem | pass@5 | |
|---|---|---|
| A | 0.9 | 0.99999 |
| B | 0.6 | 0.98976 |
| C | 0.3 | 0.83193 |
| D | 0.1 | 0.40951 |
| Mean | 0.475 | 0.80780 |
A single sample averages 0.475, and an oracle selector over five samples averages 0.808. The number of generations goes up by a factor of five. The relative improvement in the coverage ceiling is
where:
- : the mean per-sample accuracy, the average of across the four problems
- : the mean coverage ceiling, the average of across the four problems
- : the relative improvement of the ceiling over the single-sample baseline
Now apply two selection rules to the five-draw pools.
An uninformative verifier. A random ranking gives the same expected accuracy as one draw, which is on each problem and 0.475 averaged over the suite.
Plurality voting with ten choices and uniform distractors. Exhaustively weighting the five-draw sequences with uniform tie-breaking gives accuracies of about 0.998, 0.883, 0.455, and 0.100 on A through D. The mean is 0.609, between the single-draw baseline and the oracle ceiling. On D all ten labels are equally likely, so the vote still has 0.100 expected accuracy.
The worked example assigns an equal chance to every tied leader. Label zero represents the truth only for enumeration. When zero ties with other leaders, the contribution is one divided by the number of leaders. The simulation later uses a lowest-label tie rule with randomly assigned true labels.
PythonIn [7]Expand
from itertools import product
from math import fsum
example_choices = 10
example_draws = 5
vote_weight_by_correct_count = [0.0] * (example_draws + 1)
for draw in product(range(example_choices), repeat=example_draws):
counts = [draw.count(label) for label in range(example_choices)]
correct_count = counts[0]
maximum = max(counts)
if correct_count == maximum:
vote_weight_by_correct_count[correct_count] += 1 / counts.count(maximum)
def exact_example_vote_accuracy(p):
wrong_label_p = (1 - p) / (example_choices - 1)
return fsum(
weight * p**count * wrong_label_p ** (example_draws - count)
for count, weight in enumerate(vote_weight_by_correct_count)
)
example_accuracy = [
exact_example_vote_accuracy(p) for p in (0.9, 0.6, 0.3, 0.1)
]
print(
"Five-draw plurality accuracy (A to D):",
", ".join(f"{a:.3f}" for a in example_accuracy),
)
print(f"Mean: {fsum(example_accuracy) / len(example_accuracy):.3f}")ConsoleOut [7]Expand
Five-draw plurality accuracy (A to D): 0.998, 0.883, 0.455, 0.100 Mean: 0.609
Allocation. Uniform costs 20 samples. The next-draw coverage gains are about , , , and on A through D. If the per-task success probabilities were known and the objective were oracle coverage, a sixth draw would buy the most on D.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!