Post-Training and Distillation for Reasoning Models: A Practical Engineering Guide
This article explains how to build reasoning capabilities in large language models through post-training and distillation. It covers what post-training must solve, how a large-scale reinforcement learning loop works, how to design narrow and verifiable rewards, and which stability and data practices reduce variance. It then describes how to distill high-reward teacher trajectories into smaller, cheaper student models, how to evaluate capability, robustness, and cost separately, and how to serve and integrate the resulting models. The article also reviews common risks such as reward hacking, capability hallucination spillover, data leakage, and practical stopping conditions.
Reasoning ability does not reliably emerge simply by adding more pretraining data. Pretraining gives a model broad patterns, but the hard part is different: when a problem is long, the solution path branches easily, and the final answer must be verifiable, the model still needs to converge step by step on the correct conclusion. A path repeatedly validated in industry is to introduce large-scale reinforcement learning during post-training, rely on only a small amount of human annotation, and use automatically checkable task signals to push the model to “think clearly before answering.” Then, use a teacher model’s reasoning trajectories to distill that capability into smaller, cheaper student models. The following sections are organized in an engineering order that can be implemented in practice and are not tied to any single product narrative.
What Post-Training Must Solve
Mathematical proofs, competition-level programming, multi-hop question answering, and complex instruction following share three characteristics. First, intermediate steps are longer than the final answer, and errors amplify along the chain. Second, correctness can often be checked programmatically: whether unit tests pass, whether a numeric value falls within tolerance, or whether formal constraints are satisfied. Third, high-quality step-by-step annotations are extremely expensive and cannot be labeled at pretraining scale.
The goal of post-training should therefore be written as measurable behavior changes rather than slogans: improve one-pass success rate on a fixed evaluation set; reduce ineffective repetition under the same context budget; and achieve a more stable balance between refusal and random guessing. A small amount of annotation is used to define “what counts as good,” not to hand-write every chain of thought.
The Basic Closed Loop of Large-Scale Reinforcement Learning
The process can be viewed as a four-stage loop.
- Sampling: for the same prompt, let the current policy generate multiple candidate reasoning paths and answers.
- Scoring: use automatic verifiers, rule checkers, or calibrated reward models to produce scalar rewards. For tasks that can be checked exactly, prefer outcome rewards to avoid the reward model hallucinating on its own.
- Updating: use policy-gradient-style methods to increase the probability of high-reward trajectories, and use baselines, clipping, or trust-region constraints to limit the size of each update.
- Filtering: discard batches with obvious format collapse, excessive empty looping, or extremely high reward variance so that noise does not dominate the gradient.
An illustrative training step can be written as pseudocode like the following. It expresses only the data flow and does not correspond to any vendor interface:
for batch in prompts:rollouts = policy.sample(batch, n=k, temperature=t)rewards = []for r in rollouts:score = verifier(r.answer, batch.gold_or_tests)score += format_penalty(r.text) # too short, garbled, or not concluded as requiredrewards.append(score)advantages = normalize(rewards) # subtract batch mean, divide by standard deviationpolicy.update(rollouts, advantages, clip=c, kl_ref=ref_model)
“Small amounts of annotation” usually fall into three areas: open-ended questions that verifiers cannot cover, where a small human preference set calibrates the reward model; prompt templates and answer formats, where dozens to hundreds of examples pin down the output contract; and safety and refusal boundaries, where negative examples tell the model when to stop inferring. Standard answers and test cases for math and code problems are not step-by-step reasoning annotations, but they are enough to drive large-scale trial and error.
Reward Design: Narrow Rather Than Vague
Rewards are the part of post-training most likely to train the model in the wrong direction. In practice, it is better to use three layers with interpretable weights.
Outcome rewards. For code, check the proportion of tests passed and whether the code compiles. For math, check whether the final expression is equivalent rather than whether the surface string matches. For structured tasks, check whether schema constraints are satisfied. This layer should dominate because it is the hardest to fool by “sounding right.”
Process constraints. There is no need to label whether every step is correct. Instead, penalize obvious degeneration: repeating the same sentence, ending prematurely, entangling reasoning and answer in unparseable text, or ignoring hard conditions in the input. Process constraints are format and efficiency regularizers, not a substitute for proof.
Reference model constraints. Apply a divergence penalty between the updated policy and the reference policy to avoid forgetting general language ability in pursuit of score, or generating increasingly strange boilerplate. The penalty coefficient should be searched in small steps: too large and learning stalls; too small and reward hacking appears.
Do not put unverifiable subjective style into the main reward. Style can be handled later with a separate preference stage or decoding parameters; otherwise the model may sacrifice correctness to cater to what “looks like good thinking.”
Stability and Data Recipe
Reinforcement learning is more variance-sensitive than supervised fine-tuning. At minimum, engineering practice should preserve the following.
Sample multiple trajectories for the same prompt and compute advantages within the prompt to reduce noise caused by differences in problem difficulty. Mix difficulty levels: if all problems are easy, the policy never learns to search; if all problems are far beyond its ability, rewards stay near zero for a long time and gradients fail. Temperature and the number of samples should decrease with the training stage: explore first, then converge.
Do not look only at average reward when checking checkpoints. Also monitor pass rate, average length, format failure rate, and divergence from the reference model. A monotonic explosion in length often means the model is buying time with empty words rather than becoming stronger. If reward rises but hidden tests decline, suspect verifier leakage or evaluation-set contamination before increasing the learning rate.
Deduplicate at both prompt level and answer level. Competition problems and interview problems are highly repeated on the public web; if training and evaluation come from the same source, metrics will be inflated. Keep a sealed set that has never entered sampling or reward calibration, and open it only for milestone evaluation.
For compute organization, it is more robust to separate trajectory generation, verification, and parameter updates: generation can use a pool of reasoning instances, verification can use stateless jobs, and updates can be concentrated on a smaller training cluster. Object storage can hold trajectories and reward logs, message queues can smooth peaks, and container platforms can provide elastic scaling. Logging and monitoring alerts should cover at least task failure rate, reward distribution quantiles, and gradient norm; otherwise it is impossible to tell whether a problem comes from data or optimization. These are standard practices on generic cloud resource categories and do not depend on any proprietary interface name.
From Large Policy to Deployable Small Models
A teacher model at the 660B scale is suitable for experiments that establish the capability ceiling, not for all online scenarios. The goal of distillation is for the student model to approach the teacher’s pass rate on target tasks while reducing latency, memory footprint, and cost per request to a range acceptable to the business.
The available supervision signal is the teacher’s text on high-reward trajectories, not all of the teacher’s samples. First use verifiers to select correct samples with relatively concise reasoning, then have the student perform conditional generation. Distilling only final answers loses the search path; dumping all failed trajectories into training teaches the student to imitate mistakes. A more stable mix is mainly correct trajectories, supplemented by a small number of “wrong, then self-corrected, and finally passed verification” trajectories with correction points clearly marked.
Student size should be chosen by business slice rather than by chasing a single flagship small model. For example, interactive coding assistants care more about latency and may use a medium-sized model with stronger code-execution feedback; offline batch proof or long-document review cares more about accuracy and may keep a larger student or use a teacher–student cascade: the student answers first, and low-confidence or verification-failure cases go back to the teacher. A cascade is often more controllable than blindly quantizing an oversized model.
After distillation, it is still advisable to run a small round of reinforcement learning or rejection-sampling fine-tuning. The reason is that the student’s error distribution differs from the teacher’s, and directly copying the teacher’s reward curve can overfit the teacher’s style. Using the same verifier to run short-horizon optimization on the student’s own samples usually improves one-pass success rate more than continuing to pile on teacher text.
Evaluation: Separate Capability, Style, and Cost
Evaluation should have at least three axes so that a single total score does not mask regression.
Capability axis. For math, use closed problems from easy to hard with equivalence checking. For code, use hidden tests and distinguish “sample passed” from “adversarial case passed.” For natural language reasoning, use questions that can be answered correctly only by citing the provided material, reducing memorization shortcuts. When reporting pass rate, also report length and retry count.
Robustness axis. Paraphrase the problem statement, add irrelevant sentences, and reorder conditions to see how much pass rate drops. If a reasoning model is strong only on the original template, it will fail quickly after deployment.
Cost axis. Record average generated tokens per problem, verifier calls, and end-to-end latency. If post-training raises pass rate from acceptable to slightly higher but doubles tokens, the product side may still prefer the shorter policy.
Style control should be scored separately: whether the required language is used, whether the final answer is placed in the agreed position, and whether irrelevant preamble is avoided. Do not add style scores to the capability total and then claim “comprehensive leadership.” Comparison experiments must fix decoding parameters, context length, and whether external execution is allowed; otherwise they are not comparable.
Serving and Integration Scenarios
After a model is released, value comes from integration, not from the weight file itself. Common deployment patterns can remain neutral and replaceable.
Online inference: expose a unified interface through a microservice or inference gateway. Upstream sends only the prompt, constraints, and timeout; downstream can switch between student models of different sizes. Keys, quotas, and request logs are needed, but do not retain complete user code or private problem statements in logs for long periods.
Tool collaboration: for code requests, send model output to an isolated execution sandbox and feed back only test results; for verification and retrieval requests, obtain structured evidence first and then generate conclusions. The model should not directly have write access to production systems.
Scenario slices: assistant dialogue emphasizes low latency and interruptibility; search augmentation emphasizes evidence citation; content generation emphasizes style and safety filtering; industry terminals such as inspection and quality checking emphasize auditable input and output and human review. The same post-trained weights do not need the same prompt; system constraints should be tailored by scenario.
If a general cloud platform such as Baidu AI Cloud is used, training trajectories, checkpoints, and evaluation reports can be placed in object storage, containerized training jobs, and logging services, with monitoring and alerting on verification pass rate and latency. This concerns only resource organization; it does not mean the platform completes model customization or guarantees results for the business.
Open weights with permissive licenses can lower the trial threshold for teams: research teams can reproduce training recipes, and business teams can fine-tune student models in private environments. Open does not mean free of responsibility. Before launch, license compliance, data provenance review, and output safety evaluation are still required. Treating “downloadable” as “directly usable in all regulated scenarios” is not valid.
Risks and Stopping Conditions
Reward hacking: if the verifier checks only the final number, the model learns to write irrelevant content in the reasoning and hit the answer on the last line. Countermeasures include hidden tests, multiple equivalence checks, and spot-checking whether the reasoning actually uses the conditions.
Capability hallucination spillover: a high math score does not mean open-domain facts are reliable. Product copy should limit the task scope.
Cost and data leakage: before sending user code to a third-party execution environment, isolation and retention limits are required. Trajectory data may contain sensitive prompts, and distillation sets need desensitization.
Training should have stopping lines: several consecutive evaluations on the sealed set with no improvement, rising format failure rate, or divergence constraints frequently hitting the cap. At that point, adding data or changing the verifier is more effective than continuing to increase the learning rate.
Conclusion
Small amounts of annotation plus large-scale reinforcement learning are suitable for reasoning tasks whose rewards can be checked by machines. Distillation is responsible for compressing the teacher’s high-reward behavior into a deployable size. Evaluation must separate correctness, robustness, and cost. By advancing through four steps—verifiable rewards, small updates, sealed evaluation, and student re-reinforcement—post-training can move from a demo metric to an operable technical process.
