Choosing an LLM: A Practical Evaluation Framework for Developers

    This article presents a practical framework for developers evaluating large language models. It covers task definition, six core evaluation dimensions, scenario-based capability matching, custom evaluation sets, total cost estimation, and rollout practices. Readers will learn how to compare models with business-relevant tests and build a reusable selection process rather than relying only on generic benchmarks.

    1. Define Tasks Before Comparing Models

    The first step in LLM selection is to break business requirements into describable tasks. Under the same label of “intelligent assistant,” customer service Q&A, contract review, code completion, and marketing copy generation place very different demands on model capabilities. Teams should list the input format, average input length, output length, response latency requirements, and error tolerance for each task to create a task inventory. Only when task boundaries are clear do subsequent model comparisons become meaningful.

    2. Six Core Evaluation Dimensions

    1. Context Window

    The context window determines how much text a model can process at once. When handling entire technical documents, long meeting transcripts, or large code repositories, window length is a hard constraint. A longer window does not necessarily produce better results. Recall for information in the middle of long inputs may decline, and longer inputs increase both cost and latency. During selection, test the model’s accuracy within the target length range rather than looking only at the nominal number.

    2. Cost Structure

    Cost usually consists of input tokens, output tokens, cache hits, and concurrency quotas. Output token unit prices are often higher than input token prices, so costs grow faster for tasks that generate long text. For estimation, calculate “average input per request × daily requests × unit price” and add overhead from retries and exception requests. Prices change frequently, so conclusions should be based on the vendor’s current official pricing; figures in articles or evaluations can only serve as order-of-magnitude references.

    3. Modality Capabilities

    Modality capabilities refer to whether a model can directly process non-text inputs such as images, audio, and video. If the business involves receipt recognition, semantic understanding after speech transcription, or mixed image-text Q&A, confirm whether the model supports these natively or relies on front-end recognition modules stitched together. Native multimodal approaches usually have shorter pipelines, but the accuracy of each modality must be validated separately.

    4. Reasoning and Coding Capabilities

    Reasoning capability affects the correctness of multi-step tasks such as numerical calculation, conditional judgment, and complex planning. Coding capability is reflected in code generation, defect localization, and test writing. These two capabilities are best evaluated with real examples rather than generic leaderboard scores, because the distribution of leaderboard questions often differs from that of business code.

    5. Tool Calling and Agent Capabilities

    When a model needs to call databases, retrieval interfaces, or internal services, the focus is on whether structured output is stable, whether parameters are filled in accurately, and whether it can retry correctly after failures. Multi-agent collaboration approaches also require evaluation of task decomposition, state sharing, and end-to-end failure recovery.

    6. Deployment and Compliance Requirements

    Whether data is allowed to leave the region, whether private deployment is required, log retention policies, and output audit requirements can directly limit the available options. This should be determined early in the selection process. Changing models later usually incurs high migration costs.

    3. Match Capabilities to Scenarios

    • Long-document processing and content creation: Prioritize stability in long contexts and Chinese-language expression quality, and run side-by-side tests with the same batch of documents.
    • Deep integration with existing platforms: Prioritize ecosystem maturity, including whether plugins, connectors, and operations tools are complete. The deeper the integration, the higher the migration cost, so lock-in risk should be assessed in advance.
    • Voice and multimodal interaction: Prioritize end-to-end latency, recognition accuracy for multimodal inputs, and interaction capabilities such as streaming output and interruption response.
    • Code development and complex reasoning: Prioritize code correctness, fix success rate, and adherence to complex constraints.

    A single business process can be split into multiple subtasks, with different models selected for each and unified through a routing layer. This approach can achieve a better balance between performance and cost.

    4. Validate with Your Own Evaluation Set

    Generic leaderboards cannot replace business testing. The following steps are recommended for building an evaluation set:

    1. Sample 200 to 500 representative cases from historical requests, covering common scenarios and edge cases.
    2. Write the expected output or scoring criteria for each case.
    3. Run candidate models with the same prompts and parameters.
    4. Summarize results using four metrics: accuracy, format compliance rate, latency, and cost per request.

    Below is a generic evaluation summary example. The model invocation part is represented by a placeholder function and should be replaced with the client actually used by the team.

    1. from dataclasses import dataclass
    2. from statistics import mean
    3. @dataclass
    4. class Case:
    5. prompt: str
    6. expected: str
    7. def call_model(model_name: str, prompt: str) -> tuple[str, float]:
    8. """Placeholder function: returns model output text and elapsed time (seconds). Replace with an actual client call."""
    9. raise NotImplementedError
    10. def is_correct(output: str, expected: str) -> bool:
    11. # Example: simple containment check; in practice, replace with semantic comparison or human scoring rules
    12. return expected.strip() in output
    13. def evaluate(model_name: str, cases: list[Case]) -> dict:
    14. correct, latencies = 0, []
    15. for case in cases:
    16. output, latency = call_model(model_name, case.prompt)
    17. latencies.append(latency)
    18. if is_correct(output, case.expected):
    19. correct += 1
    20. return {
    21. "model": model_name,
    22. "accuracy": correct / len(cases),
    23. "avg_latency_s": round(mean(latencies), 3),
    24. }

    During evaluation, failed samples should also be recorded. Many selection mistakes come from ignoring failure modes, such as format errors that cause downstream parsing failures, or missed key conditions at the end of long inputs.

    5. Estimate Total Cost

    Total cost is not equal to unit price multiplied by the number of calls. A complete estimate should include the following:

    • Input and output costs for normal requests;
    • Retry costs caused by format errors or timeouts;
    • Concurrency resource costs configured to ensure response speed;
    • Labor costs for human review and correction of outputs.

    A lower-priced model may have a higher actual cost if it requires many retries. Therefore, comparisons should use “average cost to complete one valid task” as the metric.

    6. Implementation Recommendations

    1. Start with a small-traffic canary rollout and observe performance on real data.
    2. Encapsulate the model invocation interface at the application layer to avoid business code directly depending on one vendor’s proprietary parameters, making future switching easier.
    3. Set up monitoring metrics, including success rate, latency percentiles, daily cost, and exception type distribution.
    4. Rerun the evaluation set every quarter, because model versions and prices change.
    5. Establish desensitization rules for sensitive data and define log retention periods.

    The goal of model selection is to achieve a long-term match between model capabilities and business requirements. A one-time side-by-side comparison only provides an answer for the present; a reusable evaluation process supports every subsequent decision.