Reinforcement Learning Post-Training: Technical Approaches to Improving LLM Reasoning

    This article explains how reinforcement learning after pretraining can improve the multi-step reasoning of large language models. It covers the training pipeline, reward function design, distillation into smaller models, evaluation methods, and cost control.

    1. Background: Why Reasoning Has Become a Key Metric

    Large language models are mature at tasks such as text generation, summarization, and question answering. However, their performance remains unstable on tasks that require multi-step deduction. Problems like mathematical proofs, complex logical judgments, and code debugging require the model to organize intermediate steps into a coherent chain of reasoning. An error at any step makes the final answer wrong. As a result, reasoning ability has become one of the core metrics for evaluating model quality, and it is among the capabilities that enterprises care about most when selecting and deploying models.

    Traditional approaches rely mainly on two methods. The first is supervised fine-tuning on large volumes of manually annotated reasoning processes. The second is improving capability through larger parameter counts and more pretraining data. The first is expensive to annotate, and annotators’ solution paths are not necessarily the best ones. The second yields diminishing returns, while training and inference costs keep rising.

    As a result, the industry has paid growing attention to the post-training stage, which is the phase after pretraining is complete. The central question is how to use less data and compute to teach a model to reason better.

    2. Core Idea: Learning Driven by Verifiable Rewards

    The key question in post-training is how the model judges whether its own answer is good. In open-ended writing, quality depends on human preference, which is hard to evaluate at scale. In math and coding problems, however, answers can usually be checked automatically by a program. For example, a system can check whether a numerical result matches the reference answer, whether code passes unit tests, or whether the output format follows the specification. These verifiable results can be converted directly into reward signals.

    The basic reinforcement learning process works as follows:

    1. The model generates several candidate answers to the same problem.
    2. An evaluation module scores each answer according to rules.
    3. A training algorithm adjusts the model parameters based on the scores, increasing the probability that high-scoring answers are produced.
    4. The process repeats until the policy converges or the budget limit is reached.

    The advantage of this approach is that it requires very little annotation. Only problems and reference answers are needed, and the model can explore solutions on its own through extensive sampling. However, little annotation does not mean data engineering is unnecessary. The difficulty distribution of problems, deduplication, and consistent answer formatting all directly affect training results.

    3. Training Pipeline Design

    A practical post-training pipeline usually includes four stages.

    3.1 Cold-Start Stage

    Reinforcement learning applied directly to a base model often produces problems such as disorganized output, mixed languages, overly long answers, or truncated responses. For this reason, most approaches first run supervised fine-tuning on a set of high-quality examples. This teaches the model a basic output structure, for example, presenting the reasoning process first and then wrapping the final answer in a fixed tag so that a program can parse it. The cold-start dataset does not need to be large. Its main purpose is to enforce format consistency and language consistency, not to cover every knowledge point.

    3.2 Reinforcement Learning Stage

    After the cold start, the model enters reinforcement learning driven mainly by verifiable rewards. Typical reward designs include the following:

    • Accuracy reward: a positive reward when the final answer is correct, and zero or a negative score when it is wrong.
    • Format reward: a bonus when the reasoning and the answer follow the agreed structure.
    • Language consistency reward: the answer must use the same language as the question, which avoids meaningless language mixing.

    The weights of each reward term should be determined through small-scale experiments. If the format reward weight is set too high, the model may learn only to look well-formatted, and its reasoning quality may not actually improve.

    3.3 Rejection Sampling and Retraining

    The model produced by reinforcement learning can sample answers to a large set of problems. The pipeline then keeps the reasoning traces that are correct and clearly written, and uses them as new supervised data for retraining. This preserves the solution strategies the reinforcement learning stage discovered. It also adds data for writing, question answering, and other non-reasoning tasks, which reduces the risk of capability regression on general tasks.

    3.4 General Alignment Stage

    Finally, one round of alignment with general preference data is needed to make the model’s safety, helpfulness, and communication style meet expectations. This stage should avoid over-optimizing a single metric. Otherwise, the model may perform well on math problems but become stiff or verbose in everyday conversation.

    4. Reward Function Implementation Example

    The code below shows the basic approach to checking math answers. It is intended only to illustrate the principle. A production system needs more complete parsing and error-handling logic.

    1. import re
    2. ANSWER_PATTERN = re.compile(r"<answer>(.*?)</answer>", re.S)
    3. def extract_answer(text: str) -> str | None:
    4. """Extract the answer span from model output. Return None if the output does not follow the format."""
    5. match = ANSWER_PATTERN.search(text)
    6. if not match:
    7. return None
    8. return match.group(1).strip()
    9. def normalize(value: str) -> str:
    10. """Remove whitespace and thousands separators to standardize numeric values for comparison."""
    11. return value.replace(",", "").replace(" ", "")
    12. def compute_reward(output: str, reference: str) -> float:
    13. """Compute the reward for one response: a format bonus, plus an accuracy bonus if the answer is correct."""
    14. reward = 0.0
    15. answer = extract_answer(output)
    16. if answer is None:
    17. return reward # Format error, no reward
    18. reward += 0.1 # Format reward
    19. if normalize(answer) == normalize(reference):
    20. reward += 1.0 # Accuracy reward
    21. return reward

    In real training, a function like this is combined with sampling, batching, and policy update modules. When designing rewards, two points matter. First, the rules should be as unambiguous as possible. Otherwise, the model will learn to exploit loopholes in the rules. Second, a parsing failure should not be treated as an ordinary negative signal. Doing so can misdirect training.

    5. Transferring Reasoning Ability to Smaller Models

    Large models have strong reasoning ability, but they are expensive to deploy. A common approach is to use a large model to generate high-quality reasoning traces, then distill those traces into a model with fewer parameters. The main steps of distillation are as follows:

    1. Build a diverse set of problems that covers different difficulty levels and problem types.
    2. Use the strong model to generate multiple reasoning processes for each problem, then filter out incorrect samples through rules or human review.
    3. Run supervised fine-tuning of the smaller model on the filtered data.
    4. Test the smaller model’s capability boundaries on an independent held-out evaluation set.

    Smaller models usually lag behind larger ones on complex multi-step reasoning. Distillation can narrow the gap but is unlikely to fully replace a larger model. When selecting a model for a business use case, teams should weigh task complexity, response latency, and cost together, rather than looking only at parameter count.

    6. Evaluation System Design

    Evaluation is the navigation tool for post-training. It is recommended to build an evaluation set across the following dimensions:

    • Mathematical reasoning: measure accuracy by problem type, such as algebra, geometry, and probability.
    • Code generation: use the unit test pass rate as the primary metric, and also record the proportions of timeouts and runtime errors.
    • Natural language inference: assess the ability to integrate evidence across multiple sentences and to make logical judgments.
    • General capability regression: check whether writing, summarization, and question answering have declined.
    • Safety and stability: track the proportions of refusals, harmful content, and format errors.

    The evaluation set must be strictly separated from the training data. Otherwise, data leakage will inflate the metrics. Each evaluation should use fixed decoding parameters and random seeds, or the results cannot be compared. Key conclusions should be verified across multiple runs, with both the mean and the range of variation reported. The simplified evaluation loop below illustrates the idea:

    1. def evaluate(model, dataset, reward_fn):
    2. scores = []
    3. for item in dataset:
    4. output = model.generate(item["prompt"], temperature=0.0) # Fixed decoding so results are reproducible
    5. scores.append(reward_fn(output, item["reference"]))
    6. return sum(scores) / len(scores)

    7. Engineering Deployment and Cost Control

    Most of the cost in post-training comes from sampling and evaluation. The following approaches can help control it:

    • Problem filtering: remove problems the model always answers correctly or always answers incorrectly, and keep problems of moderate difficulty to increase the information gained from each sampling run.
    • Staged validation: first run experiments on a small-scale dataset