LLM Selection: Finding the Optimal Balance Between Capability and Speed

    Debates over how to evaluate a large language model often reach opposite conclusions even when people are using the same model, which shows that usability depends on task fit, invocation method, response speed, and cost rather than on a model's inherent quality. This article reframes model evaluation as a search for the overall optimal combination under a specific task set and constraints. It covers four dimensions—capability, efficiency, cost, and maintainability—and shows how to stratify scenarios, build a self-built evaluation set, measure speed and throughput, and calculate cost per successful delivery. It also explains why tool frameworks and prompt engineering matter, provides a four-week evaluation roadmap, describes a scenario-based routing strategy, and lists common pitfalls to avoid.

    In developer communities, discussions about “how to evaluate a given large language model” rarely stop. Opinions tend to split in two directions: some find a model “a bit awkward,” hard to place in any scenario where it is indispensable; others showcase long technical lectures they produced with the same model and speak highly of its capabilities. Two groups use the identical model yet reach opposite conclusions. This tells us that “usability” is not an inherent property of a model, but the result of model capability, invocation method, task type, response speed, and cost budget acting together. This article abstracts and reconstructs the common problems behind these debates and offers practical evaluation and selection methods.

    1. Capability Is Not an Absolute Score, but “Task Fit”

    Abstracting the typical community viewpoints yields at least the following signals:

    1. Interaction form determines output quality: The same model running in different coding tools can produce noticeably different results. This is because how context is organized, how tools are defined, and how failures are retried all significantly affect the final output.
    2. Speed is a hard constraint: Tasks such as executing code, fixing defects, and generating scripts are highly sensitive to response latency. If a comparable model completes the same work end-to-end in roughly one-tenth of the time, then even if the slower model wins slightly on a few tasks, it is hard to find a scenario where you must choose it.
    3. Long tasks require cost accounting: Someone used a single prompt to have a model produce a proof of a math theorem with no ready-made solution and output a well-structured lecture. The quality was satisfying, but the run consumed a meaningful share of the monthly quota.
    4. Self-hosting changes the cost structure: As the compute density of high-performance inference servers keeps rising, the internal marginal cost of self-hosting large models may be significantly lower than pay-as-you-go API prices. Model competition therefore extends from “whose API is cheaper” to “how to weigh building against buying.”
    5. Capability ranking depends on the task: On high-difficulty, open-ended reasoning tasks, the strong-to-weak ordering between models is inconsistent with the experience ordering in everyday tasks. So discussing “leaderboards” detached from the scenario has limited value.

    Combining these signals gives one core judgment: evaluating a model is not about finding the single “most capable” one, but about finding the “overall optimal” combination under a specific task set and constraints. An evaluation should cover at least four dimensions: capability (task completion quality), efficiency (end-to-end latency and throughput), cost (spending per successful delivery), and maintainability (stability after a model update).

    2. Scenario Stratification: Aligning Metrics with Real Work

    Before evaluating anything, you need to turn “is the model good?” into “in which scenario, measured by which metric?” Common development scenarios fall into three categories:

    Scenario Typical Work Key Metrics
    Code execution Code completion, defect fixing, refactoring, test writing Compile/test pass rate, manual rework rate, end-to-end latency
    Long-chain reasoning Math proofs, long technical lectures, complex solution design Conclusion correctness, reasoning verifiability, token consumption
    Brainstorming Solution divergence, technology-selection alternatives, naming and documentation drafts Idea diversity, feasibility, subjective satisfaction

    The three categories place very different demands on a model. Code execution tasks emphasize being “accurate” and “fast”: errors are quickly exposed by compilers and tests, the feedback loop is short, and being several times slower noticeably drags down efficiency. Long-chain reasoning tasks emphasize being “deep” and “stable”: a single inference may run for minutes, requiring strong long-context retention and the ability to self-check and self-correct when no standard answer exists. Brainstorming tasks emphasize being “broad” and “smooth”: they are more sensitive to single-response speed and less demanding on absolute accuracy.

    Within a single scenario you can stratify further: code tasks split into three difficulty levels—“single-file completion,” “cross-file modification,” and “defect localization and fixing”—which respectively probe a model’s local understanding, global correlation, and causal analysis.

    3. Capability Evaluation: From Public Leaderboards to a Self-Built Evaluation Set

    (1) The Value and Limitations of Public Leaderboards

    Public leaderboards are convenient for quickly grasping a model’s overall level, but they have three limitations. First, data contamination: if evaluation questions or highly similar content appear in training data, scores inflate. Second, task-distribution shift: leaderboard questions often differ greatly from a team’s real codebase in language, framework, and business domain. Third, missing interaction form: leaderboards usually examine only single-turn generation and cannot reflect a model’s ability to execute multi-step tasks continuously in an agent environment with tool calls. Leaderboards are therefore suitable for initial screening, but not as the basis for a final decision.

    (2) Five Principles for Building a Self-Built Evaluation Set

    • Stay close to reality: Extract real tasks from ticketing systems, code review records, and historical defects, with proper anonymization, to avoid questions that “look doable but aren’t in practice.”
    • Make it automatically judgeable: Use unit tests, compile results, and static checks as objective criteria for code tasks; prefer math and proof questions whose answers can be compared automatically; use multi-person blind review for highly subjective tasks.
    • Stratify by difficulty: Divide questions across easy, medium, and hard proportions, and avoid diluting the set with simple questions.
    • Keep it privately isolated: Reserve a portion of questions that are never made public as a regression set, reducing the risk of coverage by training data.
    • Ensure statistical reliability: Have enough questions to support a conclusion. Small gaps between models may be nothing more than random fluctuation on a small sample.

    (3) Key Metrics

    Beyond “first-pass rate,” consider adding these metrics: whether the code introduces regressions (new changes breaking existing functionality), average interaction turns (how many times the agent goes back and forth with tools to finish a task), tool-call error rate, the verifiability of citations and facts, and the time variance of generated results.

    (4) Evaluation Script Skeleton

    The following pseudocode shows the basic structure of the evaluation loop. In practice, you can commit the evaluation code to the repository, plug it into a continuous-integration pipeline, and uniformly wrap the model-invocation interface so candidate models can be swapped easily later:

    1. def evaluate(client, cases):
    2. records = []
    3. for case in cases:
    4. started = time.perf_counter()
    5. result = client.run_agent(
    6. prompt=case.prompt,
    7. tools=case.tools, # tools matching the production environment
    8. max_turns=case.max_turns,
    9. seed=case.seed, # fixed random seed to guarantee reproducibility
    10. )
    11. elapsed = time.perf_counter() - started
    12. passed = case.verifier(result.output) # objective criteria: compile/test/answer comparison
    13. records.append({
    14. "case_id": case.id,
    15. "passed": passed,
    16. "turns": result.turns,
    17. "latency_s": round(elapsed, 2),
    18. "tokens_in": result.tokens_in,
    19. "tokens_out": result.tokens_out,
    20. })
    21. return summarize(records)

    The summarize function is responsible for computing first-pass rate, median and P95 latency, average interaction turns, and cost per successful task, then outputting the results as a visualized report.

    4. Speed and Throughput: The Underestimated Key Dimension

    (1) Two Levels of Speed Metrics

    When calling an LLM API, speed metrics include time to first token (TTFT) and generation throughput (output tokens/s). These two determine how long users wait before seeing the first character and how fast the remaining content flows out. In agent scenarios, you also need end-to-end latency—the time from task initiation to full completion—usually described by the median (P50) and 95th percentile (P95).

    (2) The Speed Amplification Effect in Multi-Turn Tasks

    In a single turn, a difference of a few seconds seems tolerable, but in a multi-turn agent this gap is multiplied. Suppose a complete coding task needs an average of 15 model calls; two comparable models take 30 seconds and 3 seconds per generation respectively, so the end-to-end time is about 7.5 minutes versus 45 seconds. The former will almost certainly break a developer’s flow, while the latter fits into a tight “modify—verify—modify again” loop.

    It is precisely the speed gap that strips “slightly stronger capability” of its meaning in real workflows.

    (3) Throughput Testing Under Self-Hosting

    For self-hosted scenarios, the focus shifts from single-request latency to concurrent throughput. Throughput is affected by batch size, number of concurrent requests, input and output length, numerical precision, decoding strategy, and the KV-cache capacity in memory. The peak throughput measured on a single hardware node may differ greatly from the sustained throughput of a fully loaded rack under real traffic. Recommended practices:

    • Run stress tests with input and output lengths close to the production distribution;
    • Increase concurrency gradually and plot a “concurrency—throughput—latency” curve to find the inflection point where latency is still acceptable;
    • If you adopt acceleration techniques such as speculative decoding or quantization, you must also evaluate whether task quality drops, avoiding a situation that is “faster but wrong.”

    5. Cost and Compute Economics: Cost per Successful Delivery

    (1) From Token Price to Task Cost

    Under token-based billing, a seemingly cheap model is not necessarily more economical. The metric that truly matters is “cost per successful delivery.” It equals the total token spending per task (including retries after failures) divided by the number of tasks that pass on the first attempt:

    1. def cost_per_success(records, price_in, price_out):
    2. total_cost = sum(r["tokens_in"] * price_in + r["tokens_out"] * price_out
    3. for r in records)
    4. successes = sum(r["passed"] for r in records)
    5. return total_cost / successes if successes else float("inf")

    For example, task A consumes an average of 6000 input tokens and 1200 output tokens per call with a 60% success rate, and every retry repeats the input consumption; task B has the same input and output but an 85% success rate. The total tokens needed for one successful delivery of task A is roughly 1.7 times that of task B. A unit-price advantage is easily offset by retry overhead.

    (2) Cost Management for Long-Chain Reasoning

    Long-task costs rise for three main reasons: the inference process itself consumes a considerable number of tokens; tool-using long tasks repeatedly carry the system prompt and tool definitions; and context keeps accumulating, so input length grows. Corresponding control measures include:

    • Enable prefix caching first, to avoid re-billing duplicated content;
    • Execute long tasks in segments with a token budget;
    • Summarize intermediate results before moving to the next phase;
    • Keep a human-review step for high-risk outputs.

    (3) Self-Hosted Inference vs. On-Demand Calling

    Self-hosted inference can have a lower unit cost when demand is stable and utilization is high, and the data can stay in your own environment; the tradeoff is that hardware procurement, capacity planning, operations, and model upgrades all fall on you. On-demand calling offers good elasticity and fast startup, but under high usage the cumulative spending may exceed a self-hosted setup. Enterprises can build a simple break-even model: compare the total cost of a given monthly call volume under both approaches, then combine demand fluctuations and compliance requirements to make a phased decision.

    (4) Making Good Use of General Cloud Capabilities

    Whether you self-host or purchase, the general capabilities of a cloud platform can make evaluation and launch smoother. For example:

    • Use container platforms to spin up isolated evaluation environments quickly and reproduce consistent runtime conditions;
    • Use object storage to centrally manage evaluation datasets and their versions;
    • Use logging services to retain the complete call chain of each request;
    • Use monitoring and alerting to continuously track trends in success rate, latency, and token consumption.

    These capabilities have corresponding general categories in the product portfolios of Baidu AI Cloud and mainstream cloud providers, and can be flexibly combined according to your team’s existing tech stack.

    6. Beyond the Model: Tool Frameworks and Prompt Engineering Matter Too

    Earlier we noted that the same model performs noticeably differently in different coding tools. This means the object of evaluation should not be “the model” alone, but the whole of “model + tool framework + prompt strategy.” With the model held fixed, verify the following improvements in order:

    1. Structured prompts: State the role, goal, constraints, and output format clearly, and provide positive and negative examples.
    2. Tool design: Keep tool descriptions clear, parameters minimal, and error messages readable, so the model can self-correct based on feedback.
    3. Context management: Inject only task-relevant files and symbols, avoiding irrelevant information that dilutes attention.
    4. Execution sandbox: Run generated code in a controlled environment, automatically capturing compile and test feedback to form a “generate—execute—fix” loop.
    5. Retry strategy: Set a maximum number of retries and a timeout threshold to prevent falling into ineffective loops.

    Only after completing these optimizations and then comparing different models will the evaluation results be comparable.

    7. Implementation Roadmap: A Complete Evaluation in Four Weeks

    • Week 1 (scenario mapping): Tally the task-volume share of each scenario and set evaluation weights, so effort is not poured into low-frequency scenarios.
    • Week 2 (evaluation-set construction): Extract and anonymize data from history, build layered questions, write automatic judgment scripts, and complete multi-person blind-review labeling.
    • Week 3 (baseline evaluation): Test 3 to 5 candidate models under a unified tool framework and prompt strategy, running each model at least 3 rounds while recording both capability and efficiency metrics.
    • Week 4 (decision and consolidation): Produce a comparison report, define a “scenario-based routing” strategy, and plug the evaluation set into the continuous-integration pipeline so it runs an automatic regression after each model version update.

    8. Scenario-Based Routing: From “Either-Or” to “Combined Use”

    The ultimate goal of evaluation is not to crown a single winner, but to establish a routing strategy. The basic idea: use capable models to tackle high-value, high-difficulty tasks, and fast models to handle high-frequency, low-risk tasks. The following pseudocode shows a simplified routing logic with confidence and retry mechanisms:

    1. def route(task):
    2. for attempt in range(MAX_RETRIES):
    3. model = STRONG_MODEL if task.risk == "high" else FAST_MODEL
    4. result = model.run(task.prompt, tools=task.tools)
    5. if result.confidence >= THRESHOLD and task.verify(result):
    6. return result
    7. # low confidence or failed verification: upgrade the model and retry with feedback
    8. task = task.with_feedback(result.feedback)
    9. return escalate_to_human(task)

    After the routing strategy goes live, you also need to continuously observe the actual distribution across strata and adjust thresholds regularly, so that simple tasks are not wrongly assigned to high-cost models and high-risk tasks are not carelessly let through.

    9. Common Pitfalls and Avoidance Tips

    • Leaderboard-only thinking: Leaderboards are only for initial screening; rely on your self-built evaluation set for the final call.
    • Speed-only thinking: Speed must rest on quality meeting the bar; otherwise it is just “making mistakes faster.”
    • One-time evaluation: Models keep iterating, so evaluation should form a “monthly regression” mechanism.
    • Ignoring failure cost: The hidden cost of retries, rollbacks, and manual rework is often underestimated.
    • Ignoring stability: When repeated runs of the same task vary too much, it raises the difficulty of system integration and automation.
    • Ignoring compliance: When sensitive code or data is involved, the deployment form often determines your options before model scores do.

    Conclusion

    Back to the question at the start: the “awkwardness” of an “awkward” model does not lie in the model itself, but in the fact that it has neither built an overwhelming speed advantage nor established a clear enough barrier on the high-difficulty tasks where others are weak. For developers, a more valuable question than “which model is the strongest” is: “Under my task set, latency requirements, and budget constraints, which combination yields the lowest cost per successful delivery?” Build a sustainable four-dimensional evaluation system—starting with scenario stratification, centered on a self-built evaluation set, constrained by speed and cost, and safeguarded by continuous regression—and model selection turns from a one-time subjective judgment into a quantifiable, reproducible, continuously optimizable engineering practice.