Model Selection in Practice: Inputs, Outputs, Cost, and Agent Evaluation
A practical guide to selecting large language models based on task inputs, acceptance criteria, output budgets, context windows, total cost, and real-world Agent performance. It explains how to build cost models, benchmark different models under consistent conditions, assign models by task type, and avoid common evaluation mistakes.
1. Evaluate Inputs and Acceptance Criteria Before Price
Many teams start model selection by comparing unit prices. This can lead to the wrong decision. For similar tasks—such as reading files, writing code, or calling tools—one model may cost only a few cents per round while another costs several dollars. However, the key factor in total cost is usually whether the task passes acceptance on the first attempt and how many additional iterations are required after failure.
A cheaper model may require three retries, making the total cost higher than that of a more expensive model that succeeds immediately. Model selection should therefore focus on the total cost of completing a business task, including:
- Model inference charges
- Human review time
- The cost of failed runs and retries
A practical decision sequence is:
- Identify the input type, such as text, mixed text and images, or direct video input.
- Define acceptance criteria, such as extraction accuracy, the percentage of code that passes tests, or tool-calling accuracy.
- Compare candidate models against those criteria, and calculate costs only afterward.
2. Specifications Are Not Rankings: Understand Context and Output Budgets
Specifications in official documentation are a starting point, but they do not directly predict real-world performance. Common specification categories include the following.
Context window: The total amount of input and output a model can process in one request. Million-token context windows can be useful for entire documents, large codebases, or long conversation histories. However, a larger window does not guarantee that the model can effectively use every piece of information inside it.
Per-request output budget: The maximum number of tokens a model can generate in a single response. This is not the same as the length of the final answer. An answer may contain only a few hundred words but still be truncated if the output budget is too small.
Reasoning mechanism: Some models support reasoning before producing an answer. Reasoning also consumes generated tokens, and in many APIs, reasoning tokens and visible output share the same output budget. If the budget is too small, the model may stop before completing the answer.
Shared context window: In multi-turn conversations and Agent loops, historical messages, tool results, and the current response all consume the same context window. Therefore, the assumption that a model can still produce an equally long output after the input has filled the window is usually incorrect.
Model identifier: Calls should use the identifier specified in the official documentation. Preview and production releases may use different identifiers, and reusing an outdated identifier can produce behavior that differs from expectations. The model version should also be recorded in test results to support future reproduction.
3. Cost Model: Turn Unit Prices into a Formula
Costs are usually based on input tokens, output tokens, and reasoning tokens. Different models may charge different rates for each category. In Agent scenarios, repeated billing for shared context across multiple calls must also be considered.
The cost of a single call can be estimated as follows:
def estimate_call_cost(input_tokens, output_tokens, thinking_tokens,price_in, price_out, price_think=None):"""Estimate the cost of one call. Prices are in yuan per million tokensand are provided for illustration only."""if price_think is None:price_think = price_out # Use the output price if reasoning tokens have the same ratecost = (input_tokens * price_in+ output_tokens * price_out+ thinking_tokens * price_think) / 1_000_000return round(cost, 6)
The total cost of an Agent task is the sum of all calls. The input in round n generally includes messages and tool results from previous rounds, so the cost of a long task increases as the loop continues. For a more realistic estimate, add the input length of every round rather than evaluating each round independently.
Cost evaluation should include:
- Average cost per task: Total cost divided by the number of tasks.
- First-pass success rate: The proportion of tasks that pass acceptance without human intervention.
- Cost per successful task: Total cost divided by the number of tasks that pass. This metric reflects both unit price and rework rate.
- Human review time: In many teams, this costs more than the model itself.
4. Assign Models by Task Type
Different tasks require different capabilities. They should be evaluated separately rather than handled by a single model in every scenario.
Batch image-text processing and structured extraction: Examples include invoice recognition, form extraction, and product information organization. These tasks often involve large input volumes and relatively short outputs, making unit price important. Start by establishing a cost baseline, then measure accuracy and format consistency.
Direct video understanding: Examples include analyzing surveillance clips or summarizing instructional videos. Confirm whether the model supports video input and check its limits on frame count, duration, and resolution. Extracting frames and sending them to an image-capable model can be an alternative, but the resulting information loss must be evaluated.
Long-document question answering and retrieval-augmented generation: Examples include contract review and technical documentation search. In addition to context size, test whether the model can locate important information in long inputs. A common method is to place test information near the middle of a document and verify whether the model can retrieve it.
Complex Agent tasks: Examples include multi-step code modification and cross-system data processing. These tasks depend on accurate tool calls, error recovery, and maintaining state across a long workflow. Specifications alone cannot show these capabilities; they must be tested with realistic tasks.
5. A Staged Trial Sequence
In production, models can be introduced gradually. Each stage should be based on data from the previous stage.
Step 1: Establish a baseline with high-frequency tasks. Choose common business tasks with clear acceptance criteria. Use a relatively low-cost model that can already complete them reliably. Record accuracy, cost, and latency. This data becomes the reference point for later comparisons.
Step 2: Introduce alternatives in budget-sensitive scenarios. If some tasks require a large generation budget, such as long reports or complete source files, include models with larger output budgets. Compare their truncation rates and costs.
Step 3: Test specific input formats. If the business involves video, separately test models that support video input and compare them with a frame-extraction approach.
Step 4: Use the same test set for complex Agent tasks. Do not choose a model based on intuition or marketing claims. Run all candidates with the same prompts, tool definitions, and scoring rules, and make the decision based on the results.
6. How to Re-Test the Same Task Set
The core principle of re-testing is to control variables. Results are comparable only when inputs, tools, and scoring rules are consistent.
Build an evaluation set: Extract samples from real business workflows. Include normal cases, edge cases, and known failure cases. In general, use at least several dozen samples and group them by task type.
Fix the experimental conditions: Keep the prompt template, temperature, tool definitions, timeout, and retry policy consistent. If a model requires special parameter adjustments, document them in the report.
Define the metrics: In addition to task success rate, record tool-calling accuracy, average number of rounds, input and output token counts, cost per task, and human editing time.
The following is a simplified evaluation framework:
def run_benchmark(models, cases, runner):"""Run each candidate model on the same cases and summarize key metrics."""report = {}for model in models:stats = {"passed": 0, "tool_errors": 0, "cost": 0.0, "rounds": 0}for case in cases:result = runner(model, case) # Keep prompts, tools, and timeouts fixedstats["passed"] += int(result["passed"])stats["tool_errors"] += result["tool_errors"]stats["cost"] += result["cost"]stats["rounds"] += result["rounds"]n = len(cases)report[model] = {"pass_rate": stats["passed"] / n,"avg_tool_errors": stats["tool_errors"] / n,"avg_cost": stats["cost"] / n,"avg_rounds": stats["rounds"] / n,}return report
Test results should include distributions, not just averages. A model may have a low average cost but become extremely expensive on a small number of long tasks. That risk can be hidden by the average. Record the median and the 90th percentile as well.
A single run may also produce random results. For critical tasks, repeat the evaluation multiple times to assess stability.
7. Common Mistakes
Looking only at context length. A large context window indicates the maximum input capacity, not whether the model can use the information correctly.
Ignoring the output budget. An insufficient budget can truncate answers or damage their format. These problems may not become visible until acceptance testing.
Ignoring reasoning tokens. Enabling reasoning increases both cost and latency. If only the visible answer length is counted, the actual cost will be underestimated.
Drawing conclusions from a single test. One or two examples cannot represent a business workload. Conclusions should be based on a sufficiently large and representative sample.
Mixing versions and parameters. Different model versions may behave differently. Test records should include the model identifier, version, invocation parameters, and test date.
8. Implementation Recommendations
After completing model selection, retain the evaluation workflow as a long-term maintenance tool. When model versions, business requirements, or prices change, the same test set can be used for rapid re-evaluation without starting from scratch.
At the implementation level, connect invocation logs, cost statistics, and evaluation results to logging and monitoring systems. Set thresholds for per-task cost and failure rate. If you use model services from Baidu AI Cloud, its general logging and monitoring capabilities can also be used to build a dashboard that tracks cost and quality metrics in one view.
Ultimately, model selection is an engineering problem centered on business tasks. First define the input and acceptance criteria. Then understand output budgets and shared context windows. Next, compare total cost and success rate using the same task set. Finally, introduce models in stages. This approach is more reliable, easier to explain, and easier to reproduce than choosing a model based only on price or specifications.
