Monte Carlo, TD, and Search
TL;DR — Every method in this part is an estimator for one quantity: the advantage , “how much better than average was that action”. You can estimate it from the full empirical return (Monte Carlo: unbiased, high variance, needs the episode to end) or from one step plus a bootstrapped value (TD: biased by the value function’s error, low variance). GAE interpolates between them with ; because LLM episodes are short and , all of the bias-variance burden sits on and on the value head. MCTS moves the same trade into inference time, spending forward passes to buy lookahead and using UCB1/PUCT to decide which branch deserves them. Each term of PUCT prevents a specific degenerate search.
1. Why this exists
Here is a failure. You train a policy with REINFORCE on a task where a correct response earns reward 1 and an incorrect one earns 0. The gradient for a response is its own return times the log-probability of each token in it. Since the return is 0 or 1, the gradient for a wrong answer is exactly zero — nothing is learned from errors, which is where most of the signal is. And for a correct answer, every token in a 400-token response, including the boilerplate and the “let me think step by step” preamble, receives the full credit.
Two problems, and they are different:
- The estimator has enormous variance. The return of a sampled trajectory is a single random draw. If the answer happened to come out right, the whole trajectory is reinforced; if it came out wrong, the whole trajectory is pushed down, by an amount that depends on the luck of the sample rather than on how good the reasoning was.
- There is no notion of “better than expected”. Reward 1 is good in absolute terms but says nothing about whether this action was better than what the policy would normally do here. A policy that already solves 90% of a problem set gets the same gradient on a solved problem as one that solves 10%.
The fix for both is the same object: subtract a baseline so that what you reinforce is the surprise, not the outcome. Doing that correctly requires the whole value-function vocabulary — return, value, action-value, advantage, the Bellman equations — and it requires deciding whether to estimate that baseline from observed returns or from a learned function. That decision is the Monte Carlo versus TD question, and it is the first half of this chapter.
The second half is a different way to spend compute on the same problem. Instead of asking “what is the average value of this state”, tree search asks “if I spend extra forward passes exploring the alternatives from this state, which action looks best”. That is MCTS, and the criterion it uses to allocate those passes is UCB1/PUCT — an algorithm that exists precisely because spending budget evenly is wasteful and spending it greedily is myopic.
Why this chapter is placed here. PPO (PPO for LLMs) is GAE plus a clipped ratio. GRPO (GRPO) is the decision to skip the value function and use the group mean instead. You cannot evaluate either choice without the estimator vocabulary below, and you cannot answer “is tree search worth it for reasoning” without the search half.
2. How it works
2.1 An autoregressive generation is an MDP
The mapping is exact, and almost every confusion in this part comes from moving between the RL object and the LLM object:
| RL object | LLM object |
|---|---|
| State | prompt + the first generated tokens |
| Action | the -th token (a vocabulary-sized discrete set) |
| Transition | deterministic: append the token. No environment randomness |
| Reward | for every ; the RM score or verifier result at |
| Horizon | response length, ended by EOS or a length cap |
| Policy | the LM’s next-token distribution |
| Episode | one prompt and one complete response |
Two consequences that trip people up:
- The transition kernel is known and trivial. “Model-based RL” is a strange framing for a single response: the next state is always the concatenation. All the interesting uncertainty in LLM RL is in the policy, not the environment.
- The reward is terminal and sparse. Zero everywhere except the last token. That single fact is why credit assignment is hard, why value heads are difficult to fit, and why process reward models were proposed at all (§2.10).
2.2 Return, value, action-value, advantage
- — the empirical return from step : everything the agent actually collected, summed. It is an observable, not a model, which is why Monte Carlo methods can use it directly.
- — the reward received steps after .
- — the terminal step. The sum stops at the end of the episode; there is no tail beyond it.
- — the discount factor, deciding how much a reward steps in the future counts, as .
- — the remaining horizon, so the number of terms varies with .
What does, and why removing it changes the problem. is horizon control: the exchange rate between a reward now and a reward later. makes the agent myopic — it maximises only the immediate reward and will not take a step that costs anything, even when that step leads to certain success. makes it patient, at the cost of a longer effective horizon and higher-variance returns. The effective horizon is roughly : gives 100 steps, gives 10.
Why LLM RL sets . A response is one bounded episode with the reward delivered at the end. Discounting it would make the objective depend on where the answer happened to end: the same correct answer would be worth if it ran long and if it ran short, so the policy would be rewarded for terseness on a task where length is irrelevant. Setting removes that artefact and removes the main variance-control knob, which is why in §2.6 carries the whole burden — and why “” appears in every LLM RL hyperparameter table.
- — the state value: the return you expect, on average, if you start in state and then behave according to . It is the baseline that makes a gradient about surprise rather than outcome.
- — the action value: the same expectation, conditioned on taking action right now and following afterwards.
- — the expectation over trajectories generated by . Both quantities are defined with respect to a policy; “the value of a state” is meaningless without saying whose policy.
- The conditioning is the only difference between and , and it is the difference between “how good is this position” and “how good is this move from this position”.
The advantage: how much better action is than the policy’s own average behaviour in state . It is the quantity every policy-gradient method needs, and it has one property that makes everything else work:
The policy-weighted average advantage is exactly zero. That identity is why you may subtract any baseline: replacing with for any that does not depend on the action leaves the gradient’s expectation unchanged, because
Subtracting a baseline therefore buys variance reduction for free. Two baselines appear in this part: (PPO, learned) and over a group of samples (GRPO, learned-free). Both are legitimate for exactly the reason above.
2.3 The Bellman equations, term by term
Bellman expectation equation — what must satisfy for a given policy:
- — the average over the policy’s own action choices. This is what makes the equation about this policy; swap it for a and you get the optimality version below.
- — the probability the policy takes action in state . Remove this weighting and the equation describes a deterministic policy, an assumption you do not want to bake in.
- — the expected immediate reward of taking in . It is an expectation because in a general MDP the reward may be stochastic even for a fixed state-action pair. In an LLM it is deterministic and zero except at the end (§2.1), so this term does almost no work here.
- — the discount. It is what makes the equation recursive and contractive: because , the right-hand side is a contraction mapping in , which is the mathematical reason value iteration converges.
- — the transition probability. In an LLM this is a point mass on the concatenated state, so the inner sum collapses to one term. That collapse is why LLM RL looks like a bandit if you squint and like a deterministic chain if you do not.
- — the same function, one step later. This self-reference is the whole content of the equation: value now equals reward now plus discounted value next, averaged over what happens next.
Bellman optimality equation — what the best value satisfies:
- — replaces the policy average. The optimal action maximises the bracketed quantity, and there is no averaging because a deterministic policy is optimal in an MDP. This is where greedy action selection comes from.
- Removing the gives the expectation equation back. Setting leaves a one-step greedy rule — the myopic policy that ignores consequences, which is exactly the failure mode §2.2 warned about.
Action-value and TD forms, which are the ones implementations touch:
- — the temporal-difference (TD) residual, or one-step surprise. The first two terms, , are the bootstrap estimate of the return: “what I got, plus what I now think the future is worth”. Subtracting — what I expected before acting — leaves the surprise. If , things went better than expected and the action should become more likely.
- The word bootstrap is doing real work: the target contains , the thing being estimated. That is what lets you learn without waiting for the episode to end, and it is what makes the target move as changes — a non-stationary regression.
2.4 Monte Carlo versus TD
Two estimators of the same quantity, at opposite ends of a trade-off:
| Monte Carlo | Temporal difference | |
|---|---|---|
| Target for | the full empirical return | |
| Needs the episode to end | yes | no |
| Bias | unbiased: | biased: the bias is the error in |
| Variance | high: a sum of random rewards | low: one reward plus one value estimate |
| Bootstrapping | no | yes |
| Where it appears here | REINFORCE, RLOO, GRPO’s terminal reward, GAE | PPO’s critic, GAE, every value-based method |
The structure is not symmetric, and it is worth being precise about why:
- Monte Carlo is unbiased but its variance grows with horizon. sums random rewards. In an LLM, where the reward is terminal and binary, that sum is a single Bernoulli draw — maximum variance for the information it carries. You also cannot update until the episode ends.
- TD is biased but its variance does not grow with horizon. Its error has two sources: the reward’s own noise (one step, not steps) and the bias from being wrong. In LLM RL the second dominates early, because the value head is freshly initialised and has to predict a terminal reward from a partial response.
The GAE paper’s own formulation separates the two regimes exactly:
GAE “is -just regardless of the accuracy of , but it has high variance due to the sum of terms”; GAE “is -just for and otherwise induces bias, but it typically has much lower variance”; is “a compromise between bias and variance, controlled by parameter ”. — Schulman et al. 2015, arXiv:1506.02438
Which side is LLM RL on? Deliberately mixed, and this is the design tension of the whole part. PPO + GAE bootstraps through the critic (TD). GRPO/REINFORCE-style methods use the terminal reward (MC) with a baseline that needs no learning. That is one reason the critic-free methods are more robust in practice for sparse-reward reasoning: there is no bootstrap target to be wrong. When you cannot fit a value function to a 32k-token chain of thought, the honest move is to stop pretending you can.
2.5 -step returns, and why interpolation is possible at all
- — how many real rewards you collect before switching to the bootstrap. is TD; (or beyond the episode end) is Monte Carlo.
- — the observed rewards.
- — the bootstrap term, discounted back to time by exactly the number of steps it sits in the future. Getting this exponent wrong (using instead of ) silently changes the effective horizon.
- Removing the bootstrap term makes it pure Monte Carlo; setting makes it pure TD. The family exists because intermediate is often better than either end: you trade a bounded amount of bias for a large reduction in variance.
TD() and GAE() average over all with geometric weights . The GAE paper states the analogy explicitly: its technique is “analogous to TD()”.
2.6 GAE: the dial, and what its endpoints actually are
Schulman et al. 2015, arXiv:1506.02438:
Symbol by symbol:
- — the reward at step . In the LLM adaptation this is per token: for every token except the last, plus the KL penalty at every token. The reward vector fed to GAE is therefore not sparse in practice, because the KL term is dense.
- — the discount, setting the problem’s horizon. In LLM RL .
- — the value estimate. Its error is the source of the bias: with a wrong , bootstrapping propagates the error along the trajectory.
- — the TD residual from §2.3: the one-step surprise.
- — the -step advantage estimate: the sum of the next TD residuals, each discounted by . At this is just .
- — the GAE decay, an exponential weighting over the -step estimators. The effective decay of the whole sum is , and this is the paper’s key structural point: changes the estimator’s bias-variance position without changing the problem’s effective horizon (which is ’s job). Two dials, two distinct purposes.
- — the normaliser that makes the weights sum to 1. Without it the sum is unnormalised and the advantage’s scale changes with , which would entangle with the learning rate.
- The infinite upper limit is not a modelling claim: past the end of the episode there is nothing to add, so the sum terminates at .
Reading the dial, with the endpoints derived rather than asserted.
collapses the geometric series to its first term:
“Trust the critic completely, react to one step.” Low variance, and biased by exactly the critic’s error. In LLM RL this is the worst regime, because is always bad early: the value head is freshly initialised and must predict a terminal reward from a partial response. A biased-by- estimator with a random is not a gradient, it is noise with a direction.
makes the weights degenerate, so read the final form. With and , the sum telescopes:
which is exactly Monte Carlo return minus a baseline. So the endpoints are literally the two estimators of §2.4: is one-step TD, is Monte Carlo with a baseline. GAE is the family between them, parametrised so that you can dial the trade without touching .
Why the intermediate value is used. Neither endpoint is acceptable: is dominated by critic bias you cannot remove, and has the variance of a full return sum with no bootstrap to damp it. is the standard setting — the value in the original paper’s experiments and in the N+ RLHF reproduction, with . Read the pair as: use the critic only to damp the far tail of the sum, not to replace the observed reward.
Why and not or alone. The product is the effective decay of the sum . With , alone sets the effective horizon of the estimator. That is why is the useful knob here and is not: one of them still does something.
2.7 The policy gradient, and where the advantage enters
The policy gradient theorem gives
- — the objective: expected return of the policy.
- — a trajectory: in LLM terms, one full response.
- — the probability of the sampled token.
- — the score function: the direction in parameter space that makes the sampled token more likely. It is a direction, not a magnitude; all of the magnitude comes from .
- — the advantage estimate. This is where every method in this part differs. PPO computes it with GAE and a critic; GRPO computes it as a group-normalised scalar broadcast to every token; RLOO computes it as a leave-one-out mean.
- The sum over says every token in the response gets a gradient contribution. Whether it gets the same advantage (sequence-level) or a per-token one is the choice discussed in PPO for LLMs and GRPO, and it matters more than it sounds: a token-level mean weights long responses more heavily.
The REINFORCE special case is (or ). It is the simplest unbiased estimator and the one with the worst variance, which is the whole motivation for everything above.
2.8 On-policy, off-policy, and importance sampling
- On-policy: the data used for the gradient was generated by the current policy. The policy gradient theorem’s expectation is over , so this is the distribution the theorem is about.
- Off-policy: the data comes from a behaviour policy . To correct the mismatch you multiply by the importance-sampling (IS) ratio
- — the probability the current policy assigns to the whole trajectory. It factors as a product of per-token probabilities, which is why the trajectory ratio telescopes into a product of per-step ratios.
- — the behaviour policy. In PPO, , the snapshot taken at the top of the iteration, and is exactly PPO’s probability ratio . This is the identity to have at your fingertips: PPO’s ratio is an importance weight.
- Why it is needed: without it, the surrogate is a biased estimator of the policy gradient, and the multi-epoch updates that make PPO sample-efficient are invalid.
- The problem with IS: unbiased, but with unbounded (possibly infinite)
variance when the ratio is heavy-tailed. A single token the current policy finds
much less likely than the behaviour policy did produces a huge weight. This is why
every practical method clips (PPO), truncates (veRL’s
rollout_is_threshold: 2.0), or masks (DeepSeek-V3.2) the ratio.
LLM RL is nominally on-policy and off-policy in four ways, all of which you should be able to name:
- PPO epochs. gradient epochs over the same rollout batch. Every epoch after the first is off-policy by construction — and that is the point of PPO’s ratio.
- Minibatching. A large rollout batch is split into minibatches for several gradient steps, which is off-policy for the same reason.
- Training/inference engine mismatch. vLLM and the training stack do not compute identical logprobs, so the in the denominator is not quite the one that sampled. This is the classic “the logprobs from vLLM don’t match the logprobs from FSDP” bug.
- Sampling truncation. Top-p/top-k during rollout changes the action space, so the IS identity breaks: DeepSeek-V3.2 notes that this “introduces a mismatch between the action spaces of and , which violates the principles of importance sampling”.
What on-policy costs. Because each gradient update needs fresh generation, and generation is autoregressive and memory-bandwidth-bound, rollout dominates the wall clock. OpenRLHF’s README states it as a design premise: “RLHF training spends 80% of the time on sample generation” — a project self-report, not a controlled measurement, but the qualitative claim is forced by the algorithm. It is why 2026 systems invest in asynchronous or partially-off-policy RL: the goal is to overlap generation with training, and then pay for the resulting staleness with IS correction or masking.
2.9 Why the bandit framing works, and when it stops working
InstructGPT calls the RL environment a bandit: “a random customer prompt and expects a response to the prompt. Given the prompt and response, it produces a reward determined by the reward model and ends the episode.” Under that framing:
- The critic is only a variance-reduction device. There is no future state to plan over, so has no decision-theoretic content.
- is degenerate. Whether you set it to 1 or 0.99 changes nothing about the problem; it only changes the estimator.
- The group-mean baseline (GRPO) is exactly as legitimate as a learned critic, because with a terminal reward and one action per prompt, the group mean is an unbiased estimate of .
The framing breaks in four identifiable places, each corresponding to a real project decision:
- Multi-turn / tool use. The reward arrives at the end of an interaction, so credit assignment spans turns. A bandit has no mechanism for “the third tool call was the mistake”.
- Genuinely intermediate rewards. A process reward model (§2.10) or a verifier that scores partial progress makes for , at which point the Bellman machinery becomes load-bearing rather than decorative.
- Episode length as a decision. If the policy can choose to stop, the horizon is endogenous and stops being a free parameter.
- Search. A bandit cannot look ahead. The moment you want to evaluate a prefix that has not been completed, you need a value estimate for a partial state — a genuine — and you are in §2.11.
2.10 Where process supervision stands
Short version, with sources, because the honest state of the field is contested.
- The case for process reward models (PRMs). Let’s Verify Step by Step (Lightman et al. 2023, arXiv:2305.20050) showed step-level supervision beating outcome supervision on MATH, and Math-Shepherd (Wang et al. 2023, arXiv:2312.08935) removed the human labels by bootstrapping step values from whether the model eventually solved the problem — a direct answer to the sparse-reward problem of §2.1.
- The case against. PRMs are expensive to train and to score (one model call per step per candidate), their labels are noisy, and a PRM can itself be reward-hacked: the policy learns to produce steps that look checkable. The decisive datum is Kimi k1.5, whose recipe works “without relying on more complex techniques such as Monte Carlo tree search, value functions, and process reward models” (arXiv:2501.12599).
- The defensible position
[as of 2026-10]: outcome and verifiable rewards dominate for training frontier reasoning models; PRMs survive as a search heuristic inside inference-time tree search, a data filter for constructing SFT traces, and an evaluation signal. They are not the default training reward. This is contested, not settled.
2.11 MCTS: the four phases
Monte Carlo Tree Search builds a tree by repeatedly running simulations from the root. Each simulation has four phases:
flowchart TD
ROOT["root: state s_0 (the prompt)"]
SEL["1. SELECTION<br/>descend by argmax(Q + U)<br/>until a node is not fully expanded"]
EXP["2. EXPANSION<br/>add one new child (one action)"]
EVAL["3. EVALUATION<br/>classical: random playout to terminal<br/>AlphaZero: v = f_theta(s), no playout"]
BACK["4. BACKPROPAGATION<br/>walk the selection path<br/>update N(s,a) and Q(s,a)"]
CHOOSE["move selection<br/>argmax_a N(s_0,a), or pi ~ N^(1/tau)"]
ROOT --> SEL --> EXP --> EVAL --> BACK
BACK -->|"budget remains"| SEL
BACK --> CHOOSE
- Selection. From the root, repeatedly pick the child maximising a bandit criterion (UCB1 / UCT / PUCT) until reaching a node that is not fully expanded.
- Expansion. Add one or more new child nodes (in AlphaZero, one per simulation).
- Evaluation. Estimate the value of the new node. Classical MCTS uses a random playout to a terminal state; AlphaGo/AlphaZero substitute the value network’s output . That substitution is the single most important change from classical MCTS, because a random playout in a game is cheap and in text generation is meaningless.
- Backpropagation. Propagate the value back up the path from phase 1, updating and at every edge on the path.
Then the move is chosen from the root statistics: (visit-count selection) or the search policy .
Why MCTS is more robust than minimax with a learned evaluator — AlphaZero’s own argument, and it is a first-class insight for the LLM analogy:
“AlphaZero evaluates positions using non-linear function approximation based on a deep neural network … This provides a much more powerful representation, but may also introduce spurious approximation errors. MCTS averages over these approximation errors, which therefore tend to cancel out when evaluating a large subtree. In contrast, alpha-beta search computes an explicit minimax, which propagates the biggest approximation errors to the root of the subtree.”
In one sentence: averaging noisy value estimates is more robust than trusting one.
2.12 UCB1, every symbol
The criterion is from Auer, Cesa-Bianchi & Fischer 2002, Finite-time Analysis of the Multiarmed Bandit Problem, whose explicit form of the confidence width is :
- — an arm. In MCTS, an action at a node.
- — the exploitation term: the empirical mean reward of arm over the times it has been pulled. Written in the action-value presentation. Without it the search never concentrates on what works — it degenerates into a uniformly-random sampler with extra bookkeeping.
- — the number of times arm was pulled before step . It is in the denominator, so a heavily-tried arm earns a smaller bonus. This is the term that makes the algorithm converge instead of exploring forever.
- — the total number of pulls so far. In UCT this becomes the parent node’s visit count .
- — the exploration bonus, and its shape is not
arbitrary:
- in the numerator grows without bound but very slowly. That is exactly the rate needed to pull every arm infinitely often while still letting the empirical means dominate asymptotically. It comes from the Chernoff-Hoeffding one-sided confidence bound the paper applies to each arm’s mean.
- makes the bonus decay to zero as an arm is tried, which is what forces the search to eventually stop re-exploring a settled question.
- gives an infinite bonus, which is a feature, not a bug: it forces every arm to be tried at least once. Implementations special-case it rather than relying on floating-point infinity.
- The square root converts the decay into a shape where the bonus is worth roughly the standard error of the mean estimate — the natural scale for “how uncertain am I about this arm”.
- — the exploration constant: the exchange rate between one unit of reward and one unit of the bonus. The inside the square root is UCB1’s Hoeffding constant; is the free scale (Sutton & Barto present the same rule with absorbing it, as ). Larger gives a wider, noisier search; smaller gives greedy descent into current beliefs. It is the one hyperparameter worth tuning here, and its correct value scales with the scale of the reward: double the reward units and you must double to keep the same behaviour. This is the most common tuning mistake in MCTS implementations.
2.13 UCT: the same rule, inside a tree
UCT is UCB1 applied recursively at every node of a tree (Kocsis & Szepesvári 2006). The only change is what the symbols mean:
- (total pulls at the bandit) becomes , the visit count of the node.
- becomes , the action value maintained by backpropagation: the mean of the values backed up through edge .
UCT converges to the minimax value of the tree as simulations , and it is the direct ancestor of PUCT.
2.14 PUCT: every symbol, and what each removal breaks
PUCT is the Predictor + UCT rule from Rosin 2011, Multi-armed bandits with episode context. Its distinguishing feature is that the exploration bonus is scaled by an external prior — a prediction about which action is good, available before any simulation. AlphaGo Zero uses exactly this form:
Term by term, with the justification and the counterfactual:
- — the current state (a tree node). , — actions (children). The ranges over all children of ; note that it is the parent’s total visit count, not the action’s. Using in the numerator instead is a subtle and common bug: the bonus would then depend on the action it is meant to be correcting for, and heavily-visited actions would be rewarded with a bigger bonus.
- — the action value: the mean of the backed-up values observed on the simulations that passed through edge . This is the exploitation term. Without it, the search is a random walk guided only by the prior — it spends its whole budget on whatever the network liked at the start and never revises.
- — the exploration bonus, the “upper confidence” term. It is what makes the search revise. Remove it and you have greedy descent on the first value estimate: one unlucky evaluation on a good move prunes it forever.
- — the prior probability of action in state , produced by the policy network ( in AlphaGo Zero). This is the crucial difference from UCT, and it is what makes PUCT worth having: a strong prior tells the search where to look for free, so a hopeless branch can be deprioritised before any simulation is spent on it. Without , the search spends budget rediscovering what the network already knows. It also makes the search asymmetric in a way UCT is not: two actions with identical and identical visit counts are still ordered, because the network has an opinion.
- — the number of times edge has been visited. It appears in , offset by one so the expression is finite at . Drop the and the first visit to any action divides by zero. As an action is tried, its bonus decays; this is the term that forces the search to eventually stop re-exploring the same move.
- — the total visit count of the parent state: how much search budget the parent has already absorbed. Its square root is what gives the bonus the correct diminishing-returns shape. Doubling the parent’s budget multiplies the bonus by only , so exploitation can eventually win; with a linear numerator the bonus would grow as fast as the budget and the search would never converge. It is the same scaling job that UCB1’s confidence-width derivation produces.
- — the exploration constant, AlphaGo Zero’s . Same role as UCB1’s , and the same units problem: it is the price of exploration in reward units. AlphaZero notably reuses the same hyperparameters across Go, chess and shogi without game-specific tuning, which is a strong signal that the form of the rule matters more than the constant.
AlphaGo Zero’s own one-line gloss, which is the whole formula in a sentence: the rule “initially prefers actions with high prior probability and low visit count, but asymptotically prefers actions with high action-value.”
The symmetric failure modes, stated for recall:
| Remove | The search becomes | Symptom |
|---|---|---|
| Prior-guided random walk | Never improves on the network’s first guess; more simulations do not help | |
| Greedy descent on first value estimates | Overcommits to a bad move after one unlucky evaluation | |
| Plain UCT with uniform priors | Spends most of the budget on hopeless branches; effective branching factor explodes | |
| The offset | Division by zero | NaN on the first visit to every action |
| The in the numerator | A bonus that grows with budget | Exploration never decays; no convergence |
2.15 The AlphaGo/AlphaZero/MuZero chain, and what each step removed
- AlphaGo (Silver et al. 2016, DOI 10.1038/nature16961): MCTS + PUCT + two networks (policy net and value net) + supervised bootstrapping from human games.
- AlphaGo Zero (Silver et al. 2017, DOI 10.1038/nature24270, public PDF): tabula rasa self-play, a single network producing both the move prior and the value, no human data, and no random playouts — the leaf is evaluated by . Each simulation “starts from the root state and iteratively selects moves that maximise an upper confidence bound , where , until a leaf node is encountered.”
- AlphaZero (arXiv:1712.01815): the same algorithm and hyperparameters on chess and shogi. Training used 5,000 first-generation TPUs for self-play and 64 second-generation TPUs for training, 700k steps of minibatch 4,096, and 800 MCTS simulations per move; at evaluation it “selects moves greedily with respect to the root visit count”.
- MuZero (Schrittwieser et al. 2019, arXiv:1911.08265): removes the requirement of knowing the rules by learning a latent dynamics model that predicts exactly the three quantities MCTS needs — reward, policy, value — and plans inside it. This is the model-based RL datum the LLM world keeps re-deriving.
2.16 The connection to LLM reasoning, and its limits
The mapping. Token generation is action selection; “think step by step” is an implicit linear rollout; a tree search over reasoning steps is explicit planning. A reasoning step (a sentence, a line of algebra, a tool call) is the natural action granularity, which is why nearly all LLM tree-search methods work at the step level, not the token level.
| Method | ID | What it does |
|---|---|---|
| Tree of Thoughts (ToT) | 2305.10601 | Tree over “thoughts”; the model proposes and self-evaluates; BFS/DFS on those evaluations. No learning |
| Graph of Thoughts | 2308.09687 | Generalises ToT to a DAG: thoughts can be merged, not only branched |
| RAP | 2305.14992 | The LLM is both world model and policy; MCTS at inference using its own likelihoods as rewards |
| LATS | 2310.04406 | MCTS over an agent’s actions, with external observations and self-reflection as the value signal |
| rStar | 2408.06195 | MCTS with a mutual-consistency value: a second model solves the same problem, and agreement scores the path |
| rStar-Math | 2501.04519 | Adds a trained process preference model on top, bootstrapped from MCTS rollouts |
| MCTS-DPO | 2405.00451 | MCTS generates preference pairs from intermediate steps, then iterative DPO. Search as a data generator |
| AlphaMath | 2405.03553 | MCTS with a value model for step-level evaluation: “process supervision without process” |
The distinction that matters: inference time versus training time. Search can be used (a) at inference time, to spend more compute on one problem (ToT, RAP, LATS), or (b) at training time, to produce better data or a better value/policy target (MCTS-DPO, AlphaMath, expert iteration). Only (b) changes the weights. Both are test-time-compute techniques and must be costed as such: tree search multiplies the number of forward passes by roughly the branching factor times the depth, and every one of those forward passes is a full model call.
The limits, and the counter-evidence. This must not be omitted. Kimi k1.5 reports an RL recipe that explicitly avoids search:
“Long context scaling and improved policy optimization methods are key ingredients of our approach, which establishes a simplistic, effective RL framework without relying on more complex techniques such as Monte Carlo tree search, value functions, and process reward models.” — Kimi k1.5, arXiv:2501.12599
So the honest [as of 2026-10] statement is:
- MCTS is a live research direction and a legitimate inference-time technique, but the strongest scaling result for reasoning LLMs deliberately drops it. Do not present tree search as a required component of reasoning-model RL.
- The action space is the wrong shape for classical MCTS. A game has around 100 legal moves; a token step has around 100,000 (the vocabulary), and a reasoning step has an unbounded, near-continuous set of possible sentences. There is no cheap “expansion” operator, so every node costs a full generation.
- There is no cheap simulator. AlphaZero can play a random playout to the end of a game and get a real reward. A random playout of token generation produces garbage, so the leaf evaluation must come from a learned value or a heuristic judge — which puts all the weight back on the thing the value function was supposed to supply in the first place.
- The value estimate is the bottleneck. MCTS’s guarantee is an average over noisy values. If the per-node value is systematically wrong — as a self-evaluating LLM’s confidence often is — averaging does not help; it produces a confidently-wrong subtree.
- The cost is multiplicative and hard to amortise. branches at depth is on the order of extra generations per problem, against one generation for greedy decoding and for best-of-. Whether that beats independent samples at the same cost is an empirical question with no settled answer.
The defensible synthesis: use MCTS when you have a genuine value function and a cheap expansion operator; use best-of- or long-context RL when you do not. The honest evaluation for a specific project is a compute-matched comparison against best-of-, and most published MCTS-for-reasoning results do not report one.
3. Implementation
3.1 GAE, implemented so the endpoints are checkable
"""Generalized Advantage Estimation, with the endpoint identities asserted.
torch >= 2.0, CPU. This is PPO's advantage computation, isolated.
"""
import torch
def compute_gae(rewards: torch.Tensor,
values: torch.Tensor,
gamma: float = 1.0,
lam: float = 0.95,
mask: torch.Tensor | None = None):
"""GAE over one or more trajectories.
Args:
rewards: [T] per-step rewards. In LLM RL this is 0 for t < T-1, the RM
score at t = T-1, plus -beta * log(pi/pi_ref) at EVERY step.
values: [T] critic outputs V(s_t); no extra V(s_T) is included.
gamma: discount. 1.0 in LLM RL.
lam: GAE lambda. 0.0 -> one-step TD, 1.0 -> MC return minus baseline.
mask: [T] 1 for real tokens, 0 for padding. Zeroing the accumulator at
padding is mandatory: a padded step has no reward and no real value,
and letting it through adds a constant to every later advantage.
Returns:
advantages [T], returns [T] (the value-regression targets).
"""
T = rewards.shape[0]
advantages = torch.zeros_like(rewards)
last_gae = torch.zeros((), dtype=rewards.dtype)
for t in reversed(range(T)):
# Past the final step there is no next state, so the bootstrap is 0. The
# same is true across the padding boundary: V(s_{t+1}) is only defined for
# a real next token, otherwise the padding's value leaks into the last real
# advantage.
if t + 1 < T and (mask is None or mask[t + 1]):
next_value = values[t + 1]
else:
next_value = torch.zeros((), dtype=values.dtype)
# delta_t = r_t + gamma * V(s_{t+1}) - V(s_t)
delta = rewards[t] + gamma * next_value - values[t]
# A_t = delta_t + (gamma * lam) * A_{t+1}. Note the PRODUCT gamma*lam:
# this is why lambda alone controls the estimator's horizon when gamma=1.
last_gae = delta + gamma * lam * last_gae
if mask is not None:
last_gae = last_gae * mask[t]
advantages[t] = last_gae
# The critic regresses on the empirical return estimate, V_target = A + V.
returns = advantages + values
return advantages, returns
# --- checks that pin the endpoints ------------------------------------------
torch.manual_seed(0)
T = 40
rewards = torch.zeros(T)
rewards[-1] = 1.0 # terminal-only reward, as in RLHF
values = torch.randn(T) * 0.5 + 0.5 # a deliberately imperfect critic
adv_mc, _ = compute_gae(rewards, values, gamma=1.0, lam=1.0)
adv_td, _ = compute_gae(rewards, values, gamma=1.0, lam=0.0)
# lambda = 1 must equal the Monte Carlo return minus the baseline V(s_t).
mc_return = rewards.sum() # gamma = 1, single terminal reward
expected_mc = mc_return - values # G_t - V(s_t) for every t
print("lambda=1 max abs error vs G_t - V(s_t):",
(adv_mc - expected_mc).abs().max().item()) # ~1e-7, floating point
# lambda = 0 must equal the TD residual at each step:
# delta_t = r_t + gamma * V(s_{t+1}) - V(s_t), with V(s_T) = 0 past the end.
next_vals = torch.cat([values[1:], torch.zeros(1)])
expected_td = rewards + next_vals - values
print("lambda=0 max abs error vs delta_t:",
(adv_td - expected_td).abs().max().item()) # ~1e-7, floating point
Three implementation details in that function are where the bugs live:
gamma * lam, notgammaorlam. The recursion is the closed form of the geometric sum; writing the wrong product silently changes the effective horizon and is invisible in the loss curve.- The padding mask multiplies the accumulator, not the output. Masking after the
recursion would leave
last_gaeintact across the boundary and leak real values into padded positions. - The final bootstrap is zero. That is correct for a terminal episode and not correct if the episode was truncated by a length cap rather than by EOS — then you should bootstrap from the truncated state’s value, or the agent learns that running out of budget is the same as finishing.
3.2 A from-scratch MCTS with PUCT
The skeleton to have in your head in an interview, small enough to write on a
whiteboard: classical MCTS with a value-function leaf evaluation (the AlphaZero
substitution). The defaults degrade gracefully — uniform priors give UCT, a
random-playout value_fn gives classical MCTS.
"""MCTS with PUCT. Pure Python, no dependencies.
Caller supplies:
actions(s) -> list of legal actions; step(s, a) -> (next_state, reward)
is_terminal(s) -> bool
prior_fn(s) -> {action: P(s,a)} (uniform if omitted)
value_fn(s) -> float (if omitted, a random playout evaluates the
leaf and its accumulated reward is backed up)
"""
import math
import random
from dataclasses import dataclass, field
@dataclass
class Node:
state: object
parent: "Node | None" = None
action: object = None # the action that led here
prior: float = 1.0 # P(s_parent, action)
children: dict = field(default_factory=dict)
N: int = 0 # visits to THIS node
W: float = 0.0 # sum of backed-up values
terminal: bool = False
@property
def Q(self) -> float:
"""Mean backed-up value; 0.0 when unvisited -- see the notes below."""
return self.W / self.N if self.N > 0 else 0.0
def mcts(root_state, actions, step, is_terminal, n_sims,
prior_fn=None, value_fn=None, c_puct=1.5, gamma=1.0):
root = Node(root_state, terminal=is_terminal(root_state))
for _ in range(n_sims):
node, path = root, [root]
# 1. SELECTION: descend while every child is expanded.
while (not node.terminal and node.children
and len(node.children) == len(actions(node.state))):
total_N = sum(c.N for c in node.children.values()) # sum_b N(s,b)
best, best_child = -float("inf"), None
for a, child in node.children.items():
# U(s,a) = c * P(s,a) * sqrt(sum_b N(s,b)) / (1 + N(s,a))
u = c_puct * child.prior * math.sqrt(total_N) / (1 + child.N)
if child.Q + u > best:
best, best_child = child.Q + u, child
node = best_child
path.append(node)
# 2. EXPANSION: add exactly one new child.
edge_reward = 0.0
if not node.terminal:
n_actions = len(actions(node.state))
untried = [a for a in actions(node.state) if a not in node.children]
a = random.choice(untried)
prior = (1.0 / n_actions) if prior_fn is None else prior_fn(node.state)[a]
nxt, edge_reward = step(node.state, a)
node = Node(nxt, parent=path[-1], action=a, prior=prior,
terminal=is_terminal(nxt))
path[-1].children[a] = node
path.append(node)
# 3. EVALUATION: value network, or a random playout to a terminal state.
# `value` is the return from this node onward: the network's estimate,
# or the rewards a random playout actually collects. The reward on the
# edge into this node is added either way -- `step` returns the signal.
if node.terminal:
value = 0.0
elif value_fn is not None:
value = value_fn(node.state) # AlphaZero: v = f_theta(s)
else:
s, value = node.state, 0.0
while not is_terminal(s):
s, r = step(s, random.choice(actions(s)))
value += r # gamma = 1 in the LLM setting
value += edge_reward
# 4. BACKPROPAGATION
for n in reversed(path):
n.N += 1
n.W += value * (gamma ** 0) # gamma = 1 in the LLM setting
# Root move selection uses visit counts, not Q -- see the notes below.
return max(root.children.items(), key=lambda kv: kv[1].N)[0] if root.children else None
Five details in that skeleton are exactly the ones to talk about:
- The reward comes out of
step, and the backup must carry it.step(s, a)returns(next_state, reward); the code adds the edge reward into the leaf’s value and accumulates every reward the random playout collects before backing the total up the path. Discard thestepreturn — as an earlier version of this skeleton did — and every leaf evaluates to0.0, so the search has no signal to maximise and its visit counts are noise. A random-playoutvalue_fnis only meaningful in a reward-bearing game; for a generic search with no reward, pass an explicitvalue_fninstead of silently evaluating to zero. Qreturns 0.0 for an unvisited child, which is why the offset and the prior matter so much: a fresh child’s score is entirely , and is proportional to its prior. So the initial order of exploration is the network’s prior order — the free pruning of §2.14. Whether 0.0 is right depends on the reward scale: with all-negative rewards it is an optimistic initialisation, which is a legitimate design choice but must be made deliberately.total_Nis the sum over children. Here it equalsnode.Nbecause every backprop increments the node, but the distinction matters if you prune or lazily materialise children — and usingN(s,a)in the numerator is the bug of §2.14.- Root move selection uses
N, notQ. Visit count is lower-variance and is what AlphaZero uses; a single high from few visits is exactly the noisy estimate MCTS exists to smooth away. gamma ** 0is written out to make the discounting choice explicit. In a tree you control the horizon locally; in a long-horizon game you would applygamma ** depthon backup. Writing it out stops it silently becoming a no-op.
3.3 The knob table
| Knob | Realistic range | What moving it does |
|---|---|---|
| or (exploration) | 0.5 - 4 | Wider search vs deeper search. Must be rescaled whenever the reward scale changes |
| Simulations per decision | 50 - 1000+ | AlphaZero used 800 per move. Quality rises sublinearly; cost rises linearly |
| (RL discount) | 1.0 for LLM RL | Sets the horizon; discounting a terminal reward punishes length |
| (GAE) | 0.9 - 0.98 | 0 = one-step TD (low variance, critic-biased), 1 = MC minus baseline (unbiased, high variance) |
| Value-loss coefficient | 0.05 - 0.5 | How much the critic’s regression dominates the policy gradient |
| IS clip / threshold | 2.0 (veRL default) | Truncates heavy-tailed importance weights, trading bias for finite variance |
| Branching factor (search) | 3 - 16 | Each extra branch multiplies rollout cost |
4. Numbers and trade-offs
4.1 The variance of a Monte Carlo baseline is not a metaphor
Take the RLOO-style setup from GRPO: completions per prompt, a binary reward, a pass rate . The group-mean baseline has variance as an estimate of . (example) At :
| Std. error of the group-mean baseline | |
|---|---|
| 2 | 0.354 |
| 4 | 0.250 |
| 8 | 0.177 |
| 16 | 0.125 |
| 64 | 0.0625 |
The baseline’s noise falls as , so going from to buys an 8x-variance-reduced baseline for 8x the rollout tokens. That is the exchange rate GRPO offers, and it is why is typically 8-16 rather than 64: the marginal variance reduction stops paying for itself, and the tokens are better spent on more prompts, which reduces the variance of the outer expectation instead.
4.2 What a forward pass costs, and therefore what search costs
The number that governs whether tree search is affordable: a search budget of simulations at branching factor and depth costs on the order of extra model evaluations per decision (every selection-expansion-evaluation cycle needs at least one leaf evaluation), against for best-of-.
(example) At 800 simulations per decision, the search spends 800 leaf evaluations, and with a value network each leaf evaluation is one forward pass over the prefix. Generating the answer instead costs about one forward pass per token, so a 300-token response is roughly 300 forward passes. Put both on the same axis: a per-problem budget of 16 full responses is forward passes, so the compute-matched search budget is roughly 4,800 simulations, not 800. Comparing 800 simulations against best-of-50 silently mixes a per-decision count with a per-problem one. Almost no published MCTS-for-LLM-reasoning result is compute-matched against best-of- in these units, and you should say so when you cite one.
4.3 Where each method sits on the cost axis
| Method | Model copies resident | Rollout multiplier | Needs a value function |
|---|---|---|---|
| REINFORCE | actor + reference | 1x | no |
| RLOO | actor + reference | x | no (leave-one-out mean) |
| GRPO | actor + reward + reference | x | no (group mean) |
| PPO | actor + critic + reward + reference | 1x | yes, actor-sized |
| MCTS at inference | actor (+ optional value model) | x forward passes | yes, implicitly (a leaf evaluator) |
| Best-of- | actor (+ reward or verifier) | x | no |
Read the last two rows together. Best-of- requires nothing but a scorer and buys a real improvement in expected reward; MCTS requires a value function for partial states and buys lookahead. The AlphaZero evidence says the value function is worth it when you have it, because self-play generates an unlimited supply of ground-truth outcomes to train it on. Reasoning problems do not come with an unlimited supply of partial-state labels, which is the structural reason search has not displaced sampling here.
4.4 The trade-off, made concrete
(example) For a 400-token response with a single terminal reward and a critic with per-step error , the bias of the GAE estimator is approximately — the geometric sum of the critic’s errors along the trajectory — while the variance scales roughly with the effective number of terms, . At :
| Effective decay | Approx. bias factor | Approx. variance factor | |
|---|---|---|---|
| 0.0 | 0.0 | 0.0 | 1 |
| 0.90 | 0.90 | 9 | 10 |
| 0.95 | 0.95 | 19 | 20 |
| 0.99 | 0.99 | 99 | 100 |
The table is illustrative rather than measured, but the shape is the point: bias and variance both grow as , with the variance the larger of the two, and the reason to use 0.95 rather than 0.99 is that both are about five times smaller at 0.95 — 0.99 buys a longer effective horizon at roughly five times the bias and five times the variance. The N+ reproduction’s verified value is , .
5. Pitfalls
Writing instead of in the GAE recursion. Symptom: the
advantages are systematically scaled wrong, the policy learns much faster or much
slower than an identical run with a different , and the loss curve shows
unstable spikes. Nothing looks wrong, because both symbols are floats.
Forgetting the padding mask in GAE. Symptom: the advantages of short responses in a padded batch are inflated by the accumulated sums of their padding positions, so the policy preferentially reinforces whatever came last in short responses. The bug is invisible in aggregate metrics and obvious in a per-token advantage histogram.
Truncating an episode without bootstrapping. You hit the max length cap and treat
the last token as terminal. Symptom: the model learns to stop early on problems it
cannot solve, because running out of room is scored exactly like finishing. DAPO’s
overlong reward shaping and OpenRLHF’s --reward.overlong_penalty_factor exist because
this is common and expensive.
Setting “for stability”. Symptom: the model produces progressively shorter answers and the reward curve improves on short tasks while long-form quality degrades. With a terminal reward, discounting is a length penalty with no justification.
Tuning for PUCT/UCB without rescaling when the reward changes. Symptom: the search either explores uniformly forever (constant too large) or commits to the prior’s first guess (constant too small), and the behaviour changes discontinuously when you switch reward models. is in reward units; change the reward and you have changed .
Using instead of in the PUCT numerator. Symptom: search quality degrades in a way that is hard to attribute — exploration and exploitation become entangled, and increasing the simulation budget stops helping.
Trusting the prior with no exploration term. Symptom: only the top- tokens the policy net likes are ever expanded, so the search can never discover that the network’s second choice was better. This is the failure mode that makes pure policy-guided decoding look deceptively good on easy problems.
Assuming MCTS will beat sampling because it is “smarter”. Symptom: an expensive evaluation-time search that loses to best-of- at equal compute, on problems where the value function is unreliable. Always compute-match against best-of-, and report the value function’s own accuracy alongside.
Treating the leaf evaluation as free. Symptom: you use the LLM’s own token log-likelihood as the value, and the search confidently prefers short, fluent, confident-sounding continuations. Likelihood is not correctness; a value function must be trained on outcomes, not derived from the policy’s fluency.
Believing RLVR capability gains are settled. Symptom: you design an evaluation
around pass@1 only, and miss that the base model may already have solved the problem
at large . The dispute between Yue et al. 2025
(redistribution) and ProRL (expansion) is
unresolved; report both pass@1 and pass@k and say the question is open.
6. Using it in a project
6.1 Which estimator to reach for
- Single-turn, outcome reward, cheap scoring (the RLVR default). Use Monte Carlo with a group baseline: GRPO/RLOO. No value function, no bootstrap, no critic-bias problem. You pay x the rollouts and the only bias is the group’s sampling noise.
- Dense or shaped reward, long horizon, a value estimate you trust. Use GAE with a critic (PPO). This is where the bias-variance dial earns its keep. VAPO (arXiv:2504.05118) is the strongest published counter-argument to the “critic-free always” position, reporting 60.4 on AIME 2024 with Qwen-32B.
- Multi-turn or agentic. The bandit framing is gone; you need either a critic or a carefully designed per-turn reward. This is where credit assignment becomes the whole problem.
- You have a value function and a cheap expansion operator. Only then consider MCTS, and compute-match it against best-of-.
6.2 When NOT to use each of these
- When NOT to use GAE: when you cannot fit a value function. Fitting a critic to predict the terminal reward of a 32k-token chain of thought is genuinely hard, and a bad critic turns into noise and into a slower Monte Carlo. If your value loss is not going down, use a critic-free method instead of tuning .
- When NOT to use Monte Carlo: when episodes are very long and the reward is dense. A 10,000-step agentic episode with per-turn rewards has an enormous return variance, and bootstrapping is the only way to make the gradient usable.
- When NOT to use MCTS: when leaf evaluation is expensive and unreliable, which is the normal case for LLM reasoning. Also when the branching factor is large and the expansion operator is a full generation — you are paying a generation per node to explore a space where the value estimate has no ground truth. If your value function is a self-evaluating LLM’s confidence, you do not have a value function.
- When NOT to use importance sampling: when the behaviour and target policies are far apart. The ratio’s variance blows up; fix the staleness (fewer PPO epochs, fresher weights, async weight sync) rather than adding a clip and hoping.
- When NOT to use a learned baseline at all: in a single-turn task with a cheap reward, the group mean is unbiased, needs no training, and cannot be attacked. A learned critic is a second model to fit, serve, and hack.
6.3 The two dials people confuse
- changes the problem. It decides what the agent is trying to achieve over what horizon. Changing it changes the optimal policy.
- changes only the estimator. It decides how you measure the advantage for a fixed objective. It cannot change the optimum, only how fast and how stably you get there.
If you are tuning and the behaviour changes qualitatively, something else is wrong: either the value head is bad enough that the estimator’s bias dominates, or the ratio correction is off, or the reward is not what you think it is.
7. How you would prove it worked
7.1 Proving the estimator choice mattered
Run the identical RL setup from an identical checkpoint, varying exactly one thing:
- with everything else fixed. (example) In sparse-reward LLM RL the usual shape is: is unstable and plateaus early (critic bias dominates), has the highest variance and a noisy reward curve, is in between and usually best. Report the variance of the advantage estimate within a batch for each arm — that is the mechanism, not just the outcome.
- Critic-free versus critic at equal rollout budget. GRPO at against PPO with a critic, matched on generated tokens rather than on gradient steps. (example) The common outcome on verifiable reasoning is that the critic-free arm wins on both stability and final accuracy, and the critic arm wins on sample efficiency per generated token early in training.
- Search versus sampling at equal compute. MCTS with simulations against best-of- with . This is the comparison the literature is missing and the one an interviewer will ask about.
7.2 The diagnostics worth logging
| What you report | What it catches |
|---|---|
| Held-out win-rate vs the SFT baseline, from an independent judge | The only end-to-end claim that matters |
| Proxy reward and gold reward on the same axis | Reward hacking, the moment it starts |
| vs step | Drift faster than intended |
| Response length distribution | Length hacking, format padding |
| Format / refusal / entropy statistics | Degenerate text before a human notices |
| Explained variance of | Whether the critic is worth having at all |
| Ordinary capability benchmarks | The alignment tax |
The explained variance of is the most under-used diagnostic here. It is a single number answering “is the value function worth having at all”. If it is negative, the critic is worse than predicting the batch mean and is actively harmful; switch to a group baseline the same day.
7.3 The MCTS-specific ablation
If you do use search, the only honest evaluation has four arms, all compute-matched: (1) greedy decoding; (2) best-of- with a verifier or reward model; (3) MCTS with uniform priors and the same value function (i.e. UCT); (4) MCTS with the trained prior (PUCT). Arm 3 versus 4 isolates the value of ; arm 2 versus 3 isolates the value of search at all. (example) A common result is that arm 2 wins, because the value function is the bottleneck — and reporting that honestly is more valuable than reporting the arm where search won.
8. Interview drill
“Why do you need an advantage instead of just using the return?”
Strong answer: because the policy-weighted mean advantage is zero, so subtracting a baseline that does not depend on the action leaves the gradient’s expectation unchanged while reducing its variance. The return alone has variance that grows with horizon and, with a terminal binary reward, is a single Bernoulli draw. The advantage measures surprise rather than outcome, so a solved-easy-problem sample contributes almost nothing to the gradient while an unexpected success contributes a lot.
Common wrong answer: “the return is biased.” It is not; it is unbiased and high-variance. Confusing the two is the fastest way to fail this question.
“Monte Carlo or TD?”
Strong answer: MC targets the full empirical return — unbiased, high variance, needs the episode to end. TD targets — biased by exactly the value function’s error, low variance, online. Which is right depends on whether you can fit . In LLM RL with terminal rewards and long responses, is hard to fit, which is a structural argument for the critic-free Monte Carlo methods.
Follow-up: “so why does PPO work at all in RLHF?” Because the per-token KL penalty makes the reward dense, so the TD residual at each step carries real information even though the RM reward is terminal.
“Walk me through GAE. What is doing?”
Strong answer: GAE is , the exponentially weighted sum of TD residuals. sets the effective decay and therefore moves the estimator between its two endpoints: is the one-step TD residual , and telescopes to , the Monte Carlo return minus a baseline. The factor normalises the weights so the scale does not move with . Standard is , .
Common wrong answer: “ is the discount factor.” No — is. is the estimator’s bias-variance decay, and the paper’s specific point is that they are separable: sets the horizon of the problem, tunes the estimator.
“Why is in LLM RL?”
Strong answer: the episode is one bounded response with the reward at the end, so a discount would make the objective depend on where the answer ended. It would behave as an implicit length penalty with no justification. The cost is that you lose the main variance-control knob, which is why carries the burden.
“What is importance sampling for, and what is the problem with it?”
Strong answer: it corrects the distribution mismatch when the data comes from a behaviour policy rather than the current policy. The per-action ratio is exactly PPO’s with . It is unbiased but has unbounded variance when the ratio is heavy-tailed, which is why every practical implementation clips, truncates or masks it.
Follow-up: “name three ways LLM RL is off-policy even though it is called on-policy.” PPO’s multiple epochs over one batch; minibatching within an epoch; and the training/inference engine logprob mismatch. A fourth: top-p sampling truncation changes the action space and breaks the IS identity outright.
“Derive the PUCT formula’s terms and tell me what happens if I remove one.”
Strong answer: the score is with . is exploitation — the mean backed-up value over simulations that visited the edge; remove it and the search never revises the prior and becomes a prior-guided random walk. is the network’s prior, which lets hopeless branches be pruned before any simulation is spent; remove it and you are back to plain UCT with uniform priors, paying full price to rediscover what the network knew. is the exploration price in reward units and must be rescaled with the reward. in the numerator, square-rooted, makes the bonus grow with the parent’s budget but at a diminishing rate, so exploitation can eventually win; un-square-rooted, the search never converges. in the denominator makes the bonus decay as the edge is tried and keeps the expression finite at ; drop the offset and you divide by zero.
Common wrong answer: describing as “random exploration”. It is not random — it is a directed bonus, largest exactly where the prior is confident and the edge is under-explored.
“Why does MCTS beat minimax with a neural evaluator?”
Strong answer: because minimax propagates the largest approximation errors to the root, while MCTS averages over them so they cancel. AlphaZero’s own stated reason. The corollary for LLMs is less comfortable: the averaging argument only helps if the errors are roughly independent across the subtree. A value estimator with a systematic bias — a self-evaluating LLM that prefers confident-sounding text — produces averaged errors, not cancelled ones.
“Should you use MCTS for LLM reasoning?”
Strong answer: not by default. It is a legitimate inference-time technique with a real research literature (ToT, RAP, LATS, rStar), but the strongest published scaling result for reasoning LLMs deliberately drops it: Kimi k1.5’s recipe works “without relying on more complex techniques such as Monte Carlo tree search, value functions, and process reward models”. The structural reasons are the action space (a reasoning step has no cheap expansion operator), the absence of a cheap simulator, and the fact that the leaf value estimate is the bottleneck. If you do use it, compute-match against best-of- and report the value function’s accuracy.
Common wrong answer: “yes, search is strictly better than sampling because it looks ahead.” Lookahead is only worth paying for when the leaf evaluation is better than the sampling estimate it replaces, and in this domain it usually is not.
“Is RLVR teaching models new reasoning, or just sharpening what they had?”
Strong answer: genuinely contested, and say so. Yue et al. argue RLVR sharpens
pass@1 by concentrating on paths the base model already had, without raising
pass@k at large ; ProRL reports prolonged RL does expand the reasoning boundary.
Both are primary sources; neither has been refuted. The practical consequence is to
report both pass@1 and pass@k and to distrust any claim based on pass@1 alone.
Next: RL Frameworks — these estimators are cheap to write down and expensive to schedule: the rollout/training boundary, weight synchronisation, and the colocated-versus-disaggregated choice are what the frameworks exist to manage.