Forward Deployed EngineeringAI EngineeringTest-time Compute
Spend a 1000-token test-time budget on a math problem: process-reward scoring with tree search.
Question 73 of 73 · Updated
On this page
Interview-ready answer#
I would treat the 1,000 tokens as a shared inference-time budget, not give every candidate solution 1,000 tokens. Generate a few distinct approaches, score intermediate mathematical steps with a process reward model (PRM), prune weak branches and spend the remaining budget finishing and verifying the strongest candidates.
For a tight budget, I would start with bounded beam search or best-first search rather than a large Monte Carlo tree search (MCTS). Reserve tokens for final verification and presentation before expanding any branch. A high process score is evidence that a reasoning step looks correct, not a proof that its final answer is correct.
1. Allocate the budget before searching#
Assume the limit covers all generated tokens across the solver, any generative judge and final response, including counted reasoning tokens where applicable. A non-generative PRM's scoring passes and prompt prefill still consume compute and time; track these separately. If the customer means 1,000 total input plus output tokens, repeated input and scorer context must also be charged, and the allocation needs to change.
| Stage | Allocation |
|---|---|
| Explore three distinct approaches, up to 100 tokens each | 300 |
| Expand two promising branches, up to 200 tokens each | 400 |
| Repair or investigate a disagreement | 100 |
| Verify completed candidates | 100 |
| Present final solution | 100 |
| Total | 1,000 |
These are illustrative maximum allocations, not measured model token counts. The scheduler charges actual usage across all calls and caps generation using the model's tokenizer or returned usage. Reallocate unused tokens only within the total budget. Do not start an expansion that could consume the reserved verification and answer tokens.
2. Search at mathematical step boundaries#
A node contains a partial solution, the mathematical state it has established, its process scores and its consumed token count. A child adds one meaningful step, such as a substitution, a case split or a derived equation.
An outcome reward model scores a complete solution; a PRM evaluates intermediate steps conditioned on the preceding reasoning. A PRM trained to estimate step correctness may flag an invalid algebraic transformation before a branch wastes hundreds of tokens. Some models instead predict future success from prefixes; the search policy must match the actual score semantics.
Use hard mathematical checks to reject provably invalid steps. Among valid candidates, prioritize likely correctness, diversity and estimated remaining token cost. For example, rank by a calibrated estimated probability of successful completion per expected token needed. If only local step scores are available, use a conservative path-ranking heuristic such as the lowest step score or a length-aware log-score aggregate. Multiplying arbitrary PRM scores and calling the result a calibrated success probability is unjustified.
A low score alone need not prove a step wrong. Preserve some diversity because a biased PRM can prune an unconventional but correct solution.
3. Worked example: count five-digit even numbers#
Problem: How many five-digit even integers can be formed using the digits 0, 1, 2, 3, 4 and 5 without repetition?
The first exploration stage proposes three approaches:
| Branch | First reasoning step | Illustrative PRM score | Decision |
|---|---|---|---|
| A | Separate the last digit into 0 versus 2 or 4 | 0.95 | Expand |
| B | Count even-ending strings, then subtract leading-zero strings | 0.91 | Expand |
| C | Choose any even last digit and assume all remaining positions are unrestricted | 0.30 | Prune or repair |
Branch C ignores the leading-zero restriction. The scores are hypothetical, not outputs from a trained PRM.
Branch A — case split
If the last digit is 0, the other four positions use four of the five nonzero digits: 5 × 4 × 3 × 2 = 120.
If the last digit is 2 or 4, there are two choices for the final digit, four valid nonzero choices for the first digit and 4 × 3 × 2 ways to fill the middle three positions.
Total = 120 + 2 × 4 × 4 × 3 × 2 = 312.
Branch B — subtract invalid strings
There are three choices for the even last digit and 5 × 4 × 3 × 2 ways to fill the other positions before applying the leading-digit restriction. This gives 360 strings.
Invalid leading-zero strings must end in 2 or 4. Their count is 2 × 4 × 3 × 2 = 48.
Total = 360 − 48 = 312.
Both branches agree. Verify independently by enumerating permutations in a bounded deterministic tool and counting those whose first digit is nonzero and last digit even. The answer is 312. In this simple example no repair is necessary, so unused search tokens can remain unspent.
Local verification: 36 enumeration checks across digit-set sizes 2–9 and valid lengths 2 through the set size, two independent formulas for the worked problem, and one budget-sum check passed (39 checks total). This validates the combinatorics and illustrative allocation, not PRM accuracy or actual inference-token usage.
4. Choose the search strategy for the budget#
| Strategy | When to use |
|---|---|
| Best-of-N | Independent short solutions are cheap and a reliable final verifier exists |
| Beam search | Intermediate steps are informative; keep a small number of distinct paths |
| Best-first search | Branches differ in expected value, remaining cost or depth |
| MCTS | Larger budgets justify repeated rollouts to estimate downstream success |
Under 1,000 tokens, two strong independent paths and a final check may outperform spending the entire allowance on a wide search tree. Difficult problems may benefit from deeper exploration, while easy ones should terminate early. Prefix/KV reuse can reduce repeated prefill when supported, but it does not replenish the generated-token allowance.
5. Verify the system, not just the reward score#
Evaluate on held-out math problems with independently checked answers and, where appropriate, proof or derivation checks. Compare greedy generation, best-of-N and PRM-guided search under the same total generated-token cap. Measure answer accuracy, verifier false acceptance, budget overruns, total accelerator time and latency. Also measure how often the PRM prunes a branch that could have reached a correct answer.
The practical objective is verified success per unit of inference compute. A more elaborate search is only valuable if it improves actual correctness under the customer's budget; agreement between branches is helpful but can still reflect shared errors.
Related questions
Explore other topics:AI AgentsAI System DesignLarge Language Models