Evaluating Large Language Models: From Benchmark Scores to Real Costs

    Selecting the right Large Language Model (LLM) requires looking beyond public benchmark scores and initial hands-on impressions. This article outlines a comprehensive methodology for evaluating LLMs, covering the nuances of model specifications like MoE parameters and KV cache memory, calculating actual unit task costs, building a reproducible business-specific evaluation pipeline, and establishing a weighted decision-making framework for reliable production deployment.

    1. Why Post-Release Overall Evaluations Are Hard to Trust

    When a new model is released, the community typically draws conclusions quickly. Some rely on public benchmark scores, while others base their judgments on a few personal chat interactions. Both approaches have limitations, and accepting them directly can lead to flawed decisions.

    1. Benchmark Contamination Risks

    Public evaluation datasets often leak into training data over time. If a model has seen the test questions or their variants during training, its score will exceed its true capability. Furthermore, results can fluctuate significantly depending on the evaluation set’s prompt templates, answer extraction rules, and sampling parameters. Therefore, identical scores across different reports may not be directly comparable.

    2. Preview Versions vs. Official Versions

    Preview versions are usually designed to collect feedback; their APIs, training strategies, and inference configurations may change in the official release. Making long-term technical decisions based on a preview version requires factoring in version risks and re-validating after the official release.

    3. Verifying Capability Boundaries

    Whether a model supports multimodal inputs, function calling, structured outputs, or long-document comprehension should be verified against official documentation and your own test results. Do not assume consistent behavior simply because a capability “looks similar.”

    2. Understanding the Real Meaning of Model Specifications

    Model releases often come with a set of specifications. These numbers correspond to different engineering constraints and must be understood individually.

    2.1 Total Parameters vs. Activated Parameters

    For models using the Mixture of Experts (MoE) architecture, each input token only passes through a subset of expert networks. Therefore, it is crucial to distinguish between two metrics:

    • Total Parameters: Determines model capacity and affects storage footprint and loading costs for weights.
    • Activated Parameters per Token: Determines the computational volume of a single forward pass, directly correlating with inference latency and compute costs.

    An increase in total parameters does not mean inference costs increase proportionally. The growth in activated parameters is a closer indicator of inference cost changes. Increasing the number of routing experts usually means the model can learn more granular knowledge divisions, but it also imposes higher demands on routing strategies, load balancing, and deployment parallelism.

    2.2 Context Length

    Expanding the context window from short lengths to millions of tokens is directly beneficial for long-document analysis, code repository comprehension, and multi-turn history retention. However, two points require attention:

    1. Nominal Length ≠ Effective Length: The recall rate of long-distance information may degrade based on position. This should be tested using “needle in a haystack” methods or your own business documents.
    2. KV Cache Occupancy Grows Linearly with Length: A longer context increases memory pressure during inference, reducing concurrency.

    The following example estimates the VRAM footprint of the KV Cache using sample parameters:

    1. def kv_cache_bytes(
    2. num_layers: int,
    3. num_kv_heads: int,
    4. head_dim: int,
    5. seq_len: int,
    6. batch_size: int = 1,
    7. dtype_bytes: int = 2, # FP16/BF16 is 2 bytes
    8. ) -> int:
    9. """Estimates the VRAM footprint of the KV Cache during Transformer inference (in bytes)."""
    10. # K and V are stored separately, hence multiplied by 2
    11. return 2 * num_layers * num_kv_heads * head_dim * seq_len * batch_size * dtype_bytes
    12. if __name__ == "__main__":
    13. size = kv_cache_bytes(
    14. num_layers=60,
    15. num_kv_heads=8,
    16. head_dim=128,
    17. seq_len=128_000,
    18. batch_size=4,
    19. )
    20. print(f"Estimated KV Cache: {size / 1024 ** 3:.2f} GiB")

    Actual VRAM usage also includes weights, activation values, framework overhead, and fragmentation. The estimate should only be used for preliminary capacity planning.

    2.3 Layers, Hidden Dimensions, and Structural Adjustments

    Metrics like the number of layers and Hidden Size reflect the overall architectural trade-offs. A slight decrease in layers combined with an expanded hidden dimension typically indicates a reallocation of parameters between width and depth. The effects of such adjustments must be verified through task performance; they cannot be judged as good or bad based solely on numerical changes.

    3. Evaluating Pricing by Unit Task Cost

    When comparing model prices, the most common mistake is looking only at the unit price per million tokens while ignoring the difference in input and output ratios.

    3.1 Calculating Input and Output Separately

    Most services charge a higher unit price for output than for input. For the same task, if the output is long, costs will rise significantly. Therefore, you should first gather statistics on the typical input and output lengths of your business tasks, and then calculate the cost per task.

    3.2 Comparing Only Within the Same Tier

    Models are usually categorized into tiers such as lite, standard, and premium. Pricing differences across tiers reflect capability differences, making cross-tier comparisons meaningless. A reasonable approach is:

    • Compare candidate models within the same tier on identical tasks;
    • Then compare unit task costs among the models that meet capability requirements.

    3.3 Cost Calculation Example

    The following example uses hypothetical unit prices solely to illustrate the calculation method:

    1. from dataclasses import dataclass
    2. @dataclass
    3. class ModelPrice:
    4. name: str
    5. input_per_million: float # Price per million input tokens (example unit: CNY)
    6. output_per_million: float # Price per million output tokens (example unit: CNY)
    7. def cost_per_task(price: ModelPrice, input_tokens: int, output_tokens: int) -> float:
    8. """Calculates the cost of a single task."""
    9. return (
    10. input_tokens / 1_000_000 * price.input_per_million
    11. + output_tokens / 1_000_000 * price.output_per_million
    12. )
    13. if __name__ == "__main__":
    14. candidates = [
    15. ModelPrice("Model A", input_per_million=1.0, output_per_million=4.0),
    16. ModelPrice("Model B", input_per_million=2.0, output_per_million=6.0),
    17. ]
    18. # Assume a task averages 3000 input tokens and 800 output tokens
    19. for m in candidates:
    20. cost = cost_per_task(m, input_tokens=3000, output_tokens=800)
    21. print(f"{m.name} cost per task: {cost:.6f} CNY")

    When calculating, you must also factor in retry rates, costs of failed tasks, and discounts from cache hits. Only then will the resulting number approximate the actual bill.

    4. Building a Reproducible Evaluation Process

    Public benchmarks cannot represent specific business scenarios, so teams need to build their own evaluation sets. The following steps are recommended.

    4.1 Constructing a Business Evaluation Set

    Extract samples from real business operations covering the following types:

    • Code generation and modification;
    • Document summarization and information extraction;
    • Structured outputs, such as JSON field population;
    • Multi-turn dialogue and instruction following;
    • Long-document Q&A.

    It is recommended to prepare dozens to hundreds of samples for each task type, retaining standard answers or scoring rules.

    4.2 Fixing Experimental Conditions

    When comparing different models, the following variables should be fixed:

    • Prompt templates and system instructions;
    • Sampling parameters like temperature and Top-P;
    • Output length limits;
    • Testing time windows, to avoid interference from server-side version changes.

    4.3 Recording Multi-Dimensional Metrics

    A single accuracy rate is insufficient to support decision-making. It is recommended to record the following simultaneously:

    Metric Description
    Task Accuracy Pass rate calculated based on scoring rules
    Format Compliance Whether the output conforms to the predefined structure, affecting downstream parsing
    First Token Latency Affects interactive experience
    Total Generation Time Affects batch processing throughput
    Cost per Task Calculated using the method in Section 3
    Failure and Retry Rate Reflects stability

    Below is a simplified evaluation framework skeleton:

    1. from typing import Callable, Iterable
    2. def run_eval(
    3. model_call: Callable[[str], str],
    4. samples: Iterable[dict],
    5. judge: Callable[[str, dict], bool],
    6. ) -> dict:
    7. """Executes evaluation on the sample set and returns aggregated metrics."""
    8. total, passed, errors = 0, 0, 0
    9. for sample in samples:
    10. total += 1
    11. try:
    12. output = model_call(sample["prompt"])
    13. if judge(output, sample):
    14. passed += 1
    15. except Exception:
    16. errors += 1
    17. return {
    18. "total": total,
    19. "accuracy": passed / total if total else 0.0,
    20. "error_rate": errors / total if total else 0.0,
    21. }

    Here, model_call encapsulates the specific model interface, and judge can be rule matching, unit testing, or calibrated manual review. If using a model as a judge, you must first verify the judge’s consistency using human-annotated samples.

    5. Comprehensive Selection and Decision Making

    After aggregating the above metrics, a weighted scoring table can be constructed. Weights should be determined by business priorities, for example:

    Dimension Example Weight Evaluation Method
    Business Accuracy 35% Custom evaluation set
    Format Compliance & Stability 15% Failure rate, format check
    Cost per Task 25% Calculated by actual usage
    Latency & Throughput 15% Stress testing and first token stats
    Compliance & Deployment 10% Data location, private deployment capability

    Decision-making should also consider the version lifecycle. Preview versions are suitable for validation and small-scale trials; expand usage only after the official version is released and passes regression testing.

    6. Implementation Best Practices

    1. Gradual Rollout: First switch a small amount of traffic to the new model, compare online metrics, and gradually scale up.
    2. Establish Regression Testing: Any change to the model or prompt requires re-running the evaluation set.
    3. Design Fallback Paths: Automatically switch to a backup model if the primary model times out or gets rate-limited, and log the fallback event.
    4. Multi-Model Routing: Assign simple tasks to low-cost models and complex tasks to high-capability models to balance quality and cost.
    5. Continuous Monitoring: Track costs, latency, error rates, and user feedback, and periodically review selection conclusions.

    7. Conclusion

    Evaluating a new large language model relies on converting specifications, pricing, and task performance into unified engineering metrics. Public scores can serve as a reference but cannot replace internal business testing. By examining total and activated parameters separately, calculating input and output costs individually, and verifying conclusions with a reproducible evaluation process, teams can make stable, explainable selection decisions in a fast-paced model iteration environment.