Model Distillation in Practice: Sample Distillation and Weight Adjustment for Lightweight Reasoning Models

    This article walks through a practical pipeline for distilling large reasoning models into compact, deployment-friendly ones. It covers a two-stage training approach—supervised fine-tuning on teacher-generated reasoning traces followed by lightweight reinforcement learning—plus a final activation-based weight adjustment step to reduce over-refusal behavior. The discussion includes data generation strategies, training configuration details, evaluation metrics such as KL divergence and refusal rate, and a reusable four-step methodology for teams working with limited compute budgets.

    Why Small Models Are Becoming the Mainstream Choice for Inference

    Large models with hundreds of billions or even trillions of parameters have demonstrated strong capabilities in mathematical reasoning and logical deduction. However, the cost of deploying such models directly is prohibitive for most teams. High GPU memory consumption, slow inference latency, and massive computational overhead mean that production environments often rely on far smaller models that are usable, affordable, and fast.

    Model distillation is the core technical route to resolve this trade-off: a student model with one to two orders of magnitude fewer parameters learns to mimic the reasoning behavior of a larger teacher model. A recent community example that attracted wide attention was a small model with only 9 billion parameters that performed remarkably well on mathematical and STEM reasoning benchmarks, even topping the trending charts on an open-source model community. This article strips away product-specific details and breaks down the full pipeline from a general technical perspective—a “two-stage distillation plus weight post-adjustment” approach—offering a reusable engineering methodology for developers.

    Stage 1: Supervised Fine-Tuning on Teacher-Generated Reasoning Traces

    Data Generation: The Process Matters More Than the Answer

    The first step of distillation is not “getting the weights” but “getting the data.” A practical, high-efficiency approach is to have the teacher model generate samples in a high-quality reasoning mode. In a widely referenced example, the team used a teacher model with a total of 1.6 trillion parameters to generate approximately 250,000 mathematical and STEM samples.

    The key value of these samples lies in the fact that they record complete reasoning trajectories:

    • How the problem is approached from a specific angle;
    • How a complex problem is decomposed into solvable sub-problems;
    • Which theorems or rules are applied at each step of the derivation;
    • How the final answer is aggregated from intermediate results.

    This differs from naive distillation that only preserves “question–answer” pairs. Research has shown that allowing the student model to learn intermediate reasoning steps—often called chain-of-thought distillation—significantly improves its generalization on unseen complex problems. The reason is that the reasoning process itself acts as a supervisory signal, constraining the model’s internal representation space to more closely match the teacher’s thinking structure, rather than merely fitting the final output.

    Implementation Details for Supervised Fine-Tuning

    After collecting the samples, the team selected an open-source 9-billion-parameter base model for supervised fine-tuning (SFT). Several engineering points are worth noting:

    1. Data format alignment: Training samples must be organized according to the student model’s chat template. This typically includes a system prompt, a user question, and the teacher’s reasoning trajectory. The label region is constructed as a concatenation of “question + reasoning process + answer” so that the loss function is computed only on the valid content.
    2. Data mixing ratio: In this round, training deliberately focused only on mathematics and STEM, excluding programming data. This is a reasonable engineering decision—a single-domain data mix allows the model to converge more sharply on the target capability, at the cost of reduced generality. If multi-domain coverage is required, a mixed dataset should be used.
    3. Training scale control: A 9B model can complete a high-quality round of SFT with tens of thousands of GPU compute hours. With efficient parallelization strategies, this is affordable even for small- or medium-sized teams.

    Stage 2: Lightweight Reinforcement Learning to Address Remaining Gaps

    After SFT, the model can imitate the teacher’s reasoning, but two typical issues remain: it may drift off mid-reasoning and still force a conclusion, and it lacks optimization at the preference level for its own reasoning paths.

    To address this, the case used a lightweight reinforcement learning method called GSPO—Group-based Sequence Preference Optimization. Its core idea can be summarized as:

    • Sample a group of candidate answers for the same question;
    • Use the relative scores within the group (e.g., whether the final answer is correct) as the advantage estimation signal, rather than relying on a separately trained value network;
    • Replace absolute rewards with relative comparisons within the group to reduce training variance and computational overhead.

    This method’s advantages are low compute requirements and simple implementation, making it especially suitable for a “last-mile” preference alignment on a distilled model. One risk to monitor is that the data distribution shift during reinforcement learning may cause the model to “forget” the formatting learned in SFT. Therefore, it is common to freeze some lower-layer parameters, control the learning rate, and include SFT-stage data in the evaluation set for regression testing.

    Stage 3: Refusal Behavior Adjustment Based on Activation Analysis

    After training for reasoning capabilities, there is one more unconventional post-processing step: adjusting the model’s refusal behavior.

    Where Does Refusal Come From

    Models that have undergone safety alignment encode a “refusal direction” in their internal activations. When an input is judged as sensitive or potentially harmful, activations at certain layers shift toward this direction, resulting in a refusal response. The problem is that alignment can sometimes over-generalize, causing the model to frequently refuse completely harmless prompts, which severely harms usability.

    How the ARA Method Works

    The approach used in the case is based on Activation-based Refusal Ablation (the general idea):

    1. Construct two sets of contrasting prompts: one set of common harmless instructions, and another set of prompts that easily trigger refusals;
    2. Run forward passes on both sets separately, collect hidden-state activations from each layer, compute an average difference vector between the two activation sets in the direction space, and identify the direction most correlated with refusal behavior;
    3. Apply a projection modification to the weights of several layers (in the case, layers 9 through 24) so that the component in that direction is significantly weakened.

    This entire process requires no retraining. Essentially, it is a “direction ablation” in weight space, so the cost is extremely low—usually completing within a few hours.

    Evaluation Metrics: KL Divergence and Refusal Rate Comparison

    Any such adjustment must quantify side effects. The case reported two key metrics:

    • KL divergence (0.0422): Measures how much the model’s output probability distribution changes after adjustment. A smaller value means less change in behavior on normal tasks. A value of 0.04 is considered a low level, indicating that side effects are manageable.
    • Refusal rate comparison: On the same set of 100 test prompts, the model refused all of them before adjustment, but after adjustment it refused only 3, while the ratio of “output as instructed” reached about 97%.

    The lesson for all developers is: any weight post-adjustment must report both the effectiveness metric and a drift metric. A solution that only shows benefits without reporting drift is not trustworthy in practice.

    Engineering Methodology Summary

    Reviewing the full pipeline, we can extract a reusable four-step process:

    1. Teacher data generation: Use the strongest available model in its highest-quality reasoning mode to produce process-level samples. A scale of tens of thousands to hundreds of thousands is appropriate.
    2. SFT as the foundation: Perform domain-focused supervised fine-tuning on a medium-sized open-source base model, with careful control of the data mix.
    3. Lightweight RL alignment: Apply a group-relative-advantage method for a low-cost round of preference optimization to fix systemic flaws in reasoning chains.
    4. Targeted weight adjustment: For specific behavioral issues (such as over-refusal), use activation-analysis-based methods to make surgical modifications, and verify with KL divergence regression.

    It is worth emphasizing that the improvement in STEM performance after distillation is usually modest but stable. The real benefit is a dramatic reduction in inference cost—which is exactly the core value of small models in production environments. For teams that want to deploy such a workflow on their own cloud infrastructure, the data generation, fine-tuning, and evaluation monitoring steps can all be supported by common GPU clusters, object storage, and model serving platforms, combined with standardized logging and alerting systems to ensure observability during training.

    Model distillation is not magic that “beats a giant with a dwarf.” It is an engineering path determined by data quality, training strategy, and post-processing precision. Mastering this methodology means that a team can approach the upper limit of a top-tier large model in a specific domain with a limited compute budget.