LLM Model Selection Guide: Balancing Accuracy, Latency, and Cost

    A practical framework for evaluating large language models in production by comparing accuracy, response time, token usage, and per-call cost. Learn how to account for business-specific requirements, compare models within the same cost tier, and build a reusable evaluation workflow.

    LLM Model Selection Guide: Balancing Accuracy, Latency, and Cost

    Once large language models enter an enterprise production environment, model selection is no longer about choosing the model with the highest overall score. The more practical question is: which solution best fits the required budget and latency constraints?

    A leaderboard score only reflects average performance on a particular set of benchmarks. It does not directly answer business-specific questions. This article presents an engineering-focused evaluation framework covering four dimensions: accuracy, response time, token usage, and per-call cost.

    1. Why a Single Ranking Is Not Enough

    Leaderboards typically rank models by an aggregate score calculated from multiple subtasks using weighted or unweighted averages. Two models may have the same overall score while performing very differently in reasoning, education, finance, or tool-calling scenarios.

    If the primary use case is customer support, scores for language understanding and instruction following may be more relevant than scores for mathematical reasoning.

    Leaderboards also often omit operational factors such as cost and latency. A model may answer benchmark questions correctly, but if each request takes several dozen seconds or produces twice as many tokens as comparable solutions, its production cost and user experience will be significantly worse.

    Model selection therefore requires quality and engineering metrics to be evaluated in the same framework.

    2. Four Core Metrics and How to Calculate Them

    2.1 Accuracy

    Accuracy is the percentage of questions answered correctly:

    1. Accuracy = Number of correct answers / Total number of questions × 100%

    Before calculating it, two aspects must be defined.

    First, establish the scoring method. Multiple-choice questions can be evaluated by directly comparing the selected options. Open-ended questions require reference answers together with human or rule-based grading.

    Second, break down results by task type or capability area. Instead of recording only one overall score, track the pass rate for each relevant domain.

    When a test set covers multiple domains, macro-averaged and micro-averaged accuracy may produce different results:

    • Macro average: Assigns equal weight to each domain and helps expose weak areas.
    • Micro average: Weights domains by the number of questions and more closely reflects the overall traffic distribution.

    The appropriate method depends on the distribution of tasks in the real business workload.

    2.2 Response Time

    Response time usually refers to the time from sending a request until the complete response is received.

    Production evaluations commonly track three statistics:

    • Average latency
    • P95 latency
    • P99 latency

    The average can hide long-tail behavior. In practice, tail latency often determines whether users continue waiting or abandon a request.

    For streaming responses, distinguish between:

    • Time to first token: The delay before the first piece of output appears, which strongly affects perceived responsiveness.
    • Time to completion: The time required to generate the entire response, which matters more for batch processing and throughput.

    2.3 Token Usage

    Tokens are the basic unit used to measure model computation and billing. Each request generally includes both input tokens and output tokens.

    Output tokens are often more expensive, and generation time is directly related to output length.

    Some reasoning-oriented models generate substantial intermediate content before producing a final answer. Whether these tokens are billed or counted as output depends on the provider’s billing rules. Evaluations should record the actual usage reported for each request rather than estimating consumption from prompt length alone.

    2.4 Per-Call Cost

    The cost of a single request can be calculated as follows:

    1. Cost per call =
    2. Input tokens × Input price +
    3. Output tokens × Output price

    The cost per thousand calls is:

    1. Cost per 1,000 calls = Cost per call × 1,000

    Assume that a solution generates an average of 2,000 output tokens per request and that the output price is 10 yuan per million tokens. This is an illustrative assumption:

    1. 2,000 × 10 / 1,000,000 = 0.02 yuan

    The output cost is therefore approximately 0.02 yuan per call, or about 20 yuan per 1,000 calls.

    Putting this figure into the business model makes it possible to estimate monthly expenses.

    3. The Trade-Offs Between Metrics

    These four metrics are often interconnected. Understanding their relationships is more useful than memorizing the exact figures for a particular model.

    First, accuracy is often related to reasoning depth. Asking a model to perform more reasoning steps may improve its accuracy on complex tasks, but it can also increase token usage and latency. For simple classification tasks, unnecessary reasoning may only waste budget.

    Second, latency affects the user experience. In conversational products, once time to first token exceeds a certain threshold, users tend to perceive the system as noticeably slower. If the workload supports asynchronous processing, a longer response time may be acceptable in exchange for higher-quality output.

    Third, token usage directly affects cost. Even when unit prices remain unchanged, longer average responses increase the cost per thousand requests. If a new model version improves accuracy by several percentage points but raises the cost per thousand calls by 40%, the team must determine whether the improvement justifies the additional expense.

    There is no universal answer. The decision depends on the cost of errors. If an incorrect answer triggers manual review, compensation, or other significant consequences, the marginal value of higher accuracy may be substantial. If errors can be corrected easily, controlling cost may be the higher priority.

    4. Comparing Models Within the Same Cost Tier

    When the budget is fixed, comparisons should be made among solutions in a similar cost range. Comparing accuracy across very different price tiers can lead to the conclusion that more expensive models perform better, but it does not answer the more important question of cost-effectiveness.

    The following conditions should be standardized:

    • Use exactly the same test set, scoring scripts, and prompt templates.
    • Keep calling parameters, such as maximum output length and sampling temperature, consistent, or clearly document any differences.
    • Use comparable concurrency levels and network conditions to avoid distorting latency results.
    • Calculate costs using the same billing methodology, including both input and output tokens.

    Within the same cost tier, if two solutions achieve similar accuracy, compare additional factors such as ranking stability, tail latency, and performance on long-output tasks.

    Equal accuracy only means that the average scores are similar. It does not mean that the two models behave in the same way.

    5. Building a Reusable Evaluation Workflow

    The following example illustrates the structure of a general-purpose evaluation framework. Replace call_model with the actual model invocation logic, and update the pricing parameters according to the provider’s current pricing documentation.

    1. import time
    2. from statistics import mean, quantiles
    3. PRICE_INPUT_PER_M = 2.0 # Input price per million tokens, illustrative value
    4. PRICE_OUTPUT_PER_M = 10.0 # Output price per million tokens, illustrative value
    5. def call_model(prompt: str) -> dict:
    6. """Replace with the actual call logic and return text and usage data."""
    7. raise NotImplementedError
    8. def evaluate(dataset: list[dict]) -> dict:
    9. correct, latencies, in_tokens, out_tokens = 0, [], [], []
    10. for item in dataset:
    11. start = time.perf_counter()
    12. resp = call_model(item["prompt"])
    13. latencies.append(time.perf_counter() - start)
    14. in_tokens.append(resp["usage"]["input_tokens"])
    15. out_tokens.append(resp["usage"]["output_tokens"])
    16. if resp["text"].strip() == item["answer"].strip():
    17. correct += 1
    18. n = len(dataset)
    19. avg_in = mean(in_tokens)
    20. avg_out = mean(out_tokens)
    21. cost_per_call = (
    22. avg_in * PRICE_INPUT_PER_M +
    23. avg_out * PRICE_OUTPUT_PER_M
    24. ) / 1_000_000
    25. p95 = quantiles(latencies, n=100)[94]
    26. p99 = quantiles(latencies, n=100)[98]
    27. return {
    28. "accuracy": correct / n if n else 0,
    29. "average_latency": mean(latencies),
    30. "p95_latency": p95,
    31. "p99_latency": p99,
    32. "average_input_tokens": avg_in,
    33. "average_output_tokens": avg_out,
    34. "cost_per_call": cost_per_call,
    35. "cost_per_1000_calls": cost_per_call * 1000,
    36. }

    This workflow records correctness, latency, token usage, and cost in one evaluation result. In a production-grade benchmark, the scoring logic should be adapted to the task type, especially when answers are open-ended rather than exact string matches.