Distilling Large Model Reasoning Capabilities: Practices for Small Model Deployment

    As ultra-large reasoning models with hundreds of billions of parameters become open-sourced, their high deployment costs make them inaccessible to most development teams. This article explores how to transfer reasoning capabilities from large models to smaller, deployable models using data distillation. It covers the core concepts of reasoning trace extraction, the complete training pipeline—including question bank construction, teacher generation, filtering, and supervised fine-tuning—and provides pseudocode for the distillation process. Additionally, it discusses evaluation methods, engineering deployment recommendations, and common pitfalls to avoid when adapting small models for multi-step reasoning tasks.

    Background and Problem Definition

    Recently, ultra-large reasoning models with around 660 billion parameters have been open-sourced to the community. These models excel at mathematical derivation, code generation, and multi-step logical tasks. However, deploying them requires multi-GPU environments with high memory, leading to high inference costs that make them inaccessible to most development teams.

    Therefore, the core question the industry is focusing on is: How can we transfer the reasoning capabilities of large models to smaller models so they can perform multi-step reasoning tasks with acceptable computing power? The open-source community has already seen a batch of distilled small models, where versions with 32 billion and 70 billion parameters match the lightweight versions of well-known proprietary reasoning models in multiple capabilities.

    1. Core Concept: Knowledge Distillation of Reasoning Capabilities

    Knowledge Distillation (KD) refers to using a more capable teacher model to guide the training of a student model. The traditional approach involves the student model fitting the probability distribution of the teacher model’s output, known as soft labels. In reasoning scenarios, another more common approach is data distillation: letting the teacher model generate a complete reasoning process and final answer, and then using these samples as supervised data to train the student model.

    The differences between the two are as follows:

    • Soft Label Distillation: The student model learns the teacher model’s probability distribution for each token. It contains a large amount of information but requires the teacher and student models to share a vocabulary and requires storing large amounts of logits data.
    • Data Distillation: Only requires the text output from the teacher. It is simple to implement, has no restrictions on vocabulary or architecture, and is suitable for cross-scale and cross-architecture transfer.

    In the practice of large-scale open-source small models, data distillation has become the mainstream choice due to its low engineering barrier and high reproducibility.

    2. Why Reasoning Traces are Key Signals

    The value of a reasoning model lies primarily in its intermediate derivation process. If training data only retains the final answer, the student model can only mimic the format of the conclusion and struggles to learn the problem-solving strategy.

    A complete reasoning trace includes steps such as problem decomposition, intermediate calculation, self-checking, and backtracking correction. By learning these patterns, the student model acquires a reusable way of thinking. Such samples need to meet three conditions:

    1. The reasoning steps are coherent without obvious leaps.
    2. The final answer can be verified by a program or a standard answer.
    3. The language style is uniform, making it easier for the student model to converge.

    3. Complete Training Pipeline

    3.1 Building the Question Bank

    The question bank should be divided by domain, such as mathematics, code, logical reasoning, and science Q&A. Within each domain, questions should be layered by difficulty to avoid over-concentrating on simple problems. The number of questions and domain coverage are equally important; insufficient coverage will lead to obvious degradation of the student model on unseen question types.

    3.2 Teacher Model Generation

    For each question, sample multiple reasoning paths, commonly generating 4 to 8 candidates per question. Use a medium sampling temperature to ensure path diversity without significantly degrading output quality. When saving, record the complete output, including the separation markers between the reasoning segment and the answer segment, for subsequent processing.

    3.3 Filtering and Verification

    The filtering step directly determines the quality of the distilled data and mainly includes four types of checks:

    • Answer Verification: Compare math questions with standard answers, and run unit tests for code questions.
    • Format Verification: Confirm that the markers for the reasoning and answer segments are complete without truncation.
    • Deduplication: Remove duplicate samples based on the similarity of questions and answers to prevent the model from overfitting to certain fixed expressions.
    • Language Filtering: Remove outputs that mix multiple languages or contain gibberish.

    After filtering, the data volume usually decreases significantly. This is normal; data quality takes priority over quantity.

    3.4 Student Model Fine-Tuning

    The student model is typically trained using Supervised Fine-Tuning (SFT). The loss function only calculates tokens in the assistant’s reply; the question part must be masked, otherwise the model will learn the habit of repeating the question. The learning rate is generally an order of magnitude lower than the pre-training stage, and the number of epochs should not be too high to prevent overfitting on limited data.

    4. Sample Code: Core Steps of Data Distillation

    The following pseudocode illustrates the main pipeline of generation, verification, deduplication, and fine-tuning. The parameters are examples only; actual values need to be adjusted based on model size and data volume.

    1. # Pseudocode: Core pipeline of data distillation
    2. dataset = []
    3. for question in question_bank:
    4. # Teacher model samples multiple reasoning paths per question
    5. candidates = teacher.generate(question, n=8, temperature=0.7)
    6. for c in candidates:
    7. # Answer correctness verification
    8. if not verify_answer(question, c.answer):
    9. continue
    10. # Output format verification
    11. if not check_format(c.text):
    12. continue
    13. dataset.append({"prompt": question, "response": c.text})
    14. # Deduplication based on similarity
    15. dataset = dedup(dataset)
    16. # Supervised fine-tuning of the student model; example lr and epochs need adjustment based on actual conditions
    17. student = supervised_finetune(base_model, dataset, lr=1e-5, epochs=2)

    In this pipeline, verify_answer and check_format require the most effort. The stricter the verification rules, the cleaner the final data, but fewer samples are retained. A balance must be struck between the two.

    5. Capability Boundaries and Evaluation Methods for Small Models

    Smaller student models can approach the performance of larger models on some benchmarks, but they still have the following limitations:

    • They are prone to omitting conditions midway through long-chain reasoning, causing inconsistency.
    • Their transferability drops noticeably when facing question types outside the training distribution.
    • For knowledge-based questions, they are limited by the base model’s knowledge volume; reasoning capabilities cannot fully compensate for a lack of knowledge.

    When evaluating, it is recommended to cover four dimensions simultaneously:

    1. Standard Benchmark Accuracy: Facilitates horizontal comparison with public results.
    2. Custom Domain Test Sets: Closer to real business scenarios and can expose issues not covered by public benchmarks.
    3. Reasoning Length and Latency: Reasoning models have longer outputs; it is necessary to track time-to-first-token and overall duration.
    4. Format and Refusal Stability: Check whether the output structure can be parsed by downstream programs.

    During evaluation, fix the random seed and run multiple times, reporting the fluctuation range to avoid misinterpreting a single result.

    6. Engineering Deployment Recommendations

    • Resource Management: Store training data, model weights, and evaluation sets in object storage and manage them by version number to ensure every experiment is traceable.
    • Logging and Troubleshooting: Integrate training and inference logs into a unified logging service to facilitate locating anomalous samples and outputs.
    • Monitoring and Alerting: Set up monitoring and alerts for inference latency, memory usage, and error rates to intervene promptly when spikes occur.
    • Inference Optimization: Use batching and quantization schemes to reduce single inference costs. Quantization introduces a certain loss of precision, so its effectiveness must be re-verified on the evaluation set before going live.

    7. Common Pitfalls

    1. Believing that more data yields better results. A large amount of unfiltered samples will introduce incorrect reasoning patterns, and the student model may learn to confidently produce flawed processes.
    2. Focusing only on final answer accuracy. A correct answer with a skipped or self-contradictory reasoning process will still cause problems in practical applications. Manual sampling to check the reasoning process is necessary.
    3. Directly adopting the teacher model’s hyperparameters. The capacity gap between the teacher and student models is significant. Learning rate, batch size, and epochs all need to be re-tuned.
    4. Neglecting domain coverage. A student model trained only on math problems will often perform poorly on code or logic tasks. Question bank design should precede training design.