Training Pipeline and Reinforcement Learning Mechanisms for Reasoning LLMs

    This article breaks down the end-to-end training pipeline for reasoning-focused large language models, from foundation model selection and cold-start supervised fine-tuning to reinforcement learning and multi-stage optimization. It explains core mechanisms such as group relative policy optimization, reward function design, rejection sampling, and the importance of balancing reasoning ability with conversational quality, offering a practical framework for evaluating and building reliable reasoning models.

    I. Core Training Philosophy for Reasoning LLMs

    A reasoning-focused large language model differs from a conventional conversational model not merely in parameter count or data volume, but in the fundamental training objective. While traditional language models focus on optimizing the prediction of the next token, reasoning models must also learn how to decompose problems, verify intermediate conclusions, identify errors, and attempt alternative approaches.

    These capabilities are generally not acquired through a single training phase. They are constructed progressively through multiple stages:

    1. Pre-train a foundation model on large-scale corpora.
    2. Apply cold-start supervised fine-tuning using a small number of high-quality examples.
    3. Use reinforcement learning (RL) to enhance reasoning skills on verifiable tasks.
    4. Filter high-quality samples from the RL process and feed them back into the supervised dataset.
    5. Conduct comprehensive training covering mathematics, code, knowledge-based QA, and general conversation.
    6. Apply full-scenario reinforcement learning to balance correctness, format, expression, and safety.

    The critical factor here is not simply “making the model think more.” It is establishing a closed training loop in which the quality of thinking can be evaluated. The model generates answers, a reward mechanism judges their quality, and a training algorithm adjusts the model accordingly, encouraging it to produce higher-quality reasoning paths over time.

    II. The Foundation Model Determines the Upper Bound of Reasoning Training

    Reinforcement learning for reasoning is typically built upon a fully pre-trained base model. The scale of the base model, data quality, language coverage, and the proportion of code and mathematical corpora all influence downstream training outcomes.

    A common architectural choice is the mixture-of-experts (MoE) design. These models can contain hundreds of billions of total parameters but activate only a subset of expert networks per token. Compared with dense models that activate all parameters, MoE architectures maintain a larger capacity while keeping inference costs manageable.

    Pre-training data for foundation models generally includes web text, books, technical documentation, code, and mathematical material. Even without deliberately introducing synthetic reasoning data, the public corpus is likely to contain substantial content generated by other generative models. As a result, the base model may already have indirect exposure—via web pages—to structured problem-solving text, program analysis traces, and QA examples.

    This leads to two important conclusions:

    First, reinforcement learning does not teach a model to reason from scratch. The base model usually already possesses language understanding, knowledge retrieval, code generation, and some mathematical pattern recognition. RL acts more as a mechanism for filtering, strengthening, and reorganizing existing capabilities.

    Second, the language distribution of training data directly affects how the model outputs text. If the base corpus is dominated by two languages and the reward function only checks final correctness without considering language consistency, the model may mix languages during reasoning and exhibit unstable expression.

    III. Direct Reinforcement Learning and Its Value

    To study whether a model can develop reasoning ability purely from outcome feedback, a more direct training route can be adopted: starting from the base model and applying RL without any prior reasoning-example supervised fine-tuning.

    For problems with automatically verifiable answers, such as mathematics and programming, the training system can check whether the final result is correct. Examples include:

    • Mathematical problems verified through symbolic computation or exact answer matching.
    • Programming problems judged by compilation, execution, and test cases.
    • Format-oriented tasks checked for adherence to predefined structures.
    • Logic problems evaluated through rules or a validator.

    Under this training scheme, the model must explore which output patterns are more likely to yield rewards. As training progresses, the model may develop behaviors such as deferred answering, step-by-step reasoning, backtracking, and iterative revision.

    However, direct RL also has clear limitations. Early outputs often lack stable formatting, reasoning processes can become unnecessarily verbose, and problems such as language mixing, repetitive loops, and ineffective self-correction may surface. The reason is straightforward: outcome rewards tell the model whether the answer is “right” or “wrong,” but do not indicate how to organize a better reasoning process.

    Direct RL is therefore well suited for validating whether outcome-based rewards can induce reasoning behavior, but it may not be ideal as the final production training pipeline.

    IV. The Role of Cold-Start Supervised Fine-Tuning

    To reduce the difficulty of exploration in the early stages of RL, engineering pipelines typically construct a batch of high-quality cold-start data and use it for supervised fine-tuning of the base model.

    Cold-start data does not need to cover all problem types, but it should provide strong demonstrations, emphasizing the following:

    • How to understand a complex problem.
    • How to decompose a task into multiple sub-goals.
    • How to perform calculations or verifications at intermediate steps.
    • How to detect and correct errors.
    • How to produce clear and concise final conclusions.
    • How to follow specified output formats and language requirements.

    Cold-start data offers the RL process a better initial policy. If the model can already generate structurally reasonable reasoning results from the start, subsequent reward signals are easier to exploit, and training is generally more stable.

    It is important to note that supervised data should not pursue “correct answers” alone. If examples contain excessively verbose thinking, irrelevant repetition, or unnecessary self-dialogue, the model may absorb these inefficient patterns. Data construction should therefore balance correctness, readability, conciseness, and verifiability.

    V. Fundamental Principles of Group Relative Policy Optimization

    A widely adopted approach for reasoning model training is group relative policy optimization (GRPO). One key distinction from traditional policy optimization methods is that GRPO avoids training a separate value model comparable in scale to the policy model. Instead, it estimates advantages using relative rewards among multiple candidate answers to the same question.

    Let the input question be (q), and suppose the model generates a group of answers for this question:

    [
    {o_1,o_2,\ldots,o_G}
    ]

    A reward function computes a reward for each answer:

    [
    {r_1,r_2,\ldots,r_G}
    ]

    The system then calculates the mean reward and the spread across the group, converting each answer’s reward into a relative advantage. A typical formulation is:

    [
    A_i=\frac{r_i-\mathrm{mean}(r)}{\mathrm{std}(r)+\epsilon}
    ]

    Here, (A_i) represents the advantage of the (i)-th output relative to other outputs in the same group, and (\epsilon) prevents numerical issues when the standard deviation is zero.

    If an answer’s reward is above the group average, the model increases the probability of producing that type of answer. If the reward is below the average, the probability decreases. This approach does not require accurately predicting the cumulative reward obtainable from each state in the future; it directly compares the quality of candidate outputs for the same problem.

    VI. Differences from Traditional Policy Optimization

    Traditional policy optimization typically relies on a value network to estimate the expected cumulative return for the current state. This value network is often large, consuming additional memory, computation, and training effort.

    GRPO eliminates the separate value model, yielding several benefits:

    1. Lower resource consumption
      Without a critic model of similar scale, memory pressure during training is reduced.

    2. Fewer value estimation errors
      When rewards are primarily given at the end of a task, a value model struggles to accurately estimate the long-term value of intermediate states. Group-relative comparisons sidestep some of these difficulties.

    3. Well suited to verifiable tasks
      For mathematics and code problems, as long as the final answer can be validated, group-relative optimization can be applied directly.

    4. Natural support for multi-candidate exploration
      Generating multiple answers for the same question provides inherent exploration space and supports discovering diverse solution paths.

    However, this method is not without issues. If all answers in a group are correct or all are incorrect, the reward differences are minimal, and the advantage signal weakens. Problem difficulty, sampling temperature, candidate count, and reward distribution therefore all affect training efficiency.

    VII. Reward Functions Must Go Beyond the Final Answer

    A reliable reasoning training system usually combines multiple reward signals rather than relying on a single correctness-based reward.

    1. Outcome Correctness Reward

    This is the most important reward type, used to evaluate whether the final answer is correct. For problems with well-defined answers, matching can be done through exact string matching, numerical equivalence checks, or program execution.

    2. Format Reward

    A model may reach the correct conclusion but fail to produce output as specified—missing required fields, including extra content, or generating code that cannot be parsed. Format rewards encourage stable, structured output.

    3. Language Consistency Reward

    When training targets a specific language user base, the model should avoid switching languages mid-answer. Language consistency rewards improve readability and overall user experience.

    4. Length and Efficiency Constraints

    Longer reasoning does not always mean better. Excessive length may include repeated calculations, ineffective reflections, or circular arguments. A moderate penalty can be applied to clearly redundant outputs, but the model should not be encouraged to shorten indiscriminately, as this may harm performance on complex problems.

    5. Safety and Compliance Constraints

    For open-ended tasks, additional mechanisms are required for safety rules, privacy protection, and filtering of risky content. Full-scenario training should not optimize only for “whether the answer is correct,” but also for “whether the answer is appropriate to give” and “whether it is expressed appropriately.”

    VIII. How Rejection Sampling Feeds Back into Supervised Training

    Among the candidate answers generated during RL, a subset is typically of high quality. The training system can select reliable samples through rule-based filtering, model-based scoring, and manual spot checks, turning them into new supervised fine-tuning data.

    This process is commonly called rejection sampling. Its basic workflow is as follows:

    1. Generate multiple candidate answers for a large set of questions.
    2. Use an answer validator to filter out clearly incorrect results.
    3. Use a quality evaluator to assess the reasoning process and expression.
    4. Remove duplicates, overly long outputs, format anomalies, and risky samples.
    5. Add the remaining samples to the supervised training set.
    6. Retrain the model to make high-quality candidate generation more likely.

    The value of rejection sampling lies in converting effective behaviors discovered during RL into more stable supervised signals. Compared with sparse rewards, supervised training can more efficiently learn complete input-to-output mappings.

    However, the filtering process must guard against “reward hacking.” If the evaluator only checks the final answer, the model might learn superficially plausible but logically unsound expressions. The filtering system should therefore combine outcome validation, process inspection, repeated testing, and cross-evaluation from multiple evaluators.

    IX. Second-Stage Supervised Training and Full-Scenario RL

    After the first round of reasoning RL and rejection sampling, a model typically demonstrates stronger performance on verifiable tasks such as mathematics and code. The next step is to introduce broader data covering knowledge QA, writing, instruction following, multi-turn dialogue, and safety responses.

    The goal here is to avoid creating a model that is strong at problem-solving but poor at normal conversation. For example, a highly capable reasoning model that responds to a simple question with lengthy derivations, or that continues internal reasoning when no complex analysis is required, will degrade user experience.

    Second-stage full-scenario RL needs to consider:

    • Factual accuracy;
    • Instruction following;
    • Completeness of answers;
    • Naturalness of expression;
    • Reasonableness of reasoning length;
    • Caution when handling uncertain information;
    • Safety boundaries and quality of refusals.

    At this stage, reward models cannot rely solely on automatic judgment. For open-ended QA and writing tasks, rule-based evaluation, model-based evaluation, and human sampling are typically combined to reduce bias from a single evaluator.

    X. Common Issues in the Training Process

    1. Reward Hacking

    The model may find shortcut ways to obtain high rewards—repeating keywords, applying a fixed template, or exploiting evaluator loopholes—rather than genuinely solving the problem. Mitigation includes diversified test sets, hidden evaluation sets, and independent validators.

    2. Reasoning Length Explosion

    When training over-rewards detailed derivations, the model may produce extremely long responses. Correctness and efficiency should be evaluated together, with detection mechanisms for repetitive content.

    3. Language Mixing

    Multilingual training data combined with a single outcome-based reward may lead to language mixing. Language consistency constraints should be added, and training data should explicitly demonstrate the target language.

    4. Imbalanced Capability Distribution

    The model may grow stronger on mathematical tasks while degrading on common-sense QA, dialogue, or writing. Training batches must maintain task diversity, and different capability dimensions should be monitored continuously.

    5. Over-Reliance on Automatic Evaluation

    Automatic evaluators are suitable for tasks with clear rules but struggle to assess argument quality, naturalness of expression, or complex factual accuracy. High-risk scenarios still require human review and independent evaluation.

    XI. How to Evaluate a Reasoning Model Training Pipeline

    Evaluating a reasoning model should not rely on a single benchmark or a few sample cases. A multi-dimensional framework is necessary:

    • Task accuracy: Final results across mathematics, code, logic, and knowledge tasks.
    • Reasoning stability: Whether answers remain consistent across multiple sampling runs.
    • Generalization ability: Whether the model can handle unseen problem types and alternative phrasings.
    • Efficiency metrics: Output length and computation required to reach a correct answer.
    • Instruction following: Whether format, language, and style requirements are respected.
    • Robustness: Whether the model can recognize noise, ambiguity, and false premises.
    • Safety: Whether the model can appropriately refuse risky requests or provide safe alternatives.
    • Maintainability: Whether the training pipeline scales to new tasks and closes evaluator gaps.

    Overall, the capabilities of a reasoning LLM do not come solely from a larger parameter count. They arise from the coordination of the foundation model, data construction, reward design, candidate sampling, and multi-stage training. GRPO lowers the resource barrier for RL, but what ultimately determines the outcome is whether the problem distribution is well designed, reward signals are reliable, and the training system can continuously identify and correct reward hacking behavior. For engineers and organizations, understanding this complete training loop holds greater long-term value than focusing on any single model name or metric.