Open-Source Reasoning LLMs and Distilled Small Models: Engineering Practices

    This article explains how to combine large open-source reasoning models with smaller distilled models in production. It covers the overall architecture, distillation data construction, training and evaluation methods, deployment routing and cost optimization, security and compliance, and a phased rollout plan for engineering teams.

    Open-Source Reasoning LLMs and Distilled Small Models: Engineering Practices

    1. Background: Why a Dual-Track “Primary Model + Small Model” Strategy

    Reasoning models create value by breaking a complex problem into verifiable intermediate steps before giving a final answer. However, very large models often face high inference costs, long response latency, and limited concurrency when deployed directly in production. For enterprise developers, the real need is not a model with a very high capability ceiling alone. They need an engineering approach that balances quality, cost, latency, and controllability.

    Public practices from a category of open-source reasoning model projects follow a common path. These projects release two very large primary model versions and distill several smaller models of different sizes from the primary models’ outputs. The smaller models cover different parameter ranges. Medium-sized versions such as 32B and 70B come close to comparable closed-source lightweight reasoning models on some public evaluation dimensions. This strategy works because the primary models explore the capability ceiling and generate high-quality reasoning traces, while the smaller models handle high-concurrency, low-cost business scenarios that can be deployed privately.

    This article does not review the user experience of any specific product. It treats the topic as a general technical problem: how to understand the collaborative architecture of open-source primary reasoning models and distilled small models, how to build distillation data and evaluation systems, and how to implement deployment routing, cost optimization, and security governance.

    2. Overall Architecture: Primary Model Training and Distilled Small Models in Parallel

    A complete “primary model + distilled small model” system usually has three layers:

    1. Primary model layer: This layer includes a base reasoning version and an enhanced version. The base version helps researchers observe how reasoning capability forms. The enhanced version targets final application performance. The core value of the primary model is generating high-quality, verifiable, and diverse reasoning traces.
    2. Distillation data layer: Starting from a set of business problems, this layer collects the primary model’s reasoning processes and final answers. It then applies answer verification, format cleaning, difficulty stratification, deduplication, and safety filtering to produce trainable data.
    3. Small model layer: Lightweight models are trained at several parameter scales to form a capability gradient. A small model is not simply a compressed version of the primary model. It learns the primary model’s patterns for breaking down problems, expressing steps, and converging on answers.

    In practice, teams should treat this system as a closed loop. Business problems enter a data pool. The primary model generates reasoning samples. A verifier filters out low-quality samples. Small models are trained and evaluated, and online feedback flows back into the data pool. This prevents capability from stalling after a one-time distillation.

    3. Key Stages in Distilling Small Models

    1. Building Distillation Data: Quality Before Quantity

    Distillation results depend heavily on data quality. Build the dataset along the following dimensions:

    • Problem coverage: Include fact-based questions, mathematical reasoning, code understanding, structured extraction, multi-hop reasoning, and business rule judgment.
    • Reasoning trace format: Standardize intermediate steps, final answers, and confidence or verification markers. This makes it easier to control the output structure during training.
    • Answer verification: For verifiable tasks, use rule-based checks, unit tests, numerical comparison, or cross-validation. For open-ended tasks, use consistency checks across multiple models or manual spot checks.
    • Difficulty stratification: Sample across easy, medium, and hard tiers. This keeps small models from learning only short reasoning chains.
    • Deduplication and desensitization: Remove near-duplicate samples. Clean personal information, keys, and internal identifiers from the data.

    An illustrative data structure looks like this:

    1. {
    2. "id": "q-001",
    3. "prompt": "Business problem description",
    4. "reasoning_steps": ["Step 1", "Step 2", "Step 3"],
    5. "final_answer": "Final answer",
    6. "difficulty": "hard",
    7. "verified": true,
    8. "safety_tag": "pass"
    9. }

    The data filtering process can be expressed in pseudocode:

    1. for sample in candidate_dataset:
    2. if not answer_verify(sample.final_answer):
    3. continue
    4. if contains_sensitive(sample):
    5. sample = desensitize(sample)
    6. if reasoning_length(sample) > MAX_LEN:
    7. sample = compress_reasoning(sample)
    8. if duplicate(sample, seen_set):
    9. continue
    10. train_queue.push(sample)

    2. Training Strategy: Combining Supervised Fine-Tuning and Preference Optimization

    Distilling a small model usually takes more than one round of supervised fine-tuning. Proceed in stages:

    • Stage 1: Learning format and patterns. Use high-quality reasoning traces for supervised fine-tuning. The model learns an output structure of “analyze first, verify next, then answer.”
    • Stage 2: Improving answer quality. For each problem, rank multiple candidate answers by preference. This pushes the model toward answers that are more accurate, more concise, and better aligned with business constraints.
    • Stage 3: Controlling length and stability. Longer reasoning chains are not always better. Control unnecessary repetition, excessive self-doubt, and format drift.

    During training, watch for mode collapse. A small model may imitate surface tone without learning to verify its reasoning. Detect this with hard-sample replay, comparisons of incorrect answers, and domain-specific evaluation sets.

    3. Evaluation Framework: Performance, Cost, and Robustness Together

    Do not judge a model by accuracy alone. Build evaluation around four categories of metrics:

    • Capability metrics: Answer accuracy, step verifiability rate, code test pass rate, and structured output compliance rate.
    • Cost metrics: Average input and output tokens, inference cost per request, concurrent throughput, and P95 latency.
    • Robustness metrics: Performance degradation under perturbed questions, long contexts, mixed-language input, and noisy input.
    • Safety metrics: Sensitive information leakage rate, prompt injection block rate, rate of advice that exceeds authorization, and output moderation hit rate.

    Set a separate baseline for each model size, such as 32B and 70B. Do not apply one threshold to compare them. Small models suit well-defined rules and high-frequency scenarios. Larger models suit complex, long-chain tasks.

    4. Deployment and Cost Optimization: Making Model Routing the Default

    In production, sending every request to the primary model is not advisable. A better approach combines model routing with tiered inference:

    • Simple tasks: A small model handles them directly. Examples include classification, extraction, short question answering, and format conversion.
    • Medium tasks: A small model produces a candidate answer first. A verifier or a larger model then reviews it.
    • Complex tasks: Route the request to the primary model, keep the full reasoning trace, and check key steps.
    • Fallback on failure: When a small model shows low confidence, produces non-compliant output, or fails verification, escalate the request automatically to a larger model.

    On the deployment side, consider these optimizations:

    1. Quantization and batching: Reduce GPU memory usage and increase throughput within an acceptable accuracy loss.
    2. KV cache and concurrency scheduling: Set cache policies and queue limits suited to long reasoning outputs. This prevents tail latency from growing.
    3. Elastic scaling: Adjust instance counts to match peak and off-peak business load. Models with slow cold starts can keep a minimum number of warm instances.
    4. Observability: Monitor latency, throughput, error rate, token consumption, reasoning chain length distribution, and fallback rate.
    5. General cloud architecture: Use object storage to distribute models and datasets, a container platform to deploy inference services, and a log service with monitoring and alerting to build observability. For example, on Baidu AI Cloud, teams can use its general-purpose container platform, object storage, log service, and monitoring and alerting capabilities to achieve elastic deployment and operations management. The focus should be on architectural portability and security isolation, not on binding to platform-specific interfaces.

    5. Security and Compliance: Reasoning Chains Are Sensitive Assets

    Reasoning model outputs include intermediate steps. These steps can expose internal rules, data fragments, or system prompts. At a minimum, implement the following measures:

    • Input desensitization: Remove personal information, keys, and internal identifiers before input reaches the model.
    • Prompt injection defense: Separate system instructions from user input. Prevent user input from overriding security policies.
    • Output moderation: Run sensitive content detection on both final answers and reasoning chains.
    • Reasoning chain display policy: For end users, show only summarized steps. Keep full reasoning chains for auditing and debugging.
    • Audit logging: Record request IDs, model versions, routing decisions, fallback reasons, and moderation results to support traceability.

    6. Rollout Roadmap and Practical Recommendations

    Proceed in five steps:

    1. Scenario selection: Start proofs of concept with high-frequency scenarios where answers are verifiable and error tolerance is clearly defined.
    2. Baseline establishment: Measure the accuracy, latency, and cost of the primary model and the small models separately.
    3. Data loop: Generate samples with the primary model, filter them with a verifier, train the small models, and feed online results back into the pool.
    4. Canary release: Route low-risk traffic to the small model first, set fallback thresholds, and expand the share gradually.
    5. Continuous evaluation: Update the evaluation set weekly or with each model version to catch data drift and model regression.

    Overall, combining open-source primary reasoning models with distilled small models is not simply a way to cut costs with large models. It is an engineering system that spans data production, capability transfer, routing and deployment, and security governance. Developers should focus on verifiable data, tiered routing, and observable operations. These practices help deliver stable, controllable, and scalable reasoning capability within limited compute.