Evaluating Large Language Models: A Practical Framework for Model Selection

    \$\$This article presents a neutral, repeatable framework for evaluating general-purpose large language models and making selection decisions. Instead of asking which model is "best," it reframes the question around business scenarios, quality standards, and cost constraints. It covers seven capability dimensions, a three-layer evaluation set design with anti-contamination practices, automated grading with human review as a fallback, non-functional and cost metrics, and a four-step selection process that leads to model routing and fallback. The goal is to treat evaluation as a long-term engineering asset rather than a one-time activity.

    \$\$## 1. Why “Which Model Is Strongest” Is the Wrong Question

    In real engineering work, teams often face a question that looks simple but is extremely hard to answer: among today’s mainstream general-purpose large language models, which one performs better overall? Community discussions tend to be highly subjective—one model is “stable but unexciting,” another is “more creative,” and another “stands out on cost-effectiveness.” These claims are not baseless, but they usually reflect personal experience in limited scenarios and lack a reproducible evaluation design, so they cannot serve directly as a basis for technical selection.

    A more reasonable approach is to reframe the question: under a clearly defined business scenario, clear quality standards, and clear cost constraints, which combination of model capabilities best matches the requirements. Model capability is multi-dimensional, including instruction following, long-context handling, structured output, code generation and repair, multimodal understanding, tool calling, refusal and safety policies, latency and throughput, and cost per task. The relative position of different models on these dimensions keeps shifting with each version release, so any static ranking becomes outdated quickly.

    This article therefore does not compare specific products. Instead, it provides an executable, neutral evaluation framework. The framework has proven effective across extensive enterprise practice: first define the scenario, then define the metrics, then build the evaluation set, and finally use a combination of automation and human review to reach comparable conclusions.

    2. Breaking Down Capabilities into Measurable Items

    To evaluate “overall performance,” the first step is to decompose it into dimensions. At least the following seven categories should be covered:

    1. Instruction following and format constraints. This examines whether the model strictly obeys requirements on word count, language, JSON structure, field enumerations, and negative constraints. The most common engineering failure is not poor content but invalid formatting that breaks downstream parsing.
    2. Reasoning and factual accuracy. This includes multi-step reasoning, numerical calculation, fact checking, and ambiguity resolution. Evaluation should introduce automatically verifiable reference answers to avoid subjective drift among reviewers.
    3. Code capability. This covers code generation, code explanation, defect localization, unit test generation, and cross-file refactoring. Executable test cases are recommended for grading rather than text similarity.
    4. Long context and information extraction. This examines the ability to locate details in long documents, summarize across paragraphs, and resist interference from inserted irrelevant content.
    5. Multimodal understanding. If the business involves images, screenshots, scanned documents, or audio and video, a separate evaluation set for those modalities is needed.
    6. Tool calling and workflow orchestration. This examines the accuracy of function parameter extraction, consistency across multi-turn calls, and how well the model works with failure rollback and retry strategies.
    7. Non-functional metrics. These include time to first token, overall latency, throughput, availability, rate-limiting policies, cost per task, and data compliance and audit capabilities.

    Once these dimensions are made explicit, a subjective description such as “stable but boring” can be translated into measurable statements: above-average but low-variance scores in creative writing; consistent performance in factual accuracy; and a low failure rate under format constraints.

    3. Evaluation Set Design: Layering and Anti-Contamination

    The quality of the evaluation set determines the quality of the conclusions. A three-layer structure is recommended:

    • L1 smoke set (50 to 100 items): covers core scenarios and is used for fast regression after every change.
    • L2 scenario set (200 to 500 items per scenario): sampled according to the real distribution of the business, including typical and long-tail samples.
    • L3 adversarial set (100 to 300 items): includes prompt injection, unauthorized requests, ambiguous instructions, extremely long inputs, and maliciously encoded content.

    Anti-contamination is critical. Evaluation samples should be rotated regularly, and a private holdout set should be maintained to avoid inflated scores caused by public data entering training corpora. An illustrative structure is shown below:

    1. {
    2. "id": "cs-0421",
    3. "layer": "L2",
    4. "scene": "code_fix",
    5. "input": {"language": "python", "snippet_ref": "s3", "error": "KeyError"},
    6. "constraints": {"output": "json", "fields": ["patch", "reason", "risk"]},
    7. "grader": {"type": "unit_test", "timeout_ms": 8000},
    8. "tags": ["long_tail", "no_network"]
    9. }

    4. Evaluation Execution: Automated Grading First, Human Review as Fallback

    Automated grading should cover as many samples as possible. Common graders include rule validation (JSON Schema, regular expressions, enumerations), execution validation (compilation, unit tests, static checks), semantic similarity (used only when rules cannot be applied), and model-based review by another model (which requires correction for position bias and length bias).

    Human review is used for two types of samples: open-ended tasks that automation cannot grade, and samples where automated grading conflicts with business feedback. To reduce subjectivity, blind review, multiple reviewers, and disagreement arbitration are recommended, along with tracking reviewer agreement (such as the Kappa coefficient). Illustrative pseudocode:

    1. def evaluate(candidate, dataset):
    2. report = {}
    3. for item in dataset:
    4. out = candidate.generate(item.input, item.constraints)
    5. if item.grader.type == "schema":
    6. ok = validate_schema(out, item.grader.schema)
    7. elif item.grader.type == "unit_test":
    8. ok = run_tests(out, item.grader)
    9. else:
    10. ok = None # enters the human review queue
    11. report.setdefault(item.scene, []).append((item.id, ok, latency_ms(out)))
    12. return aggregate(report)

    5. Non-Functional Metrics and Cost: The Real Dividing Line in Engineering Selection

    Many teams compare only output quality and ignore engineering metrics, ultimately paying the price in production. The following items should be included in the same scorecard:

    • Latency structure: time to first token determines the interactive experience, while overall latency determines batch processing cost.
    • Throughput and rate limiting: concurrency capacity, queuing strategy under burst traffic, and backoff retry implementation.
    • Cost model: billing per task rather than per call is closer to the business, and hidden costs from retries, validation failures, and human fallback must be counted.
    • Stability: error rate, timeout rate, output format failure rate, and regressions caused by version changes.
    • Compliance and audit: log retention, data masking, regional deployment, key management, and content safety policies.

    For cloud deployment, these can be carried by general-purpose capability combinations: object storage holds evaluation sets and artifacts, a message queue handles asynchronous evaluation scheduling, a container platform hosts graders and load-testing scripts, and logging and monitoring services track latency and failure rates. Baidu AI Cloud offers capability forms in these general categories that are consistent with the industry, making it easier to standardize the evaluation pipeline.

    6. Selection Process: From Scenarios to Routing

    A four-step method is recommended:

    1. Scenario layering: split the business into high-frequency low-risk, high-frequency high-risk, and low-frequency high-value categories.
    2. Metric binding: bind a primary metric and guard metrics to each scenario category (for example, format validity rate as a guard item).
    3. Small-traffic validation: compare candidate models with shadow traffic and collect samples from the real distribution.
    4. Routing and fallback: route different scenarios to different models, and configure timeouts, retries, fallbacks, and default templates.

    Illustrative routing configuration:

    1. routes:
    2. - match: {scene: "json_extract", risk: high}
    3. primary: modelA
    4. fallback: modelB
    5. guard: {schema_valid: true, max_latency_ms: 2500}
    6. - match: {scene: "draft_text", risk: low}
    7. primary: modelB
    8. guard: {min_quality_score: 0.7}

    7. Common Pitfalls

    • Looking only at public leaderboards: leaderboard tasks differ greatly from the business distribution, and data contamination is a risk.
    • Testing only quality and not cost: retries and human fallback can significantly raise the cost per task.
    • Ignoring version drift: model-side updates can introduce regressions, so the L1 smoke set must be retained for continuous regression.
    • Over-relying on a single model: multi-model routing and fallback can significantly improve availability and negotiating leverage.
    • Non-verifiable metrics: metrics that cannot be graded automatically should be converted into executable checks or a clearly defined human process.

    8. Conclusion

    There is no single answer to “overall performance”—only the best combination for a given scenario. Building a closed loop of layered evaluation sets, automated grading, non-functional measurement, and routing with fallback is the only sustainable way to make technical decisions. Teams should treat evaluation as a long-term engineering asset rather than a one-time activity; only by building a standardized pipeline on top of general-purpose cloud capabilities can they maintain stable delivery quality in an environment where models iterate rapidly.