Search Self-Distillation

rl
llm
Use MCTS on-policy
Published

March 2, 2026

“generalized reasoning engine”. By replacing standard gradient steps with search in the inner loop, we avoid the trap of just doing Supervised Fine-Tuning. The teacher acts as the search heuristic, and the student compiles those discoveries back into its base weights, staying strictly on-policy to prevent distribution shift.

This formulation heavily utilizes the latent reasoning tokens to bridge the gap between exploration and distillation, clarifying the model’s intent at each step.

1. The Search-Distillation Objective Function

Let the policy be \(\pi_{\theta}\). For a given prompt \(s\), a complete trajectory \(\tau\) consists of a sequence of intermediate reasoning tokens \(r = (r_1, ..., r_k)\) and a final answer/action \(a\). So, \(\tau = (r, a)\).

The Inner Loop (Teacher’s Search): Instead of Test-Time Training via gradients , the Teacher runs a search algorithm \(\mathcal{S}\) (e.g., MCTS or a STaR-like rejection sampling) over the latent reasoning space. The search is guided by the policy’s own prior probabilities and an environment verifier \(V(s, \tau) \in \{0, 1\}\).

The output of the search is a golden trajectory \(\tau^* = (r^*, a^*)\) that successfully solves the prompt:

\[\tau^* = \text{argmax}_{\tau \in \mathcal{S}(\pi_{\theta}, s)} V(s, \tau)\]

The Outer Loop (Student’s Distillation): The Student (which shares the exact same weights \(\theta\)) is then updated to maximize the likelihood of this verifiable reasoning path. To maintain stability in RLVR, we optimize this using a policy gradient method like GRPO, treating the discovered \(\tau^*\) as the behavioral target.

The distillation objective forces the model’s latent representations to align with the successful reasoning trace:

\[\mathcal{L}_{distill}(\theta) = -\mathbb{E}_{s \sim \mathcal{D}, \tau^* \sim \mathcal{S}} \left[ \sum_{t=1}^{|\tau^*|} \log \pi_{\theta}(\tau^*_t | s, \tau^*_{<t}) \right]\]

If you want to maintain the relative advantage framing (like in GRPO), you can structure it as an advantage-weighted loss where trajectories found via search that yield high verifier scores receive a positive advantage \(+A\), and failed searches receive \(-A\).


3. Implementation Strategy

Because this architecture isolates the heavy compute to the forward-pass search tree rather than requiring ephemeral backwards passes, it’s highly scalable.

If you were to prototype this, you could easily build it into a minimal deep learning framework. You’d just need to abstract the SearchAlgorithm as a modular class that takes a prompt and the current model state, returning a list of token IDs (the golden trajectory). Then, your outer training loop remains a dead-simple PyTorch optimization step over those returned tokens, perfectly suited for a lightweight RL LLM post-training package like minpost.