Large Language Model Selection: A Scenario-Driven Evaluation Framework

    Choosing a large language model (LLM) by leaderboard rank often fails because model capability is not a single scalar and real tasks have orthogonal requirements. This article presents a scenario-driven framework: decompose capability into four dimensions (code generation and engineering understanding, general tasks and tool ecosystems, multimodal and long context, real-time data and external knowledge), design metrics and thresholds per task family, run comparisons both with and without retrieval augmentation, model total cost as a function of token usage, retrieval, retries, human review and migration, and manage non-functional risks such as account stability, identity verification, data boundaries, vendor replaceability and fallback plans. It closes with a repeatable six-step selection process that turns model replacement from a high-risk decision into a routine parameter change.

    1. Why Rank-Based Selection Fails

    In engineering practice, model capability is not a single scalar. Ranking different models on one leaderboard assumes that all tasks demand the same kind of capability. Real business needs are the opposite: code completion depends on symbol consistency within long context, document writing depends on natural style and structural stability, mixed image-text moderation depends on cross-modal alignment accuracy, and public opinion analysis depends on data freshness. These requirements are largely orthogonal, so any “overall first place” conclusion can be overturned in a specific scenario.

    A more reasonable approach is to treat selection as a multi-objective decision problem: first define task families, then set key metrics and thresholds for each family, and finally compare cost and operational overhead among the candidates that meet the thresholds.

    2. Four Capability Dimensions and Metric Design

    2.1 Code Generation and Engineering Understanding

    The core of a code task is not whether a model can produce a snippet, but whether it can produce a mergeable change under the constraints of an existing repository. A layered evaluation is recommended:

    • Syntax and unit test pass rate: use the pass ratio of automatically generated test cases as a baseline;
    • Defect fix success rate: given an issue description and a repository snapshot, measure whether the patch actually closes the issue;
    • Cross-file consistency: check whether new symbols, interface signatures and dependency references match existing project conventions;
    • Regression introduction rate: measure the share of patches that break existing tests; this is often ignored but has the largest impact on the developer experience.

    A sketch of the evaluation skeleton (pseudocode, illustrating the flow rather than concrete APIs):

    1. def evaluate_patch(model, repo_snapshot, issue):
    2. patch = model.generate(issue, context=repo_snapshot)
    3. if not applies_cleanly(patch, repo_snapshot):
    4. return {"applied": False}
    5. before = run_tests(repo_snapshot)
    6. after = run_tests(apply(patch, repo_snapshot))
    7. return {
    8. "applied": True,
    9. "target_passed": issue.target_test in after.passed,
    10. "regression": set(before.passed) - set(after.passed),
    11. }

    Code capability depends heavily on context window size and retrieval quality. When the repository exceeds the window capacity, the retrieval recall strategy often matters more than differences between models. Evaluation must therefore be run under two conditions: with and without retrieval augmentation.

    2.2 General Tasks and Tool Ecosystems

    General scenarios reward the floor, not a single peak. A practical criterion: randomly sample 100 requests from the team’s real ticket set, then measure the “first-pass usability rate” (the share accepted without manual rewriting) and the “severe error rate.” The former measures the floor; the latter measures risk.

    Tool-calling capability should be evaluated separately, focusing on three things: accuracy of parameter extraction, termination judgment in multi-step calls, and self-correction after failures. Call traces can be recorded as a state machine to compute average step count and the share of ineffective calls.

    2.3 Multimodal and Long Context

    Multimodal evaluation must separate recognition from reasoning: the first asks what is in the image, the second asks whether the relationships in the image are self-consistent. It helps to build scenes containing distractors and observe whether the model produces descriptions that look plausible but are factually wrong. For long context, watch for the “middle-of-context forgetting” effect: place key information at the beginning, middle and end separately, and compare recall.

    2.4 Real-Time Data and External Knowledge

    For time-sensitive business, whether a model is connected to the internet is not the key; whether the retrieval pipeline is controllable is. Decoupling external data acquisition from the model is recommended: the business side maintains knowledge snapshots through a message queue and a cache layer, and the model is responsible only for understanding and expression. This reduces uncertainty and makes data provenance auditable.

    3. Cost Model: Put the Bill on the Architecture

    Unit price comparisons are of limited value. Real cost has four parts: input and output token consumption, retrieval and vector storage, retries and human review, and migration cost. A practical estimate:

    1. cost per task ≈ (input tokens × input price + output tokens × output price)
    2. + retrieval overhead + retry count × cost per task + human review labor cost

    Three paths can reduce cost in engineering: first, prompt and context trimming to remove duplicated fragments; second, tiered routing, using a lightweight model for simple requests and escalating only complex requests to a high-capability model; third, result caching, building a semantic-level cache for frequent repeated requests. The routing logic can be simplified as:

    1. def route(request):
    2. if request.estimated_tokens < 2000 and request.complexity == "low":
    3. return lightweight_model
    4. if request.requires_tool_chain:
    5. return agent_capable_model
    6. return default_model

    4. Risk Control and Compliance Checklist

    Selection must assess non-functional risk at the same time. A fixed set of checks is suggested:

    • Account and access stability: an unstable network egress or frequent region changes may trigger risk controls, so production should use a fixed compliant egress and a credential hosting scheme;
    • Identity verification requirements: some services add extra verification steps, so the workflow should reserve a branch for human intervention;
    • Data boundaries: define which data may leave the domain, mask sensitive fields at the gateway layer, and keep call audit logs;
    • Vendor replaceability: wrap model calls behind a unified abstraction layer so business code is not coupled to one provider’s interface details;
    • Fallback plan: set timeout, rate limiting and backup model policies to keep core paths available.

    A sketch of the unified abstraction layer:

    1. class ModelGateway:
    2. def call(self, task, payload):
    3. provider = self.select(task) # select the backend per routing policy
    4. try:
    5. return provider.invoke(payload)
    6. except (TimeoutError, RateLimited):
    7. return self.fallback.invoke(payload)

    5. A Practical Selection Process

    1. Build a task inventory: list real business scenarios, call volume, latency requirements and compliance level;
    2. Build a private evaluation set: at least 50 items per scenario, with reference answers and scoring rules, combining human and automated scoring;
    3. Run a two-condition comparison: score with and without retrieval augmentation so retrieval gains are not mistaken for model capability;
    4. Run a small-traffic canary: validate first-pass usability and error distribution with 5% of traffic;
    5. Lock in a cost dashboard: bring token consumption, retry rate and human review rate into monitoring and alerting;
    6. Re-evaluate quarterly: model capability keeps evolving, so the evaluation set and thresholds must iterate with it.

    6. Conclusion

    There is no universally optimal solution across scenarios, only a fit between the solution and the task structure. What a team should accumulate is not one selection conclusion but a repeatable evaluation framework: task layering, quantified metrics, two-condition comparison, cost modeling, a risk checklist and a unified access abstraction. Once this mechanism is in place, replacing a model degrades from a high-risk decision into a routine parameter adjustment. If an organization wants to reduce the burden of building its own evaluation and operations, it can rely on general capabilities from Baidu AI Cloud, such as container platforms, log services, monitoring and alerting, and object storage, to quickly set up a model gateway and an evaluation pipeline and focus effort on the business metrics themselves.