Post-Training on the Same Base Model: How Much Can a Code Model Improve?
This article provides a practical framework for evaluating how much post-training and reinforcement learning can improve a code model when the base model stays fixed. It covers a total-cost formula that accounts for inference, the trade-offs between dense and mixture-of-experts architectures, a controlled experiment design with a recording template, common pitfalls such as benchmark contamination, a Python example for detecting data overlap, and a decision checklist for choosing between deeper post-training and a new pretraining run.
1. A Decision Framework First
Evaluating the value of post-training on the same base model can be broken into four steps. First, use a total-cost formula to estimate the long-term expense of each path. Second, run controlled experiments to measure the real gains from post-training. Third, check whether the evaluation set is contaminated by training data, so memorization is not mistaken for capability. Fourth, combine the data recipe, inference cost, and chain-of-thought length to decide where the next iteration should focus.
The sections below follow these four steps.
2. Where the Question Comes From
Rankings among code models shift quickly. Between two models in the same generation, benchmark scores may differ by only a few percentage points, while the underlying technical approaches differ substantially. A question worth asking is: if the base model stays fixed and only post-training and reinforcement learning are pushed further, how far can capability go?
This question directly shapes resource allocation. Teams must decide whether to invest in a new pretraining run or deepen the post-training pipeline on the existing base. The two paths differ in cost structure, iteration cycle, and risk, so the real gains from post-training need to be understood first.
This article does not discuss the ranking or evaluation results of any specific model. Instead, it breaks the question into several independently verifiable technical sub-questions and explains the basis for each judgment.
3. Parameter Count Is Not the Only Variable
In some public practices, teams scale models up while keeping training data relatively insufficient, optimizing mainly for training cost. This keeps the账面 training expense low, but it tends to overlook two things.
First, parameter count and data volume need to match. When parameters are abundant but training data is scarce, model capacity cannot be fully utilized, and the returns from adding more parameters diminish.
Second, a deployed model serves traffic over the long term, and inference cost accumulates continuously. For high-volume services, inference expense can exceed training expense.
Therefore, the economics of a model should be evaluated by total cost, not training cost alone:
Total cost ≈ training cost + per-request inference cost × expected request volume
Here is a hypothetical example. Suppose the per-request inference cost is 0.002 yuan and the service handles 1 million requests per day. Annual inference cost would be roughly 0.002 × 1,000,000 × 365 = 730,000 yuan. If the compute per request doubles, annual inference cost grows by about 730,000 yuan. Whether this increment exceeds the cost of a full training run depends on each team’s own measurements. Teams should plug in real billing data and training records rather than reuse the example numbers directly.
4. Dense Models vs. Mixture-of-Experts Models
When choosing a model architecture, two kinds of parameters must be distinguished. The table below summarizes the main differences.
| Dimension | Dense Model | Mixture-of-Experts Model |
|---|---|---|
| Activated parameters per forward pass | All parameters | Only a subset of experts per token |
| Memory footprint | Determined mainly by parameter count | Determined mainly by total parameters; all experts must reside in memory |
| Compute per token | Roughly proportional to parameter count | Related to activated parameters |
| Inference path | Stable and fixed | Depends on routing; path varies with input |
| Engineering complexity | Relatively simple | Requires expert parallelism and load balancing |
| Typical risks | Inference cost rises quickly as parameters grow | Routing failures, uneven expert load |
When comparing the two architectures, total parameter count alone is not enough. Total parameters mainly affect memory footprint, which is also influenced by activations, KV cache, parallelism strategy, and deployment precision (such as FP16 or INT8). A mixture-of-experts model with more total parameters can have lower per-request inference cost than a smaller dense model. This holds only if the routing mechanism works well, memory resources are sufficient, and the parallelism strategy matches the hardware. When routing is unevenly distributed, some experts become overloaded, throughput drops, and results can become unstable.
5. How to Design Same-Base Post-Training Experiments
To judge the true contribution of post-training, experiments must control variables. A sound design includes the following:
- Fix the base weights and model architecture.
- Fix the total and activated parameter counts.
- Change only the post-training data recipe, training duration, and number of reinforcement learning rounds.
- Use the same evaluation set, and keep results broken down by task type and difficulty.
This design answers a clear question: without any new pretraining, how much gain can post-training deliver? If gains concentrate in a particular task type, post-training is having a stronger effect on that capability.
Every experiment should fill in the same record table to enable horizontal comparison.
| Field | Description |
|---|---|
| Experiment ID and base version | Record the weight hash or version number to ensure base consistency |
| Total / activated parameters | Keep consistent with the base |
| Data recipe version | Record data sources, cleaning rules, and mixture ratios |
| RL rounds and training duration | Record steps per round and total elapsed time |
| Scores by task type | Track function implementation, debugging/repair, code completion, etc. separately |
| Scores by difficulty | Stratify by difficulty to see whether gains concentrate on hard problems |
| Contamination rate | Share of evaluation items flagged by contamination detection |
| Per-request inference cost | Measured in the actual deployment environment, including token count and latency |
| Conclusion and next action | State whether the gains are credible and what to do next |
Common Pitfalls
Three pitfalls appear frequently in such experiments.
- Evaluation set leakage. When post-training data overlaps heavily with evaluation items, improvements are overestimated. Deduplication and contamination checks should be done before training.
- Metric saturation. When most models approach full marks on a benchmark, its discriminative power declines. Add difficulty tiers or introduce newer problems.
- Anecdotal bias. Subjective impressions on a handful of tasks are only clues; they cannot replace systematic evaluation.
Contamination Detection Example
Below is a rough contamination detection example. It uses character-level n-gram Jaccard similarity to flag suspicious samples.
def ngrams(text, n=8):"""Strip whitespace, then generate the set of character-level n-grams of length n.If the text is shorter than n, return the whole text as the only element."""text = "".join(text.split())if len(text) < n:return {text} if text else set()return {text[i:i + n] for i in range(len(text) - n + 1)}def jaccard(a, b):"""Compute the Jaccard similarity of two sets; the result ranges from 0 to 1."""if not a or not b:return 0.0return len(a & b) / len(a | b)def dedup_check(train_items, eval_items, n=8, threshold=0.9):"""Detect overlap between the training set and the evaluation set.train_items and eval_items: lists of dicts, each with "id" and "prompt" fields.Returns (flagged, overlap_rate):flagged is a list of suspicious (eval item, train sample, similarity) records;overlap_rate is the share of evaluation items with at least one suspicious match."""train_grams = [(tr["id"], ngrams(tr["prompt"], n)) for tr in train_items]flagged = []flagged_eval_ids = set()for ev in eval_items:ev_grams = ngrams(ev["prompt"], n)for tr_id, tr_grams in train_grams:score = jaccard(ev_grams, tr_grams)if score >= threshold:flagged.append({"eval_id": ev["id"],"train_id": tr_id,"score": round(score, 3),})flagged_eval_ids.add(ev["id"])overlap_rate = len(flagged_eval_ids) / len(eval_items) if eval_items else 0.0return flagged, overlap_rate
Keep the following in mind when using it.
- This example only illustrates the idea. The nested loop grows quadratically with data size; for large datasets, switch to approximate methods such as MinHash or SimHash, or use mature deduplication tools.
- The 0.9 threshold is only a starting point. Teams should calibrate the threshold on manually labeled samples before deciding which samples to remove.
- Detection results are only candidates. Flagged samples need manual review before any action, to avoid deleting legitimate training data by mistake.
- The usual handling is to remove confirmed overlapping evaluation items or training samples, then rerun the evaluation and compare the difference.
6. Chain-of-Thought Length Is Not the Only Path
A common assumption is that longer chains of thought make a model better at code. This holds for some tasks, but it is not the only path.
Longer chains of thought increase token count and latency per request, pushing inference cost up. Teams should treat chain-of-thought length as a cost item, not just an accuracy lever. On some code tasks, short chains of thought combined with test feedback over multiple correction rounds can also achieve good results. Therefore, when comparing the two approaches, compare effectiveness under the same cost budget rather than comparing accuracy alone.
7. The Executable Environment Sets the Ceiling
Code problems have a unique advantage: answers can usually be executed and verified. Whether unit tests pass provides a reliable reward signal, allowing reinforcement learning to iterate on large volumes of automatically generated feedback.
The quality of the environment is therefore critical. Focus on the following aspects.
- Test case coverage. With too few cases, the model may learn to pass the samples without solving the real problem.
- Sandbox stability. Execution timeouts, missing dependencies, or non-reproducible results all pollute the reward signal.
- Consistency between problems and tests. When the problem statement and the tests do not match, training optimizes in the wrong direction.
In vertical security domains, similar executable environments can support tasks such as vulnerability repair and security rule checking. Such applications must stay within authorized scope, and both sample sources and test content require compliance review.
8. Conclusion and Decision Checklist
Back to the original question: on the same base, how much can post-training and reinforcement learning alone improve a code model? The answer depends on whether the experiment design is rigorous, not on any fixed number. Teams can use the checklist below to decide the direction of each iteration.
- Parameter scale: Do activated parameters match the data volume? Are the returns from adding parameters still increasing?
- Data recipe: Has post-training data been deduplicated and checked for contamination? Do gains concentrate in specific task types?
- Inference cost: What share of the total-cost formula does inference account for? Does the architecture choice account for routing risk?
- Chain-of-thought length: Does longer reasoning deliver enough gain to cover the added cost?
- Executable environment: Is test coverage sufficient? Is the sandbox stable? Are problems and tests consistent?
If most checklist items indicate that post-training still has headroom, deepening work on the existing base is likely the better investment. If gains clearly narrow after multiple rounds of experiments, it is time to evaluate the cost and benefit of a new pretraining run. Both judgments should rest on measured data, not on impressions from a single evaluation.
