Multidimensional Evaluation and Cost Optimization for Large Language Model Upgrades

    Upgrading a large language model can improve capability while also changing latency and cost. This article presents a reproducible evaluation framework covering accuracy, response latency, token usage, and per-call cost. It also explains how to compare performance by domain, assess statistical reliability, calculate cost-effectiveness, and establish practical release criteria.

    1. Why Model Upgrades Require Multidimensional Evaluation

    A model upgrade can change capability, speed, and cost at the same time. Looking only at accuracy may hide increases in latency and spending. For example, after a model’s reasoning capability improves, it may generate more intermediate steps. This increases the number of tokens per request and raises the total cost. Without tracking these metrics together, a team cannot determine whether the benefits of an upgrade justify its additional expense.

    Evaluation should therefore use the same dataset, prompt set, and parameters for both versions while recording capability and resource metrics. Only consistent evaluation conditions make differences between old and new versions meaningful.

    2. Four Core Metrics

    1. Accuracy

    Accuracy is calculated as the number of correct answers divided by the total number of questions. Before calculating it, fix the evaluation dataset and scoring rules. If scoring depends on human judgment, review a sample manually and record inter-rater consistency. For larger datasets, also report the sample size so readers can assess whether the observed difference is reliable.

    2. Response Latency

    Response latency is the time from sending a request to receiving the complete response. Because a small number of long-tail requests can significantly increase the average, report P50, P90, and P99 whenever possible.

    • P50 reflects the typical user experience.
    • P90 and P99 reflect extreme cases and are particularly important for applications that require stable response times.

    3. Token Usage

    Track input tokens and output tokens separately. For reasoning-oriented tasks, output length often changes more significantly than input length. Separate tracking makes it easier to identify the source of cost increases.

    4. Cost per Call

    Calculate the cost of each call using the applicable token prices:

    1. Cost per call = input tokens × input price + output tokens × output price
    2. Cost per 1,000 calls = cost per call × 1,000

    Use the actual prices specified in the relevant contract or pricing documentation. The evaluation report should also specify the currency and billing unit.

    3. Comparing Domains and Measuring Improvement

    Overall accuracy can conceal degradation in specific areas. Split the evaluation dataset by task type, such as:

    • Knowledge question answering
    • Logical reasoning and mathematics
    • Code understanding and generation
    • Text extraction and rewriting
    • Long-context processing

    Calculate accuracy for each domain separately, then compare the results with the previous model version.

    Report improvements in percentage points, not percentages. The calculation is:

    1. Improvement in percentage points = new accuracy − old accuracy

    For example, if accuracy in a domain increases from 60.0% to 65.0%, the improvement is 5.0 percentage points. The relative improvement is 8.3%. These figures have different meanings and should be labeled clearly in the report.

    4. A Reproducible Evaluation Workflow

    A reproducible evaluation process generally includes the following steps:

    1. Fix the evaluation dataset and record its version and source.
    2. Fix the prompt templates, system instructions, and sampling parameters.
    3. Run requests in batches and record correctness, latency, and token usage for each call.
    4. Score the results automatically and manually review a subset of samples.
    5. Aggregate overall and domain-level metrics, then calculate the differences.
    6. Generate a report that includes the sample size, confidence intervals, and evaluation environment.

    The following code provides a basic implementation for aggregating metrics from individual call records:

    1. import statistics
    2. from dataclasses import dataclass
    3. @dataclass
    4. class CallRecord:
    5. correct: bool
    6. latency_s: float
    7. input_tokens: int
    8. output_tokens: int
    9. def summarize(records, price_in, price_out):
    10. """price_in and price_out are per-token prices supplied by the user."""
    11. n = len(records)
    12. if n == 0:
    13. raise ValueError("records cannot be empty")
    14. latencies = sorted(r.latency_s for r in records)
    15. p90_index = min(n - 1, int(0.9 * (n - 1)))
    16. total_cost = sum(
    17. r.input_tokens * price_in + r.output_tokens * price_out for r in records
    18. )
    19. return {
    20. "accuracy": sum(r.correct for r in records) / n,
    21. "avg_latency_s": statistics.mean(latencies),
    22. "p90_latency_s": latencies[p90_index],
    23. "avg_tokens": sum(r.input_tokens + r.output_tokens for r in records) / n,
    24. "cost_per_1k_calls": total_cost / n * 1000,
    25. }
    26. def compare(old, new):
    27. """Return metric differences between the new and old versions.
    28. Accuracy differences are expressed as percentage points in decimal form.
    29. """
    30. return {key: new[key] - old[key] for key in old}

    After producing the summary, add statistical testing to avoid treating random variation as a real performance difference.

    5. Interpreting Results and Making Decisions

    1. Determine Whether Accuracy Differences Are Reliable

    For a proportion metric, a 95% confidence interval can be estimated using the normal approximation:

    1. Approximate interval half-width ≈ 1.96 × √(p × (1 − p) / n)

    Here, p is the accuracy and n is the sample size. If the confidence intervals for the two versions clearly do not overlap, the difference is more likely to be meaningful. If the intervals overlap substantially, expand the evaluation dataset or run the test multiple times.

    2. Measure Cost Effectiveness

    Cost per correct answer reflects both pricing and accuracy:

    1. Cost per correct answer = cost per 1,000 calls ÷ (1,000 × accuracy)

    This metric helps teams compare a more expensive but more accurate model with a cheaper model that performs slightly worse.

    3. Consider Business Constraints

    Whether latency and cost are acceptable depends on the application. Interactive products typically place greater importance on P90 latency, while batch-processing workloads may focus more on cost per unit of work. Evaluation conclusions should be compared with these business constraints rather than based solely on changes in a single metric ranking.

    6. Common Mistakes

    • Looking only at the overall score: An overall improvement may come from a major gain in one domain while other domains have degraded.
    • Ignoring output length: Longer outputs can increase both latency and cost, and this effect is easy to overlook.
    • Using averages instead of percentiles: A small number of timeout or long-tail requests can distort the average. Tail latency should be examined separately.
    • Using inconsistent test conditions: Changes to prompts, sampling parameters, or dataset versions make comparisons unreliable.
    • Drawing conclusions from a single run: Generated outputs are often stochastic. Run the evaluation multiple times and report both the average and the range of variation.

    7. Practical Recommendations

    Start by creating a fixed baseline dataset. Whenever the model is upgraded or service parameters change, rerun the same evaluation process. Then define acceptance criteria, such as requiring overall accuracy not to decline, maintaining baseline performance in critical domains, and keeping P90 latency and cost per 1,000 calls below budget limits.

    After deployment, continue monitoring production latency, token usage, and spending. Compare these operational metrics with offline evaluation results to verify that the evaluation conclusions remain consistent with real-world performance.