Evaluating Post-Training Capability and Stability of Code-Generating LLMs
How do you fairly evaluate a coding LLM beyond a few impressive demos? This article presents a practical framework for assessing post-trained code models, covering functional correctness, instruction following, code quality, long-context understanding, and iterative repair. It explains how to build reliable evaluation sets, quantify stability through multi-sample consistency and perturbation robustness, understand reinforcement learning post-training practices such as executable rewards and rejection sampling, and avoid common evaluation pitfalls. Includes runnable Python code for computing pass@k and consistency metrics, plus concrete steps for teams adopting these evaluations internally.
Why “How to Evaluate” Is a Hard Question
Judging whether a model is good at coding tasks often stays at the level of impressions. Someone uses it to build a neat little tool and concludes it is powerful; someone else hits a single failure and concludes it is unusable. Both judgments come from individual samples and say little about how the model performs in real workflows.
Coding tasks have another characteristic: the same problem admits many valid solutions, and correctness must be verified by execution rather than by eyeballing the code. A snippet that looks reasonable may crash under edge conditions; a snippet that runs may contain security flaws or unmaintainable structure. Evaluating coding capability therefore requires considering functional correctness, stability, code quality, and engineering usability together.
This article presents a general methodology applicable to any code-generating LLM. It does not draw conclusions about any specific product.
Key Concepts
Before diving into evaluation, let’s align on terminology.
Pre-training is the phase where the model learns statistical patterns of language and code from massive corpora, forming its knowledge base.
Post-training refers to the series of adjustments applied after pre-training, commonly including instruction fine-tuning, preference alignment, and reinforcement learning-based optimization. For coding, the goal of post-training is typically to help the model better understand requirements, follow constraints, generate executable code, and stay consistent across multi-turn interactions.
Reinforcement learning pipeline refers to the complete process of guiding the model’s generation strategy with a reward signal, including reward design, sampling strategies, data filtering, and iterative updates. Coding has one advantage here: rewards can be automated. Whether generated code passes tests, compiles, or clears static checks can all be judged programmatically, without relying entirely on human annotation.
Stability refers to how consistent the model’s output quality is across similar inputs. For developers, stability often matters more than a single best-case score, because daily use involves repeatedly handling many similar tasks.
Core Dimensions of Coding Capability
When evaluating a coding model, examine the following dimensions individually before forming an overall judgment.
1. Functional Correctness
Functional correctness is the most fundamental metric, usually measured by whether generated code passes predefined tests. Test cases should cover normal inputs, boundary inputs, and exceptional inputs. A test suite that only covers normal inputs can hardly distinguish a model that truly understands requirements from one that has memorized common patterns.
2. Instruction Following
In real development, requirements come with constraints: a specified language version, a banned library, a required function signature, a time complexity limit. Whether the model strictly follows these constraints directly determines whether its output can enter the engineering workflow. When evaluating, design an independent check for each constraint and compute the per-constraint compliance rate.
3. Code Quality
Code that runs is not necessarily good code. Look for:
- Clear structure and single-responsibility functions;
- Sensible variable naming and comments;
- Obvious resource leaks, unhandled exceptions, or injection risks;
- Idiomatic usage of the target language.
Static analysis tools can partially automate quality checks, but experienced engineers should still review a sample.
4. Long-Context and Multi-File Understanding
Real projects span multiple files and long conversation histories. Evaluations should include tasks that require understanding interfaces across files, locating existing implementations, and modifying code locally without breaking other modules. Such tasks better reflect daily development and more readily expose weaknesses in context management.
5. Tool Use and Iterative Repair
In some workflows, the model must revise code based on test error messages, run it again, and repeat until it passes. This “execute, observe, repair” loop can be measured by multi-turn repair success rate. Fewer repair rounds and more precise per-round changes indicate better use of error information.
Building a Reliable Evaluation Set
The quality of your evaluation set determines how trustworthy your conclusions are. Keep the following in mind.
Cover real scenarios. Test problems should be abstracted from real development work: data cleaning scripts, API parameter validation, log parsing, simple concurrency tasks, unit test completion, and so on. Obscure algorithm puzzles can supplement the set but should not dominate it.
Layer the difficulty. Grade problems into difficulty tiers and observe how the model’s success rate decays across them. A stable model’s pass rate typically declines smoothly with difficulty; a cliff-like drop at medium difficulty often signals a gap in generalization.
Prevent data contamination. If evaluation problems already appear in training data, scores will be inflated. Common practices include using newly created problems written after the evaluation set was published, rewriting existing problems, and checking overlap between generated output and public corpora.
Keep hidden tests. Tests shown to the model should be separated from tests used for final scoring. Showing only part of the test suite reduces overfitting to test cases.
Record the full process. Save prompts, sampling parameters, generated outputs, execution logs, and failure reasons for every evaluation run, so results can be reviewed later.
Quantifying Stability
Stability is a key indicator of post-training quality, yet it is often overlooked. Here are three practical ways to measure it.
1. Consistency Across Multiple Samples per Problem
Sample each problem n times independently and record the number of passes c. A stable model either passes almost every time or fails almost every time; if pass counts are widely distributed in between, the model’s grasp of that problem is weak and results depend on randomness.
2. Variance Across Evaluation Rounds
Run the same evaluation suite repeatedly at different times or with different random seeds, and compute the standard deviation of overall pass rates across rounds. A smaller standard deviation means more reproducible results and more predictable model behavior.
3. Perturbation Robustness
Make light rewrites of problem descriptions—reordering conditions, renaming variables, adding irrelevant background text—and observe how pass rates change. If the model only handles the original wording and is sensitive to equivalent phrasing, its understanding is stuck at surface patterns.
Observations on Post-Training Reinforcement Pipelines
Post-training for coding shares some common practices. Understanding them helps you judge whether a model’s post-training is solid.
Executable rewards. Using “does the code pass the tests” as the reward signal is the most direct optimization approach for coding. Its strength is objective signal; its weakness is that when test coverage is incomplete, the model may learn to merely satisfy the tests rather than solve the real problem. Test suite quality therefore directly affects training quality.
Process rewards and format constraints. Beyond final results, intermediate steps can be rewarded: whether the code compiles, whether output formats follow conventions, whether repairs complete within a reasonable number of steps. Process rewards speed up learning, but poor design introduces bias.
Rejection sampling and iterative fine-tuning. A common approach: have the model generate multiple candidate solutions per problem, keep only the verified ones for the next round of fine-tuning, and iterate. The key lies in how strict the filtering criteria are and whether enough diversity is preserved. Without diversity, the model converges to a single style of solution and degrades on new problems.
Guarding against reward hacking. During optimization, models may find shortcuts: hardcoding expected test values, exploiting test framework quirks, or bypassing assertions. Mature training pipelines detect such behavior and exclude it from reward computation. Evaluators should watch for it during result review too.
From an external evaluation perspective, a model with a solid post-training pipeline typically shows: high pass rates on unseen problems, consistent results across repeated sampling, stable instruction compliance under constraints, and comprehensible repair directions when it fails. These behaviors say more than a single leaderboard score.
Metric Calculation Example
The following example shows how to compute pass@k and consistency metrics. The code relies only on the Python standard library and runs as-is.
from math import combfrom statistics import mean, pstdevdef pass_at_k(n: int, c: int, k: int) -> float:"""Given c passes out of n samples, estimate the probability thatat least one of any k draws passes. Uses the standard unbiasedestimator used across the industry."""if not 0 <= c <= n:raise ValueError("c must be between 0 and n")if k > n:raise ValueError("k cannot exceed n")if n - c < k:return 1.0return 1.0 - comb(n - c, k) / comb(n, k)def summarize(results: dict[str, list[bool]], k: int = 1) -> dict[str, float]:"""Keys of results are task IDs; values are lists of pass/fail per sample.Returns average pass@k and the consistency rate.Consistency means all samples for a task agree (all pass or all fail)."""per_task = [pass_at_k(len(o), sum(o), k) for o in results.values()]consistent = [all(o) or not any(o) for o in results.values()]return {f"pass@{k}": mean(per_task),"consistency_rate": sum(consistent) / len(consistent),}def round_stability(round_pass_rates: list[float]) -> dict[str, float]:"""Takes overall pass rates from multiple evaluation roundsand returns the mean and standard deviation.A smaller standard deviation means more reproducible results."""return {"mean": mean(round_pass_rates),"stdev": pstdev(round_pass_rates),}if __name__ == "__main__":# Sample data is for illustration only, not measured from any modelsample_results = {"task_001": [True, True, True, True, True],"task_002": [True, False, True, False, True],"task_003": [False, False, False, False, False],}print(summarize(sample_results, k=1))print(round_stability([0.62, 0.60, 0.64, 0.61]))
In the output, pass@1 reflects the average single-attempt pass probability, and consistency_rate reflects how stable results are at the task level. Used together, these two metrics are more informative than average pass rate alone. For example, two models with identical average pass rates will differ in predictability: the one with lower consistency will be harder to rely on in practice.
Common Pitfalls
Relying on a single demo. Demos are usually handpicked and don’t represent average performance. Evaluations should use large numbers of unselected samples.
Trusting leaderboard scores alone. Public leaderboards may suffer from data contamination and may diverge significantly from your business scenarios. Treat them as a reference, but judge models against your own evaluation set.
Ignoring failure modes. Not all failures are equal. A missing boundary check is one thing; introducing a security vulnerability or a silent data error is quite another. The latter costs far more. Classify and count failures separately during evaluation.
Ignoring cost and latency. Generation speed, per-call cost, and context length limits all affect real-world usability. Your evaluation report should cover these dimensions.
Confusing “works” with “works well.” Code that passes tests is not necessarily readable, maintainable, or easy to deploy. Evaluate code quality and team acceptance alongside correctness.
Practical Recommendations
If you need to evaluate coding models within your team, proceed as follows.
- Define your use cases. List your team’s five to ten most common development tasks and define success criteria for each.
- Build an internal evaluation set. Sample from historical tickets, code review records, and existing tests, add hidden tests, and update the set regularly.
- Set stability thresholds. For example, require a minimum consistency rate for certain task types, or require the standard deviation across evaluation rounds to stay below a threshold.
- Integrate with CI. Put evaluation scripts into your pipeline, run them automatically after every model version update or prompt change, and keep the result history.
- Keep human review. Audit automated results by sampling, focusing on code quality, security, and maintainability.
- Document your decisions. Whenever you select or switch models, save the evaluation data and conclusions for future reference.
With this approach, a team ends up with more than a single score—it gains a repeatable, verifiable basis for decision-making. Coding model capabilities evolve with each version, and a stable, reproducible evaluation process is the foundation for long-term judgment.
