How Reinforcement Learning Post-Training Breaks Past Coding Baselines

    This article examines why reinforcement learning (RL) post-training can push a specialized model well beyond its base model on coding evaluations, while sometimes regressing on engineering and UI tasks. It breaks "coding ability" into trainable sub-skills, then explains two core mechanisms: verifiable rewards as a hard constraint, and training stability with the exploration-exploitation balance. Includes illustrative pseudocode for reward shaping and a training loop.

    1. The Phenomenon: Why “Post-Trained Model Beats Its Base” Deserves Study

    In real model iteration, a counterintuitive result often appears: a specialized version produced by reinforcement learning post-training on a previous-generation base model can score significantly higher on coding evaluations than its “teacher,” sometimes by a multiple. The case described here fits this pattern: a post-trained version is clearly stronger than its base model in the algorithmic dimension, yet shows relative regression on tasks that lean toward engineering and interface implementation.

    To understand this, we need to abstract the conclusion from “a certain model is stronger” into a general proposition: post-training does not improve all capabilities uniformly; it amplifies the part of the training distribution that is explicitly rewarded. Reinforcement learning does not make a model globally “smarter”; it reallocates probability mass toward high-return behavior patterns. As a result, the same post-training recipe will produce a mix of gains and regressions across different task families. This is a property of the method, not an anomaly.

    2. Capability Breakdown: Splitting “Coding Ability” into Trainable Sub-Skills

    Before discussing benchmark scores, we need to break down what “coding” actually includes in terms of independently optimizable capabilities:

    • Problem formalization: Turning natural-language requirements into formal descriptions with clear boundary conditions.
    • Algorithmic reasoning: Selecting the correct paradigm (dynamic programming, greedy, graph theory, number theory, etc.) under given constraints and deriving complexity.
    • Long-chain execution: Multi-file changes, interface integration, style and interaction regression, all requiring long-range consistency.
    • Self-verification: Proactively constructing boundary cases, finding flaws in one’s own reasoning, and retrying with backtracking.

    RL post-training delivers the largest gains on the second and fourth items, because they have automatically判定 correctness signals; it delivers the smallest gains on the third, because “whether the interface is reasonable and the interaction is smooth” is hard to score programmatically. This explains why algorithmic evaluations improve markedly while front-end tasks may regress relatively—training concentrates the model’s “exploration budget” on verifiable reasoning chains.

    3. Core Mechanism One: Verifiable Rewards Are a Hard Constraint for Post-Training

    The first determining factor in whether post-training works is whether the reward can be judged programmatically. Common industry practices include:

    1. Unit tests and hidden cases: Use pass rate as the main reward, with timeout and memory-limit penalties for “brute-force” solutions.
    2. Static checks and complexity constraints: Deduct points for static-scan warnings, dependency violations, and complexity over threshold.
    3. Process rewards: Give local feedback on intermediate reasoning steps to ease exploration under sparse rewards.

    An illustrative way to organize the reward (pseudocode, expressing only the general idea):

    1. def reward(sample, tests):
    2. passed, total = run_tests(sample, tests) # verifiable main signal
    3. r = passed / max(total, 1)
    4. if timeout_or_oom(sample):
    5. r -= 0.5 # resource violation penalty
    6. r -= 0.1 * lint_violations(sample) # style/convention deduction
    7. return clamp(r, -1.0, 1.0)

    The key is that the reward must be hard to “game.” If pass rate is the only criterion, the model will tend to write special-case solutions that target the visible samples. Therefore, the proportion of hidden cases, randomized inputs, and boundary-case coverage are necessary conditions for keeping the reward trustworthy.

    4. Core Mechanism Two: Training Stability and the Exploration-Exploitation Balance

    A common reason post-training fails is not insufficient capability but a collapse of the training process. Engineering practice usually requires controlling the following variables:

    • Variance of advantage estimation: Using a group-relative baseline (sampling multiple responses under the same prompt for relative comparison) can significantly reduce variance and avoid oscillation caused by drift in absolute reward values.
    • Policy-shift constraint: Apply a divergence penalty against the reference policy to prevent the model from losing general language ability while chasing reward.
    • Sampling temperature and diversity: Too low a temperature leads to insufficient exploration; too high amplifies reward noise, so it needs to be annealed as training progresses.
    • Curriculum difficulty scheduling: Bucket by pass rate and concentrate training samples at the “edge of current capability.” Too-easy samples contribute almost no gradient, while too-hard samples produce very noisy gradients.

    A simplified training-loop skeleton is as follows:

    1. for batch in curriculum(by_pass_rate=0.2):
    2. group = [policy.sample(q, n=8) for q in batch]
    3. adv = group_relative_advantage(group) # group-relative advantage
    4. loss = policy_loss(group, adv) + beta * kl(policy, ref_policy)
    5. optimizer.step(clip_grad(loss))

    Here, the tuning of beta