Post-Training Optimization: Better Inference Cost-Efficiency Without Scaling Parameters
Post-training offers a way to improve model capability without increasing parameter counts or training compute. This article explains why post-training matters, how it complements pretraining, and practical paths for improving coding, long-horizon agent, and defensive security capabilities. It also covers how to quantify cost-efficiency using cost-per-success metrics, engineering techniques for reducing inference costs, and how to build a repeatable evaluation and deployment process.
1. Why Post-Training Deserves Attention
Over the past few years, the dominant approach to improving model capability has been scaling up parameters and training compute. This route works, but it is expensive. More parameters mean higher memory usage, latency, and per-call costs during inference, and businesses making large-scale calls quickly hit cost constraints.
The post-training stage offers an alternative path. Working on top of an existing base model, techniques such as supervised fine-tuning, preference optimization, and reinforcement learning based on execution outcomes can make the model better at specific types of tasks. With the base model’s parameters unchanged, post-training can still produce significant capability gains. This shows that improving model capability does not necessarily require scaling parameters or compute.
For developers, this insight has practical value. When selecting a model, you should look beyond benchmark scores and consider the cost per call at a given quality level, and how many real business tasks the model can actually complete.
2. Division of Labor: Base Model vs. Post-Training
Understanding the value of post-training starts with distinguishing the responsibilities of the two stages.
Pretraining teaches the model language patterns and general knowledge from massive amounts of text and code. This stage determines the upper bound of model capability, but it does not directly determine whether the model behaves according to user intent.
Post-training converts general capability into usable capability. Common techniques include:
- Supervised fine-tuning: Using high-quality instruction-response pairs to teach the model to follow formats and intent.
- Preference optimization: Ranking multiple responses to the same prompt so the model favors more helpful, more accurate outputs.
- Feedback-based reinforcement learning: Using automatically verifiable outcomes (such as whether code passes tests) as reward signals, letting the model learn complete problem-solving paths.
- Rejection sampling and data distillation: Filtering correct samples from large batches of model-generated candidates, then using them in the next training round.
A common trait across these methods: data quality matters more than data quantity. One verified, high-quality sample often improves model performance more than thousands of unfiltered ones.
3. Improvement Paths for Three Key Capabilities
3.1 Complex Coding Tasks
Coding tasks have a major advantage: results can be verified automatically. Whether code compiles, whether unit tests pass, and whether outputs match expectations can all be converted into objective reward signals.
When constructing training data, you can organize the workflow as follows:
- Collect problem descriptions, relevant code, and test cases from real projects;
- Have the model generate multiple candidate patches;
- Run tests in an isolated environment and keep only patches that pass all tests;
- Perform error analysis on failures, categorize error types, and add samples targeting weak areas.
The key to this workflow is separating “looks correct” from “is actually correct.” Relying solely on human judgment of code quality is costly and inconsistent.
3.2 Long-Horizon Tasks and Agent Capabilities
Long-horizon tasks require multi-step reasoning, multiple tool calls, and sustained state maintenance—for example, troubleshooting a fault across multiple services, or producing an analysis report that requires several rounds of retrieval.
The difficulty of these tasks lies not in single-step accuracy but in error accumulation. If each step succeeds with 95% probability, after 10 consecutive steps the overall success rate drops to roughly 60%. Post-training therefore needs to focus on:
- Task decomposition: Breaking goals into executable sub-steps with explicit dependencies;
- State tracking: Remembering completed operations and intermediate results across multi-turn interactions;
- Error recovery: After a step fails, analyzing the cause and adjusting strategy rather than repeating the same mistake;
- Termination judgment: Knowing when a task is done, avoiding wasteful loops that burn resources.
Training data can come from complete task trajectories, including each action, tool return values, and final conclusions. Keeping only successful trajectories helps the model learn more stable execution patterns.
3.3 Defensive Security Tasks
Model applications in security require special caution. This article covers defensive scenarios only, such as code security audits, configuration risk checks, anomaly detection in logs, and writing and interpreting security policy documents.
In these scenarios, the model must satisfy two requirements simultaneously: accurately identifying risks and proposing fixes, while not outputting operational details that could be directly used for attacks. Post-training can handle this balance through:
- Labeling training samples from a defensive perspective, making the corresponding remediation explicit for each recommendation;
- Setting clear refusal boundaries and offering alternatives for requests beyond authorized scope;
- Regularly testing model behavior on edge cases with red-team test sets.
Evaluating security capability should not stop at pass rates—you must also check false positive and false negative rates. False positives increase manual review costs; false negatives can cause real losses.
4. Balancing Intelligence and Cost: How to Quantify It
When evaluating whether a model is “worth it,” the key metric is not the price per call but the average cost per successful task. The reason is simple: a cheap model with a low success rate requires multiple retries, and total cost may end up higher.
Cost per success can be estimated with:
cost_per_success = cost_per_call / task_success_ratecost_per_call = input_tokens × input_price + output_tokens × output_price
Here is a worked example:
def cost_per_success(price_in, price_out, tokens_in, tokens_out, success_rate):"""Compute the average cost per successful task."""if success_rate <= 0:raise ValueError("success_rate must be greater than 0")per_call = tokens_in * price_in + tokens_out * price_outreturn per_call / success_rate# The following values are for illustration only and do not# represent any actual product's pricing or performance datalow_rate = cost_per_success(0.001, 0.002, 2000, 800, success_rate=0.5)high_rate = cost_per_success(0.001, 0.002, 2000, 800, success_rate=0.8)print(f"Cost per success at 50% success rate: {low_rate:.4f}")print(f"Cost per success at 80% success rate: {high_rate:.4f}")
This example shows that with unit prices fixed, improving the success rate directly lowers cost per success. If post-training raises task success rates and reduces retries, it improves cost-efficiency without changing per-call prices.
Note that post-training may also increase output length or reasoning steps, raising per-call costs. So when evaluating, you should track token consumption, call counts, and success rates together—not just one of them.
5. Engineering Techniques to Reduce Inference Costs
Even with an optimized model, there are several application-layer methods to control costs.
1. Model routing: Choose model sizes based on task complexity. Route simple classification and format conversion tasks to small models, and escalate complex reasoning tasks to large models.
def route_request(task):if task.is_simple:return "small_model"if task.needs_long_context or task.is_multi_step:return "large_model"return "default_model"
2. Prompt trimming: Remove repeated background explanations and redundant examples, keeping only information essential to the task. Fewer input tokens mean lower costs.
3. Result caching: For identical or highly similar requests, return cached results directly. Cache keys can be computed as hashes of normalized inputs.
4. Batching: Combine offline tasks into batch requests to reduce call overhead, and run them during off-peak resource windows.
5. Early termination: In long-horizon tasks, set step limits and cost budgets. When thresholds are exceeded, output the best current result and note what remains incomplete.
These techniques can be combined. In practice, start with caching and prompt trimming since they barely affect quality; routing strategies should be tuned gradually based on evaluation data.
6. Building an Evaluation System
Model selection and optimization both require repeatable evaluation processes. A practical evaluation system typically has three layers.
Offline benchmarks: Use test sets relevant to your business, covering common and edge-case scenarios. Update test sets regularly to prevent overfitting to fixed questions.
Business replay: Replay real historical requests in a test environment and compare old and new versions on success rate, latency, and cost. Replay can surface issues that offline tests miss.
Online monitoring: Continuously record call volume, token consumption, error types, and human feedback. Set alert thresholds on monitoring metrics—for example, automatically notifying owners when cost per success exceeds budget.
When deploying in the cloud, you can use object storage to hold test datasets and run logs, log services to search for anomalous requests, and monitoring alerts to track cost and success rate changes. For example, the general-purpose capabilities offered by Baidu AI Cloud can serve as infrastructure components for building such a system.
7. Deployment and Risk Control
After a model version update, do not replace the old version across all traffic at once. A recommended process:
- Complete offline benchmarks and business replay in a test environment;
- Roll out to a small fraction of real traffic as a canary release and compare key metrics against the old version;
- Gradually increase traffic share once metrics stabilize;
- Keep the ability to roll back quickly to the old version until the new one runs stably.
In addition, record the training data sources, evaluation results, and known limitations for every version. This information speeds up root-cause analysis when problems occur and helps the team make informed trade-offs between versions.
8. Summary
Post-training provides a path to better model capability that doesn’t rely purely on scaling. For coding, long-horizon tasks, and defensive security scenarios, the keys are constructing verifiable training data, designing clear reward signals, and measuring outcomes with cost per successful task.
At the application layer, model routing, caching, prompt trimming, and budget controls can further reduce costs. Teams should build an evaluation system first, then decide optimization directions based on data. Only after clarifying business goals and cost constraints do model selection and optimization decisions have a solid foundation.
