Distilling a Large Model to 9B Parameters: Inference Transfer and Refusal Tuning

    This article provides a technical walkthrough of distilling the reasoning capabilities of a trillion-parameter model into a 9-billion-parameter student model. It covers a two-stage training pipeline—supervised fine-tuning on verifiable reasoning traces followed by lightweight reinforcement learning—and addresses the specific challenge of over-refusal in safety-aligned small models. The discussion includes data construction strategies, activation-level intervention for refusal suppression, evaluation methodologies, and practical engineering considerations for deployment.

    Distilling a Large Model to 9B Parameters: Inference Transfer and Refusal Tuning

    Transferring trillion-parameter-level reasoning abilities into a 9-billion-parameter model is a practical approach for reducing inference costs and improving the feasibility of private deployment. However, the real challenge is not simply feeding the large model’s outputs to a smaller one—it is ensuring that the student model learns a reusable problem-solving process, maintains stable output formatting, and balances safety alignment with useful responses. This article outlines a typical two-stage pipeline for distillation and refusal-behavior tuning, with a focus on data construction, supervised fine-tuning, lightweight reinforcement learning, activation-level intervention, and evaluation methods.

    1. Background: Why Distill the Process Rather Than Just the Answer

    The strengths of large models in math, physics, and engineering reasoning tasks generally come from longer intermediate reasoning chains: first identifying the problem type, then decomposing the conditions, selecting a formula or method, computing step by step, and finally verifying the answer. If only final answers are collected for training, a small model often learns the distribution of answers but not the path to arrive at those answers. This results in several common problems:

    1. It may solve problems similar to training examples by applying templates but fails quickly on slight variations.
    2. Output formats are unstable—steps are missing or skipped.
    3. Inference cost is unpredictable—simple problems may be over-expanded, while difficult problems terminate prematurely.
    4. Refusal boundaries are poorly calibrated—normal technical questions may be misclassified as high-risk.

    Therefore, a more effective approach is to have the teacher model generate samples with full solution traces, then train the student model to learn the complete process—from initial analysis, through decomposition and derivation, to the final conclusion. In practice, the teacher model, operating in an enhanced reasoning mode, generated approximately 250,000 math and engineering samples. These samples included not just the final answer, but also the problem-solving entry point, the decomposition of the problem, each derivation step, and the final output. This data was then used for supervised fine-tuning of a 9-billion-parameter base model, followed by an additional round of lightweight reinforcement learning.

    It is important to note that the goal of such an approach is usually not for a 9B model to fully replace a trillion-parameter model. Instead, it aims to approach usable performance in specific vertical capabilities while significantly reducing memory usage, latency, and deployment costs.

    2. Data Construction: Upgrading Answer Samples to Reasoning Traces

    High-quality distillation data is the foundation of the entire pipeline. A usable reasoning trace sample should include at least the prompt, domain, difficulty level, reasoning steps, final answer, and a verification flag. A sample structure might look like this:

    1. {
    2. "prompt": "Find the optimal parameters under a given engineering constraint",
    3. "domain": "math_or_engineering",
    4. "difficulty": "hard",
    5. "reasoning_steps": [
    6. "Identify known conditions and the objective function",
    7. "Establish the constraint relationship",
    8. "Derive by case analysis",
    9. "Verify using boundary conditions"
    10. ],
    11. "final_answer": "Final result with units",
    12. "verified": true
    13. }

    During data construction, the following quality strategies are recommended:

    • Verifiable answers: For math and engineering problems, use computational checks, symbolic verification, or unit-test-style validation to prevent teacher model errors from polluting the training data.
    • Complete reasoning steps: Filter out traces that only provide conclusions, skip too many steps, or contain contradictory logic. For overly long traces, consider segmenting them while preserving the full chain of thought, so the student model does not simply learn verbosity.
    • Difficulty stratification: Sample across basic, intermediate, and hard difficulty levels to prevent the model from becoming overly reliant on simple formula application.
    • Deduplication and diversity: Deduplicate by problem semantics, templates, and solution paths. Retaining a variety of solution approaches improves generalization.
    • Clear domain boundaries: The approach described here focuses on math and engineering reasoning, without mixing in code-generation data, to avoid diluting the primary capability target.
    • Compliance and desensitization: Remove personal information, copyrighted full problem texts, and unnecessary source identifiers.

    Scale alone does not guarantee quality. Roughly 250,000 high-quality traces can already provide strong supervision signals for reasoning processes. However, if a large portion of the samples share similar formats, the effective information density decreases. Engineering effort should prioritize verifiability, step clarity, and coverage of long-tail cases.

    3. Phase One: Supervised Fine-Tuning to Teach Reasoning Paths

    The supervised fine-tuning (SFT) stage typically starts with the 9B open-source base model. The prompt is used as input, and the complete reasoning trace along with the final answer is used as the supervision target. The loss should be calculated mainly on the reasoning steps and answer tokens, not just on the final answer. A pseudocode sketch is as follows:

    1. for batch in reasoning_corpus:
    2. logits = student_model(batch.prompt)
    3. loss = cross_entropy(
    4. logits,
    5. target=batch.reasoning_steps + batch.final_answer,
    6. mask=batch.answer_and_trace_mask
    7. )
    8. loss.backward()
    9. optimizer.step()

    Key considerations for this stage:

    1. Learning rate and epoch control: Small models are prone to overfitting on formats when learning reasoning traces. Keep the learning rate moderate and limit the number of epochs; use warmup and early stopping.
    2. Sequence packing and memory optimization: Packing short samples improves throughput, but attention must be isolated between different samples. Gradient checkpointing can help with long traces.
    3. Format and content both matter: In addition to answer correctness, include a small number of samples that enforce strict output structure so the model reliably produces a step-by-step format.
    4. General capability replay: Mixing in a small amount of general instruction data can mitigate regression in conversational ability after specialized training, but keep the proportion low to avoid diluting the reasoning objective.
    5. No code data introduced: If the target is math and engineering reasoning, keep the training corpus boundaries consistent to avoid ambiguous capability attribution during evaluation.

    The primary benefit of this stage is to establish a behavior pattern in the student model: analyze first, then answer. It typically yields a moderate improvement in accuracy on STEM-type problems and raises the rate of well-formatted responses to approximately 97%. However, supervised fine-tuning alone may leave the model unstable on hard problems.

    4. Phase Two: Lightweight Reinforcement Learning for Stability

    After supervised fine-tuning, an additional round of lightweight reinforcement learning (RL) can further improve answer correctness, step consistency, and output length control. A policy optimization approach can be used, with the reward function composed of multiple components:

    • Answer correctness reward: scaled by exact final answer match for verifiable problems.
    • Process consistency reward: ensures key steps are not contradictory to the final conclusion.
    • Format reward: requires the output to include steps and a conclusion as specified.
    • Length penalty: discourages unnecessary expansion or excessive truncation.
    • KL constraint: limits the drift of the new policy relative to the SFT model.

    Pseudocode sketch:

    1. for prompt in verifiable_prompts:
    2. samples = policy.generate(prompt, n=4)
    3. rewards = [reward_fn(prompt, s) for s in samples]
    4. loss = policy_optimization_loss(samples, rewards) + beta * kl_divergence(policy, ref_policy)
    5. update(policy, loss)

    Lightweight RL should be applied cautiously: choose problems that can be automatically verified, control the number of training iterations and generation length, and avoid overfitting to reward or producing excessively verbose or oscillating outputs. The value of this stage lies in refining the “how to write steps” behavior learned during SFT into a more consistent “how to arrive at correct answers” behavior.

    5. Refusal Behavior Tuning: Correcting Over-Safety with Activation Comparison

    Small models that undergo safety alignment often show an over-refusal problem: normal math questions, engineering problems, or even harmless technical queries may be rejected. One practical approach described here uses an internal activation comparison method to suppress refusals. By comparing the model’s internal activations across different types of prompts, signals associated with refusal behavior can be identified. Modifying a selection of intermediate layer weights reduces the impact of these signals on responses. In one example configuration, the adjustment range is set to layers 9 through 24.

    The key to this method is not simply disabling refusals, but applying a layer-wise treatment:

    1. Identify refusal signals: Collect normal technical requests and high-risk requests, and observe activation differences in intermediate layers.
    2. Locate the adjustable layers: Intermediate layers often carry most of the semantic and behavioral patterns. Adjusting too shallow or too deep may degrade model capability.
    3. Apply small-range weight corrections: Limit the magnitude of modifications, and use KL divergence to monitor changes in the output distribution.
    4. Preserve safety boundaries: Clearly dangerous requests should still be rejected. The goal of reducing false refusals is not to remove the safety policy entirely.
    5. Red-team regression testing: After tuning, evaluate the model jointly with adversarial prompts, boundary prompts, and a normal problem set.

    In one publicly documented experiment, the change in output distribution after adjustment was described by a KL divergence of 0.0422. In a controlled comparison of 100 prompts, the distilled model refused all of them, while the adjusted version refused only 3. This demonstrates that activation-layer intervention can significantly reduce the false refusal rate. However, it also highlights the necessity of accompanying safety evaluations to ensure the model does not become overly permissive on high-risk requests.

    6. Evaluation Framework: Accuracy, Compliance, and Regression Risk

    Evaluation should not focus solely on a single accuracy metric. At minimum, the following dimensions should be considered:

    Dimension Focus Typical Metric
    STEM accuracy Final answer correctness on math, physics, and engineering problems Accuracy, per-difficulty accuracy
    Process quality Step completeness, logical consistency, no skipped steps Manual sampling, step consistency
    Output compliance Whether responses follow the required structure Format compliance rate (approximately 97% as a reference)
    Refusal behavior False refusals on normal requests vs. missed refusals on dangerous requests False refusal rate, missed refusal rate
    Distribution shift Output change before and after weight adjustments KL divergence
    General regression Dialogue, common sense, instruction following Small regression test set

    The evaluation set should be frozen in advance, and training data should be strictly isolated from evaluation data. For refusal tuning, it is important to separately track false refusals on normal technical problems and missed refusals on high-risk problems. Reporting only a decrease in refusal count is not sufficient.

    7. Practical Engineering Recommendations

    1. Evaluate before training: Build a verifiable problem set, a format checker, and a security red-team set before starting distillation.
    2. Prioritize data quality: 250,000 high-quality traces are more valuable than a much larger set of low-quality answers. Remove samples with contradictory steps.
    3. Decouple the two stages: SFT injects capability, lightweight RL adjusts stability, and refusal tuning acts as a separate behavioral correction phase.
    4. Version and rollback: Data, weights, and evaluation configurations should all be versioned. Keep the original safe-aligned version for rollback after refusal tuning.
    5. Monitor production traffic: After deployment, monitor the false refusal rate, answer verification failure rate, and long-tail request patterns. Retrain promptly if drift is detected.
    6. Maintain safety and compliance guardrails: Refusal suppression should be limited to harmless technical scenarios, while dangerous requests remain rejected. Do not open high-risk interfaces with unverified weights.

    8. Summary

    Distilling the problem-solving process of a trillion-parameter model into a 9B-parameter model relies on a combination of “process supervision + lightweight RL + behavior calibration.” Approximately 250,000 verifiable reasoning traces establish a problem-solving paradigm; lightweight policy optimization improves answer stability; and activation-comparison methods correct over-refusal. This pipeline can achieve usable STEM reasoning capabilities under limited compute, bringing the format compliance rate close to 97% and significantly reducing the false refusal rate. However, in engineering practice, evaluation, safety boundaries, and version rollback must be given equal weight to avoid sacrificing safety and reliability in the pursuit of lower refusal rates.