Evaluating Large Language Models: An Engineering Approach from Architecture to Cost-Effectiveness

    Selecting the right large language model (LLM) for your business requires more than just checking leaderboards and unit prices. This article introduces an engineering approach to model evaluation, covering how to interpret architectural parameters like MoE, context windows, and multimodal capabilities. It outlines a four-dimensional evaluation framework focusing on capability, cost, latency, and stability, and provides guidance on building custom evaluation sets and cost models. Additionally, it discusses testing strategies for long context and multimodal tasks, deployment strategies with canary releases and rollbacks, and common pitfalls to avoid during the selection process.

    Why Model Selection is Harder Than Reading Leaderboards

    Information released about new models usually falls into three categories: parameter size, composite benchmark scores, and pricing. While valuable, none of these are sufficient to make direct business decisions.

    Composite benchmarks compress the performance of multiple tasks into a single number, making horizontal ranking easy but losing structural information. Two models with the same total score might have different strengths—one might excel at reasoning, while another is better at code generation or text extraction. Furthermore, the distribution of benchmark questions usually differs from that of business data; a high score does not guarantee effectiveness in your customer service tickets or contract review scenarios.

    Pricing also has its traps. A lower unit price does not mean a lower total cost, because different models consume varying amounts of output tokens to complete the same task. A model might be more “verbose” or require multiple retries to produce a qualified result.

    Therefore, teams need a fixed evaluation process: first define business metrics, then test candidate models using unified data and criteria, and finally compare capability, cost, latency, and stability in a single table.

    Understanding Model Architectural Parameters

    Parameters in a model’s technical documentation need to be translated into judgments about their engineering impact. Here are the meanings of several common parameters.

    Total vs. Activated Parameters

    Models using the Mixture of Experts (MoE) architecture contain multiple expert sub-networks, activating only a subset during each forward pass. This results in two numbers: total parameters and activated parameters per inference.

    • Total parameters determine the model’s capacity ceiling and affect memory usage and deployment thresholds.
    • Activated parameters relate to the computational volume of a single inference, usually affecting latency and unit cost.

    A smaller ratio between the two indicates a more aggressive trade-off between capacity and computation. This structure is suitable for high-throughput, low-latency scenarios, but the stability of expert routing needs to be verified through actual testing rather than just looking at the parameter table.

    Context Window

    The context window refers to the maximum number of tokens a model can process at once, including both input and output. A larger window makes scenarios like long-document Q&A, code repository understanding, and multi-turn conversation memory easier to implement. However, a long window does not equate to good long-text understanding. Actual performance depends on the information’s position, retrieval method, and the implementation details of the attention mechanism.

    When testing long context, it is recommended to place key information at the beginning, middle, and end of the text separately to observe whether recall rate drops based on position.

    Multimodal Input

    Native multimodal and bolt-on vision modules represent two different implementation approaches. The former learns images, text, and video simultaneously during the pre-training phase, usually resulting in tighter cross-modal alignment. The latter uses an additional encoder to convert images into vectors before passing them to the language model, which costs less to implement but may limit fine-grained understanding.

    In engineering, multimodal capabilities should be tested by task: chart reading, table recognition, UI screenshot understanding, and video keyframe description might perform very differently.

    Pre-training vs. Distillation

    Models pre-trained from scratch have a significantly different capability distribution compared to smaller models obtained through distillation or pruning from larger ones. Distilled models may perform close to the original on common tasks but are usually weaker on long-tail problems and complex reasoning. Determining whether a model is “just a smaller version” should not rely on its name but on its performance on your evaluation set.

    Building a Four-Dimensional Evaluation Framework

    During model selection, it is recommended to examine four dimensions simultaneously: capability, cost, latency, and stability.

    Dimension Key Questions Common Metrics
    Capability Can it complete core tasks? Accuracy, manual scoring, unit test pass rate
    Cost Single task and monthly total spend Price per token, average input/output length, retry rate
    Latency User wait time Time to first token, total response time, throughput
    Stability Is it reliable in production? Timeout rate, error rate, output format compliance rate

    The weighting of these four dimensions depends on the scenario. User-facing real-time chat prioritizes latency, offline batch processing prioritizes cost, and compliance-related businesses must put output stability first.

    Designing a Custom Evaluation Set

    A custom evaluation set is the most reliable basis for model selection. Follow these steps to build one:

    1. Sample real data: Extract representative samples from historical requests, covering high-frequency scenarios and typical hard cases, and anonymize the data.
    2. Define standard answers or scoring rules: Use exact answers for tasks that can be judged precisely, rubrics for open-ended tasks, and unit tests for code tasks.
    3. Control variables: Use the same prompt template, temperature parameter, and output format requirements for all candidate models.
    4. Multiple sampling: Call the same input multiple times to observe result volatility, avoiding misjudgments caused by a single accidental success.

    Below is a general evaluation execution framework. The model calling function should be encapsulated by your team:

    1. import time
    2. def run_eval(model_call, cases):
    3. """Executes evaluation on candidate models, returning score and time per sample.
    4. model_call: A function that takes a prompt string and returns output text
    5. cases: A list, where each item contains id, prompt, reference, and grader fields
    6. """
    7. results = []
    8. for case in cases:
    9. start = time.perf_counter()
    10. output = model_call(case["prompt"])
    11. latency = time.perf_counter() - start
    12. score = case["grader"](output, case["reference"])
    13. results.append({
    14. "id": case["id"],
    15. "score": score,
    16. "latency": latency,
    17. "output": output,
    18. })
    19. return results
    20. def summarize(results):
    21. """Summarizes average score, average latency, and maximum latency."""
    22. n = len(results)
    23. if n == 0:
    24. return {}
    25. return {
    26. "avg_score": sum(r["score"] for r in results) / n,
    27. "avg_latency": sum(r["latency"] for r in results) / n,
    28. "max_latency": max(r["latency"] for r in results),
    29. }

    The grader can be an exact match function or a function that calls another judge model to score based on a rubric. When using a model as a judge, you need to sample and manually verify the reliability of the judge’s results to prevent the judge model’s own biases from contaminating the conclusions.

    Using a Cost Model Instead of Unit Price Comparison

    Unit price is only part of the cost. A reasonable approach is to estimate the monthly cost of complete tasks, factoring in input/output length, call volume, and retry rate.

    1. def monthly_cost(requests_per_day, avg_input_tokens, avg_output_tokens,
    2. price_in_per_m, price_out_per_m, retry_rate=0.0, days=30):
    3. """Estimates monthly call cost. Unit price is per million tokens.
    4. retry_rate: Retry proportion, e.g., 0.1 means 10% of requests need one retry.
    5. """
    6. effective_requests = requests_per_day * days * (1 + retry_rate)
    7. input_cost = effective_requests * avg_input_tokens / 1_000_000 * price_in_per_m
    8. output_cost = effective_requests * avg_output_tokens / 1_000_000 * price_out_per_m
    9. return round(input_cost + output_cost, 2)
    10. # Example parameters are fictional and only used to demonstrate the calculation
    11. model_a = monthly_cost(50_000, 1_200, 400, price_in_per_m=1.0, price_out_per_m=4.0, retry_rate=0.02)
    12. model_b = monthly_cost(50_000, 1_000, 900, price_in_per_m=0.6, price_out_per_m=2.5, retry_rate=0.15)
    13. print(model_a, model_b)

    In the example, Model B has a lower unit price, but its output is longer and its retry rate is higher, meaning the monthly cost might not be cheaper. This is why you need to replace example parameters with real task data before comparing.

    Correctly Understanding Composite Scores

    Composite scores are weighted results of multiple tests. Keep the following points in mind when reading them:

    • Same score does not mean same capability: Two models with similar total scores might have varying strengths in individual areas. Compare sub-metrics relevant to your business one by one.
    • “On par” is not “better than”: If multiple sub-metrics are slightly lower than a competitor’s, a tied composite score only means the overall level is close, not that it is better in all scenarios.
    • Benchmark questions have distribution bias: Public question banks might overlap with training data or lean towards academic problems. Use your custom evaluation set as the primary reference, and treat leaderboards as an initial screening tool.
    • Pay attention to evaluation settings: The same model might score very differently under different prompts and inference parameters. Ensure the criteria are consistent when comparing.

    Practical Testing for Long Context and Multimodal

    Long context testing can utilize “needle in a haystack” style cases: embed a key fact within a long text and ask the model to extract it accurately. Gradually increase the text length and change the fact’s position, recording the recall rate curve. If the curve drops sharply after a certain length, the actual usable window is shorter than the nominal value.

    Multimodal testing should design samples by sub-task. For receipt recognition, you can separately test field localization, digit reading, table structure restoration, and handwriting recognition. Score each task individually to prevent “overall looks good” from masking a significant shortcoming in a specific sub-task.

    Deployment Strategy: Canary Release and Rollback

    Once a candidate model is identified, a direct full-scale switch is not recommended. The recommended deployment process is as follows:

    1. Shadow traffic: Send live requests to both the old and new models simultaneously. Only log the new model’s output without returning it to users, and compare quality and timing.
    2. Small-scale canary release: Gradually increase traffic by user or request ratio, setting clear thresholds for quality and error rates.
    3. Automatic rollback: Automatically switch back to the old model when timeout rates, format error rates, or manual feedback exceed thresholds.
    4. Continuous evaluation: Model versions, prompts, and business data will change. The evaluation set needs to be updated and re-run regularly.

    The key to a rollback mechanism is preparation. The routing layer should make the model identifier a configuration item, so switching only requires a configuration change without redeploying business code.

    Common Pitfalls

    • Looking only at parameter size: Large parameters do not guarantee good business results. Data quality, training methods, and inference costs also matter.
    • Looking only at single demos: Selected examples are often optimal results. Use batch samples to analyze statistical distribution.
    • Ignoring output format: When downstream systems rely on structured output, format compliance is more important than language fluency.
    • Ignoring hidden costs: Prompt length, retries, manual reviews, and operational costs all affect the total cost.

    The core of model selection is comparing using unified data, unified criteria, and a unified cost model. As long as the evaluation process is reproducible, teams can continuously make verifiable judgments amidst rapid model iterations.