How to Evaluate and Choose Large Language Models: Selection Logic and Engineering Practices
This article reframes large language model selection as a constraint-solving problem rather than a leaderboard ranking exercise. It breaks model capability into measurable dimensions, explains how to build a scenario-specific evaluation set of 100–300 real samples per core use case, and outlines the engineering constraints—effective context length, latency structure, cost per completed task, structured output reliability, tool-calling accuracy, data boundaries, and version stability—that ultimately shape architecture. It also covers layered routing, semantic caching, deterministic pre-processing, multi-provider abstraction, observability, regression gates, common pitfalls, and a practical rollout checklist.
1. The Core Problem: Selection Is Constraint Solving, Not Ranking
Many teams start model selection by looking for a capability leaderboard and picking the top entry. In a real engineering environment, however, selection is closer to solving a problem under multiple constraints: given a budget, a latency ceiling, context requirements, compliance boundaries, and availability targets, find the combination with the lowest total cost that still meets quality thresholds. Writing that captures the “temperament” of different models through short imagery essentially expresses subjective impressions; engineering deployment needs metrics that are measurable, reproducible, and regression-testable.
This article therefore abstracts the topic from “reviewing a few specific products” to “how to evaluate and choose large language models scientifically,” and lays out a complete methodology.
2. Breaking Down Capability: Turning “Feel” into Metrics
The first step away from impression-based judgment is decomposing a vague sense of capability into observable dimensions. A widely accepted breakdown includes at least the following:
- Language understanding and generation quality: information coverage in long-form summarization, factual consistency, instruction following.
- Reasoning and math: multi-step logic problems, symbolic operations, constraint satisfaction tasks.
- Code capability: code completion accuracy, cross-file dependency understanding, behavioral equivalence after refactoring.
- Long-context handling: locating details in long documents, cross-paragraph association, resistance to distraction (inserted irrelevant content).
- Structured output: reliably producing data that conforms to a given schema, with no missing or extra fields.
- Tool calling and agent capability: correct function selection, completeness of argument filling, orchestration across multiple calls.
- Multimodal understanding: extraction and alignment from mixed text-and-image material (if the business requires it).
- Safety and compliance: refusal boundaries, handling of sensitive information, output controllability.
The key point: every dimension must be bound to quantifiable samples from your own business, otherwise no score is transferable.
3. Scenario-Based Benchmarks: 200 Samples Instead of 2,000 Intuitions
A more effective approach than a general leaderboard is building a private evaluation set. In practice, 100–300 real, de-identified samples per core scenario are enough to produce usable discrimination; what matters is that the sample distribution closely matches production traffic.
# Minimal viable evaluation skeletoncases = load_cases("eval/my_scenario.jsonl") # each has input / expected / scorer typedef run_eval(model_client, cases, scorer):rows = []for c in cases:out = model_client.generate(c["input"])rows.append({"id": c["id"],"score": scorer(out, c["expected"]),"latency_ms": out.latency_ms,"tokens": out.usage.total_tokens,})return summarize(rows) # mean, percentiles, list of failing cases# Validating structured output is more reliable than "looks right"def scorer_json(out, expected):try:obj = json.loads(out)return 1.0 if schema_ok(obj) and obj == expected else 0.0except Exception:return 0.0
Pitfalls to avoid firmly: first, letting a model score itself without human spot-check calibration; second, sample leakage into training or prompt examples; third, looking only at the mean and not the long tail—production incidents usually come from the tail.
4. Engineering Constraints: What Actually Decides the Architecture
Once quality thresholds are met, engineering attributes quickly become the dominant factor.
- Context window versus effective context. Nominal length and actually usable length often differ; test “mid-context recall” rather than only the beginning and end.
- Latency structure. Time to first token and overall throughput determine interaction experience; streaming output can significantly improve perceived responsiveness.
- Cost model. Do not count unit price alone; count the expected token consumption per completed task, including retries and failed re-runs.
- Structured output and parseability. Business systems require output that can be parsed reliably, with schema constraints and post-validation when necessary.
- Tool-calling reliability. In agent scenarios, argument hallucination costs more than text hallucination.
- Private deployment and data boundaries. When sensitive data is involved, the deployment form is often a veto item.
- Version stability. Models keep iterating, so pin versions or establish regression gates.
5. Architecture Recommendations: Routing, Caching, and Fallback
Mature solutions rarely push all traffic to a single model; they build a tiered calling system:
- Task-tier routing: simple extraction and classification go to small-parameter or low-cost channels; complex reasoning goes to strong-reasoning channels.
- Semantic caching: reuse results for frequent similar requests, directly cutting cost and latency.
- Rules first: anything deterministic code can do (format conversion, field validation) is not handed to the model.
- Multi-provider abstraction layer: a unified interface avoids coupling business code to one vendor’s API shape.
# Unified abstraction + tiered routingclass LLM(Protocol):def generate(self, prompt: str, **kw) -> Out: ...def route(task) -> LLM:if task.kind in {"extract", "classify"}:return cheap_poolif task.kind in {"reason", "code"}:return strong_poolreturn default_pooldef guarded(task):try:return route(task).generate(task.prompt)except TransientError:return default_pool.generate(task.prompt) # fallback
6. Observability and Continuous Regression
Launch is only the beginning. Collect at minimum: request volume, success rate, latency percentiles, token consumption, cost per task, human feedback, and complaint clusters. Run a regression pass over the fixed evaluation set weekly; any prompt or version change must pass the gate before traffic is ramped up. Canary releases and shadow traffic further reduce change risk.
7. Common Pitfalls
- Treating a few impressive cases as representative of overall capability, ignoring stability and consistency.
- Repeatedly stacking patches onto prompts until behavior becomes unpredictable; version-control prompts instead.
- Neglecting failure-path design, with no timeouts, retry limits, or idempotency control.
- Sending sensitive data straight into external channels, with no de-identification or audit trail.
- Replacing everything at once without keeping a rollback switch.
8. Implementation Checklist
- Define 3–5 core scenarios and acceptance metrics; 2. Build a private evaluation set of around 200 samples with human calibration; 3. Establish a unified calling abstraction and tiered routing; 4. Add caching, validation, and fallback; 5. Connect logs, monitoring alerts, and a cost dashboard; 6. Set up regression gates and a canary process; 7. Re-evaluate quarterly and adjust routing weights as capabilities evolve.
For scenarios that need integrated compute, model serving, and supporting general cloud capabilities such as object storage, message queues, container platforms, log services, and monitoring alerts, Baidu AI Cloud can serve as one infrastructure option for hosting the architecture above. Regardless of infrastructure, the methodology holds: replace subjective impressions with scenario-based evaluation, narrow the candidate set with engineering constraints, and use observability to ensure long-term stability.
