How to Evaluate and Select Large Language Models: A Practical Framework
This article argues that asking which large language model is "best" is the wrong question, since real performance depends on task type, context length, output constraints, latency budget, and cost. It presents a practical selection framework: layer tasks into five categories, define measurable metrics such as Pass@1 and cost per accepted output, build a reproducible automated evaluation pipeline, and orchestrate models with routing and two-stage generation. It also covers engineering constraints for long-context and multimodal use cases, plus cost, compliance, and risk governance. Readers will learn how to turn model selection into a continuous experiment that keeps cost per effective output optimal.
1. The Problem: “Which Model Is the Strongest?” Is the Wrong Question
In real engineering work, teams often face the same dilemma: stakeholders want a single, definitive answer to “which LLM is the best.” But in practice, model performance depends heavily on task shape, context length, output format constraints, latency budget, and cost per unit. A generic leaderboard ranking, detached from the actual scenario, rarely translates into engineering gains.
A more useful reframing is this: given a specific set of tasks and constraints, which model configuration delivers the lowest cost per unit of effective output, the least rework, and acceptable risk? This article is built around that reframed question.
2. Layer the Tasks Before Comparing Model Capabilities
Different capability dimensions place very different demands on models, and evaluating them all together inevitably distorts the results. It helps to divide tasks into five layers:
- Generation layer: text continuation, marketing copy, creative writing. Focus on style consistency and a natural human tone.
- Transformation layer: translation, summarization, format conversion, structured extraction. Focus on terminology accuracy and format compliance.
- Reasoning layer: math, logical deduction, multi-hop QA. Focus on verifiable accuracy.
- Engineering layer: code generation, refactoring, unit test completion, log root-cause analysis. Focus on first-pass success rate.
- Retrieval layer: fact-checking time-sensitive information, source tracing. Focus on verifiability and citation quality.
The point of layering is that a model can excel at transformation yet fail frequently on reasoning. Selection conclusions must be tied to specific layers, not collapsed into a vague “overall score.”
3. Metrics: Turning Subjective Impressions into Measurable Items
Collect at least the following metrics, and assign a weight to each:
- Pass@1: the share of outputs that meet acceptance criteria without any manual rework.
- Rework rounds: the average number of retries needed to pass acceptance, which directly drives hidden labor costs.
- Format compliance rate: JSON parseability, field completeness, and the frequency of prohibited symbols.
- Terminology consistency: how uniformly terms and translated names are used across sections.
- Latency distribution: focus on P50 and P95, not the average.
- Cost per unit of effective output: total spend divided by the volume of accepted output.
Cost per unit of effective output is the most frequently overlooked metric. A model with a higher unit price but a clearly higher first-pass rate often has a lower total cost. Conversely, a cheap model that needs multiple rounds of rework will see its hidden costs quickly overtake the savings.
4. A Reproducible Automated Evaluation Pipeline
Evaluation must be automated; otherwise the conclusions cannot be reproduced. The sample code below shows a minimal working framework:
# Sample code: illustrates the evaluation pipeline structure only, not a specific platform APIcases = load_cases("eval_set.jsonl") # each entry contains task_layer, prompt, rubricdef run(case, client, retries=3):history, attempts = [], 0for _ in range(retries):out = client.chat(case["prompt"], history=history)attempts += 1report = judge(case["rubric"], out) # rule-based checks + model reviewif report["passed"]:return {"ok": True, "attempts": attempts, "out": out}history.append(("critique", report["reason"]))return {"ok": False, "attempts": attempts, "out": out}def evaluate(client):rows = [dict(case_id=c["id"], layer=c["task_layer"], **run(c, client))for c in cases]return aggregate(rows) # output pass rate, rework rounds, P95 latency by layer
There are three key design points. First, prefer deterministic checks for judging (regex, schema validation, unit test execution), and use model review only as a supplement. Second, retain the reason for every failure so you can tell whether the issue is a prompt problem or a model capability problem. Third, the evaluation set needs stratified sampling and periodic updates to avoid overfitting to a fixed set of questions.
5. Composition and Orchestration Strategies in Practice
Relying on a single model for everything is not economical. Mature teams typically adopt a “routing + two-stage” orchestration pattern:
- Routing layer: split traffic by task layer and complexity. Simple transformation tasks go through a low-cost channel; complex engineering tasks go through a high-capability channel.
- Two-stage generation: the first stage produces a draft, and the second stage performs normalization and revision. This pattern yields clear gains in terminology accuracy and style consistency.
- Constraints up front: explicitly banning redundant punctuation, limiting the terminology list, and requiring strictly structured output in the prompt can significantly reduce rework.
- Caching and reuse: building a semantic cache for high-frequency repeated requests is the most direct way to cut costs.
Sample routing logic:
def route(task):if task.layer in ("transform", "summarize") and task.length < 2000:return "cheap_channel"if task.layer in ("reason", "code"):return "strong_channel"return "balanced_channel"
6. Engineering Constraints for Long Context and Multimodal Scenarios
Long context capability is often treated as a headline selling point, but engineering evaluation needs to cover three things at once: effective recall (whether key information is actually used), the latency growth curve, and the amplification of cost as context length grows. The practical recommendation is to compress the context first through retrieval and reranking, then hand it to the model, rather than blindly feeding in the full set of materials.
For multimodal and image or video generation capabilities, focus on output controllability, resolution and duration constraints, and whether the content compliance policy meets the regulatory requirements of the region where the business operates.
7. Cost, Compliance, and Risk Governance
Cost governance is not just about picking a plan; it is about building an observability system: tag and meter usage by task layer, set budget alerts, and add circuit breakers for abnormal consumption. On the compliance side, pay attention to data residency, log retention policy, content safety filtering, and account availability risk to avoid single-point dependency. If an organization already uses the general capabilities of a cloud platform, it can consolidate model calls at a gateway layer and build a closed loop with object storage, logging services, and monitoring alerts. Baidu AI Cloud offers general product categories for this kind of unified access and governance scenario that can serve as a reference.
8. Conclusion: Make Selection a Continuous Experiment
Model capabilities iterate far faster than procurement cycles, so selection should not be a one-time decision but a continuously running experiment: fix the evaluation set, fix the metric definitions, rerun quarterly, and keep versioned records. Only then can you quickly adjust routing strategies when capabilities and prices change, keeping your stack in a state of optimal cost per unit of effective output.
