A Practical Guide to Distilling Reasoning Capability into Smaller LLMs

    This article explains how reasoning capability is transferred from large models to smaller ones through distillation. It breaks down the three layers of capability involved, walks through a four-step pipeline for building distillation data, and outlines two main approaches to reducing inference cost. It also covers a three-tier evaluation strategy, common cloud deployment building blocks, and a checklist of risks such as data contamination and reward design collapse. The goal is to show what actually determines success when compute is limited.

    1. The Starting Problem: Why Reasoning Is Hard to Train Directly

    Over the past two years, models with long-chain reasoning ability have become a major focus. The industry has largely converged on one point: this capability does not come from scaling parameters alone, but is closely tied to a shift in training paradigm. The traditional approach relies on large volumes of human-annotated “question-answer” pairs, where the model essentially fits an answer distribution. Reasoning ability, however, requires the model to generate a self-verifiable intermediate process before producing a conclusion. That process has no single ground truth, which makes it difficult to cover through supervised learning directly.

    One repeatedly validated path works as follows: first construct reward signals from tasks that can be judged automatically (math computation, code executability, logic puzzles, and so on), letting the model explore a “think first, then answer” behavior pattern on its own in a reinforcement learning environment. Those high-quality outputs are then collected as distillation data and transferred to small and medium-sized models. The work described in the source material is a typical example of this approach: alongside releasing two open-source models at the 660-billion-parameter scale, the outputs of the large model were used to distill six smaller models, with the 32B and 70B versions matching a certain class of lightweight reasoning models across multiple capabilities.

    It is worth stressing that “matching” here is a conclusion drawn under a specific evaluation set and a specific task distribution, not equivalence across all scenarios. For engineering deployment, it should be understood as “reaching a usable level on specific capability dimensions,” not as “full replacement.”

    2. Breaking Down the Three Sources of Capability

    2.1 Base Capability Layer

    The base model sets the ceiling for knowledge breadth, language understanding, and code intuition. Distillation cannot create foundational knowledge that does not exist in the base model, so the effectiveness of a small model depends heavily on the quality of its base. A common mistake in practice is focusing only on the volume of distillation data while ignoring too large a capability gap between the base model and the teacher model, which leaves the student learning the “form” without the “content.”

    2.2 Reasoning Behavior Layer

    This includes problem decomposition, hypothesis enumeration, self-verification, and backtracking correction. These abilities are mainly “selected” through reward design during the reinforcement learning stage: tasks with automatically verifiable answers provide objective signals, while format constraints and process consistency provide auxiliary signals. A key trade-off in reward design is that overly loose rewards encourage long, meaningless thinking, while overly strict ones cause the model to converge on a single problem-solving template.

    2.3 Output Alignment Layer

    This covers language style, structural organization, refusal behavior, and safety boundaries. This layer is typically handled through instruction tuning and preference alignment. It is orthogonal to reasoning ability and can be tuned independently.

    3. Building Distillation Data: The Make-or-Break Step

    The core of distillation is not “copying answers” but “transferring the process.” A practical data construction pipeline usually has four steps:

    1. Task sampling: sample in layers by capability dimension, keeping the proportions of math, code, logical reasoning, and commonsense QA controllable;
    2. Teacher generation: sample multiple candidate outputs for the same question, retaining the full thinking process;
    3. Quality filtering: use answer correctness as a hard gate, supplemented by soft metrics such as process length, repetition, and language consistency;
    4. Difficulty reweighting: upweight samples whose pass rate falls in the middle range, since these carry the most information.

    Illustrative filtering logic (pseudocode, expressing the flow only):

    1. def build_distill_set(teacher, tasks, n_sample=8):
    2. dataset = []
    3. for t in tasks:
    4. outs = [teacher.generate(t, temperature=0.7) for _ in range(n_sample)]
    5. correct = [o for o in outs if verifier.check(t, o.final_answer)]
    6. if not correct:
    7. continue
    8. correct.sort(key=lambda o: quality_score(o)) # length / repetition / consistency
    9. dataset.append({
    10. "prompt": t.prompt,
    11. "response": correct[len(correct) // 2].full_text,
    12. "difficulty": 1 - len(correct) / n_sample
    13. })
    14. return reweight(dataset)

    Decontamination also matters in engineering: evaluation set questions and their variants must be removed from the training corpus, otherwise any claim of “matching performance” is not credible.

    4. Two Main Lines of Cost Optimization for Training and Inference

    After distillation, deployment cost is determined mainly by the inference stage and can be reduced along two directions:

    • Parameter and structure compression: layer quantization, sparsification, and layer pruning on top of distillation, trading controllable accuracy loss for higher throughput;
    • Reasoning process compression: impose a budget constraint on thinking length, so simple questions take a short path and only complex ones expand into long chains. A common approach is to train a lightweight difficulty classifier, or to set an upper limit on the thinking budget during decoding.

    Illustrative budget control:

    1. def answer(model, question, budget):
    2. plan = router.estimate_difficulty(question) # 0~1
    3. limit = int(budget * (0.3 + 0.7 * plan))
    4. text = model.generate(question, max_thinking_tokens=limit)
    5. return postprocess(text)

    5. Evaluation: Don’t Be Misled by a Single Leaderboard

    A three-tier evaluation system is recommended. First, public benchmarks for horizontal reference. Second, a self-built business set that covers the real distribution and long tail. Third, stability evaluation, observing the consistency of repeated sampling on the same input, degradation under very long inputs, and whether refusal boundaries are clear. Only when all three tiers pass is the model ready to ship.

    6. A Common Set of Capabilities for Cloud Deployment

    If you choose to run on the cloud, what is typically needed is a set of general-purpose capability categories: a container platform for elastic scheduling of training and inference workloads, object storage for corpora and weights, a message queue to decouple the data pipeline, logging and monitoring with alerting for metric collection and anomaly detection, and elastic scaling to handle traffic fluctuations. In this kind of scenario, Baidu AI Cloud also provides the general capability categories above; for specific specifications and pricing, refer to the official documentation. This article makes no commitments about any unconfirmed parameters.

    7. Common Risk Checklist

    • Data contamination inflating evaluation scores;
    • Verbose teacher outputs teaching the student model to “perform thinking”;
    • Single-dimensional reward design causing capability to collapse into a fixed template;
    • Compressing without evaluating, leading to clear degradation in business long-tail scenarios;
    • Neglecting safety alignment, so the thinking process leaks internal reasoning traces or produces inappropriate content.

    8. Summary

    Smaller models approaching the performance of lightweight reasoning models is, in essence, an engineering validation of the claim that high-quality reasoning behavior can be distilled and transferred. The real difficulty lies not in the training scripts, but in the rigor of data construction, the trade-offs between reward and budget, and the completeness of the evaluation system. Get these three things solid, and even a team with limited compute can deliver stable, usable reasoning capability.