Reinforcement Learning Training and Implementation Practices for Reasoning LLMs
This article explores methodologies for training and deploying reasoning-focused large language models (LLMs). It covers supervised fine-tuning, test-time compute expansion, and reinforcement learning (RL) with verifiable rewards. Additionally, it details knowledge distillation from large to small models, engineering considerations for open-source weights, evaluation design, cost control, and practical implementation steps for production environments.
1. Why Reasoning Capability is a Core Metric for LLMs
Mathematical problem solving, code generation, and multi-step logical judgment all require the model to break down a problem into several intermediate steps and then reach a conclusion step by step. These tasks share three common characteristics. First, the final answer can usually be objectively verified. Second, there are numerous intermediate steps, and an error in any step will propagate down the chain. Third, there are multiple reasonable solving paths for the same problem.
Relying solely on next-token prediction during the pre-training phase leads to unstable performance on these tasks. If the same problem is phrased differently, the result might be entirely different. Therefore, the industry has gradually developed training methods that treat “reasoning capability” as an independent objective.
1.1 Three Common Enhancement Methods in the Industry
Currently, there are three common approaches to improving reasoning capabilities:
- Supervised Fine-Tuning (SFT) with High-Quality Reasoning Data: Using manually written or filtered problem-solving processes to train the model, enabling it to learn standardized reasoning formats.
- Test-Time Compute Expansion: Sampling multiple reasoning paths for the same problem and selecting the optimal answer through voting or scoring. This method increases inference costs but does not require modifying model parameters.
- Reinforcement Learning (RL) Optimization: Allowing the model to generate answers autonomously and adjusting its strategy based on reward signals to gradually reinforce behavior patterns that yield correct results.
These three methods are not mutually exclusive. In practice, it is common to use SFT data to establish a foundational format first, followed by RL to expand the capability boundaries.
2. Reinforcement Learning Based on Verifiable Rewards
2.1 Basic Training Loop
RL training can be summarized as a loop: the model generates multiple candidate responses for a batch of questions; the reward function scores each response; the training algorithm updates the model parameters based on the score differences, increasing the generation probability of high-scoring responses.
The effectiveness of this loop depends on the quality of the reward function. If the signal provided by the reward function is inaccurate, the model will learn incorrect behaviors or even learn to “game the system,” such as generating beautifully formatted but factually incorrect responses.
2.2 Three Designs for Reward Signals
Outcome Reward: Only checks whether the final answer is correct. Math problems can be compared against a standard answer, and coding problems can be verified using test cases. This method is simple to implement and provides clear signals, making it the most commonly used reward format for verifiable tasks.
Process Reward: Scores each intermediate step of the reasoning process. It provides finer feedback, but annotation costs are high. Furthermore, the scoring model itself may make mistakes and can be exploited by the target model.
Format Reward: Constrains the output structure, for example, requiring the reasoning content and the final answer to be placed in designated tags. Once the format is unified, answers are easier to parse programmatically, and outcome rewards are simpler to calculate.
In practice, combining outcome rewards with format rewards is a relatively stable approach. Process rewards are suitable as supplementary signals introduced after outcome rewards have stabilized.
2.3 The Role of Small-Scale Cold Start Data
Starting large-scale RL directly from a base model often results in three issues: mixed languages in the output, large sections of repetition in the responses, and random variations in the reasoning format, leading to unstable reward signals.
Therefore, a common practice is to perform a cold start using a small amount of annotated data. This dataset does not need to be large, but it should cover typical question types of the target task and unify the output format. After the cold start, the model’s output becomes more readable, and the exploration space for RL is more concentrated.
2.4 Illustration: Rule-Based Rewards and Group-Relative Advantage
The following pseudocode demonstrates the basic logic of reward calculation. The weights are illustrative values and need to be adjusted according to the task.
function compute_reward(response, reference):answer = extract_final_answer(response) # Extract final answer from tagsformat_ok = contains_required_tags(response) # Check if format is compliantaccuracy = 1 if normalize(answer) == normalize(reference) else 0return 0.8 * accuracy + 0.2 * (1 if format_ok else 0)function group_advantage(rewards):# For multiple responses to the same question, calculate the advantage relative to the group meanmean = average(rewards)std = standard_deviation(rewards) + epsilonreturn [(r - mean) / std for r in rewards]
The benefit of group-relative advantage is that it allows better-performing responses to the same question to receive positive updates without needing to train a separate value model. epsilon is a small constant to prevent division by zero.
3. From Large to Small Models: Knowledge Distillation
Large models achieve good reasoning results but have high deployment costs. The idea of knowledge distillation is to have a large model (teacher) generate reasoning processes, and then use this data to train a small model (student), allowing the student to learn similar problem-solving patterns.
3.1 Distillation Data Construction Process
The quality of distillation data directly determines the upper limit of the student model. The following steps are recommended:
- Collect a question set covering the target scenarios, removing duplicates from the evaluation set.
- Use the teacher model to generate multiple reasoning processes for each question.
- Use verifiable rules to check the final answers, discarding incorrect samples.
- Check the format and language consistency of the reasoning process, filtering out obviously anomalous text.
- Deduplicate the remaining samples and control the proportion of each question type.
dataset = []for question, reference in problem_set:traces = teacher.generate(question, n=4)for trace in traces:if compute_reward(trace, reference) >= 0.8: # Keep only correct and format-compliant samplesdataset.append((question, trace))dataset = deduplicate(dataset)student = fine_tune(base_small_model, dataset)
3.2 Benefits and Limitations of Distillation
The primary benefit of distillation is cost. Small models have lower inference latency and consume fewer resources per call, making them suitable for high-concurrency or edge scenarios.
The limitations are equally clear. Small models have limited capacity and are usually weaker on highly difficult problems compared to large models directly trained with RL. Distillation effectiveness depends on data quality; if the teacher model makes many errors on a certain type of question, the student model will inherit these errors. Therefore, after distillation, separate evaluation on the target task is required, rather than solely looking at general benchmark scores.
4. Engineering Considerations for Open-Source Weights
Releasing model weights allows teams to deploy, fine-tune, and audit models in their own environments. This lowers the barrier to trial and error but also imposes higher requirements on engineering capabilities.
4.1 Licensing
Permissive open-source licenses usually allow commercial use, modification, and redistribution, but the specific terms vary. Before going live, you should read the license text to confirm requirements regarding attribution, copyright notice retention, and derivative works. Do not make assumptions based solely on the word “open source.”
4.2 VRAM and Cost Estimation
The primary constraint for model deployment is VRAM. Weight usage can be roughly estimated using “parameter count × bytes per parameter”:
| Precision | Bytes per Parameter | Approx. Weight Usage for a 7B Model |
|---|---|---|
| FP16 | 2 | ~14 GB |
| INT8 | 1 | ~7 GB |
| INT4 | 0.5 | ~3.5 GB |
Additionally, space must be reserved for the KV cache and intermediate activations. The KV cache grows with context length and concurrency. Reasoning models generate longer outputs, so the context budget and concurrency limits must be determined through stress testing, not just estimated based on the weight size.
4.3 Common Trade-offs in Fine-Tuning and Deployment
- Full Fine-Tuning: High upper limit for performance, but VRAM and training costs are significant.
- Parameter-Efficient Fine-Tuning (PEFT): Updates only a small number of parameters, suitable for resource-limited teams, but more sensitive to data quality.
- Quantized Deployment: Significantly reduces resource usage, but requires verifying precision loss on the target task.
5. Evaluation, Cost, and Risk Control
5.1 Evaluation Design
Public benchmarks only reflect general capabilities. Before deployment, an evaluation set consistent with the business should be established, adhering to a few principles: evaluation questions must not enter the training data; accuracy, average output length, and latency should be reported simultaneously; for open-ended questions, combine manual review or rule checks to avoid relying solely on a single leaderboard.
5.2 Cost and Latency
Reasoning models tend to generate longer thought processes, which simultaneously increases latency and cost. You should set a maximum output length, use lighter reasoning strategies for simple questions, and record the average token consumption for each type of request as a basis for capacity planning.
5.3 Output Reliability
A reasoning process does not equate to a correct conclusion, and intermediate steps may also be wrong. For numerical calculations, code execution, and factual queries, deterministic tools should be integrated for verification, rather than directly trusting the model output. Whether to display the full reasoning process to end users should be decided jointly by the product and compliance teams.
6. Recommended Implementation Steps
- Determine Task Type: Confirm whether the target problem has a verifiable answer. If the answer cannot be objectively judged, the benefits of RL will significantly decrease.
- Establish a Baseline: Use existing models to measure accuracy and cost on the evaluation set as a benchmark for future comparisons.
- Small-Scale Pilot: Select a high-value question type, complete data construction, reward design, and one round of training to verify if the benefits hold true.
- Gradual Expansion: After the pilot proves effective, expand the coverage of question types and simultaneously build monitoring to track changes in quality, latency, and cost.
- Continuous Iteration: Regularly update the evaluation set with new data to prevent the model from overfitting on old questions, and adjust reward design based on production feedback.
Improving reasoning capability relies on the coordination of reward design, data quality, and engineering constraints. Teams should start with verifiable tasks and advance progressively using quantifiable metrics, rather than pursuing a one-time comprehensive upgrade.
