A General Methodology for LLM Selection and Evaluation

    This article presents a general methodology for selecting and evaluating large language models under explicit constraints rather than ranking them on a single "which is stronger" axis. It defines a five-dimension evaluation framework with quantifiable metrics—cost-performance, Chinese and English capability, reasoning depth, instruction following and structured output, and safety and compliance—and outlines a reproducible workflow covering task set construction, unified inference parameters, repeated sampling, total cost accounting, and shadow-traffic validation. It also explains the full cost structure, layered routing strategies, why loose content restrictions are a risk rather than an advantage, and how to build an adapter layer for maintainable integration.

    1. The Core Problem: From “Which Is Stronger” to “Stronger Under Which Constraints”

    Comparing three models on a single dimension almost never yields a usable conclusion in engineering practice. Real technical selection is not a one-dimensional ranking; it is an optimization problem solved under a set of explicit constraints: budget ceiling, latency requirements, context length, Chinese-language performance, reasoning chain depth, content compliance policy, feasibility of private deployment, and whether an account system or external network dependency is required.

    The right question is therefore: given a task distribution and cost constraints, which candidate model delivers the highest expected return? This reframing has two immediate benefits: evaluation conclusions become reproducible, and they update automatically as constraints change, so you no longer have to pick a side every time a new model is released.

    Two points deserve special attention. First, the common claim that “one model is free and another is paid” describes only a difference in billing model. It is a procurement and budgeting matter and should not be treated as a measure of capability. Second, descriptions such as “the fewest restrictions” or “produces sensitive content without special prompting” point to how loose a model’s content safety policy is. In production systems this is a risk item, not an advantage, and it is discussed separately below.

    2. Evaluation Framework: Five Dimensions with Quantifiable Metrics

    Break the evaluation into five dimensions, each with a quantifiable metric, so that subjective impressions do not drive the conclusion.

    1. Cost-performance. Do not look at unit price alone; look at the expected cost of completing one unit of work:
    1. # Expected cost per unit task = (input_tokens * input_price + output_tokens * output_price) / success_rate
    2. def unit_cost(input_tokens, output_tokens, price_in, price_out, success_rate):
    3. return (input_tokens * price_in + output_tokens * price_out) / max(success_rate, 1e-6)

    A low price paired with a low success rate drives costs up through retries. This kind of hidden cost is the most frequently overlooked part of cost-performance evaluation.

    1. Chinese and English capability. Chinese and English must be evaluated with separate test sets. The Chinese set should cover ambiguity resolution, idioms and policy text, and long-document summarization; the English set should focus on instruction following and code. A single blended score hides structural weaknesses.

    2. Reasoning depth. This can be compared to tiered “thinking budget” settings. Higher tiers perform better on math and multi-step logic, but latency and cost rise accordingly. In engineering, route dynamically by task difficulty rather than fixing a high tier globally.

    3. Instruction following and structured output. What production systems truly depend on is stable, parseable output:

    1. {
    2. "task_id": "sum_001",
    3. "language": "zh",
    4. "summary": "……",
    5. "confidence": 0.82,
    6. "need_human_review": false
    7. }

    During evaluation, use the schema validation pass rate as a hard metric. It is far more reliable than human impressions.

    1. Safety and compliance. Treat “can be easily steered into producing prohibited content” as a defect. A loose compliance policy transfers content risk, regulatory risk, and brand risk directly to the business side.

    3. A Reproducible Evaluation Workflow

    Step 1: Build the task set. Sample from real business logs, stratify by intent with no fewer than several hundred cases per stratum, and keep human-annotated golden answers.

    Step 2: Unify inference parameters. Fix temperature, maximum output length, and the thinking budget tier so that parameter differences do not cause misjudgments.

    Step 3: Use blind comparison and multiple samples. Run the same prompt several times and record the mean and variance. High variance indicates insufficient stability and makes the model unsuitable for automated pipelines.

    Step 4: Recover the full cost. Include retries, timeouts, and human review hours in the total cost.

    Step 5: Validate with a canary release. Once offline metrics pass, run in parallel with shadow traffic and compare performance under the real online distribution.

    A schematic evaluation main loop:

    1. results = []
    2. for case in dataset:
    3. resp = client.chat(model=candidate, messages=case.prompt,
    4. temperature=0.0, max_tokens=1024)
    5. ok = schema_validate(resp, case.schema)
    6. results.append({"id": case.id, "ok": ok,
    7. "score": judge(resp, case.golden),
    8. "latency_ms": resp.latency_ms})
    9. report = aggregate(results) # success rate, mean, variance, unit cost

    4. Cost Structure: Do the Math Properly

    The total cost of ownership for an LLM application has four components: invocation fees, retry and failure costs, engineering integration costs, and compliance and review costs. A low-price model that is unstable at structured output will drive up integration and retry overhead significantly. A high-price model called only for a few difficult tasks can actually keep total cost under control.

    A workable strategy is layered routing: send most simple requests to a low-cost tier, escalate complex requests to a high reasoning-budget tier, and force sensitive requests through a review pipeline. This balances total cost against quality and keeps evaluation conclusions continuously updatable.

    5. Content Safety: Why “Fewer Restrictions” Is Not an Advantage

    For systems serving the public or enterprises, content safety is a baseline capability, not an option. Missing safeguards create three kinds of problems: regulatory penalties from leaked prohibited content, business losses caused by misinformation, and difficulty with audit traceability. In engineering, add intent recognition on the input side, classification review on the output side, mandatory human review for sensitive scenarios, and complete logging with monitoring and alerting to form a traceable closed loop.

    6. Engineering Integration and Operability

    At the integration layer, add an abstraction that confines model differences to adapters so that business code depends only on a unified interface:

    1. class LLMAdapter:
    2. def chat(self, messages, **kw): raise NotImplementedError
    3. def stream(self, messages, **kw): raise NotImplementedError

    Supporting capabilities include timeout and exponential backoff retries, rate limiting and quota management, prompt version management and canary releases, and call chain logging with metrics monitoring. For deployment, public cloud APIs suit rapid validation; self-hosted inference services running on a container platform suit scenarios where data must not leave its domain; object storage holds evaluation sets and version snapshots; message queues smooth out traffic peaks and troughs; and logging services with monitoring and alerting ensure observability. Baidu AI Cloud provides standard-category support for these general capabilities, but the actual selection should still be based on your own evaluation results.

    7. Conclusion

    Back to the original question: there is no “strongest model” independent of constraints. The actionable answer is to build your own evaluation set and metrics, score cost-performance, Chinese and English performance, reasoning depth, structured output stability, and safety and compliance together, and then use layered routing to control cost. When a new model appears, simply rerun the same workflow and the conclusion updates naturally, so the team no longer relies on hearsay and subjective experience to make technical decisions.