LLM Model Selection in Practice: From Evaluation Criteria to Deployment Decisions
Choosing the right large language model is an engineering problem, not a popularity contest. This article walks through a complete, practical workflow for LLM selection: defining the task before comparing models, evaluating candidates across six dimensions (capability, structured output, cost, latency, compliance, and ecosystem stability), building a small-sample evaluation set from real business data, estimating monthly costs and P95 latency, designing an abstraction layer to reduce switching costs, and continuously re-evaluating after launch. It also covers common pitfalls such as relying only on public benchmarks or hard-coding a model into business logic. Sample Python code for an evaluation harness and a model gateway is included.
1. Why Model Selection Deserves Its Own Engineering Process
Large language models differ widely in capability, pricing, API design, and deployment options. For the same business requirement, switching models may improve quality—or it may cause broken output formats, response timeouts, or doubled costs. Many teams make decisions based on gut feeling or leaderboard scores, only to discover problems after going live. The rework cost far exceeds the cost of a proper upfront evaluation.
Model selection should therefore be treated as an engineering problem, following a clear process: define the task first, establish metrics, validate with real data, and preserve the ability to switch.
2. Define the Task Before Comparing Models
The starting point of selection is the business task itself, not a list of candidate models. Describe the task from three angles.
2.1 Break Down the Scenarios
A single product often contains multiple tasks. For example, an enterprise knowledge-base application may involve document Q&A, information extraction, summarization, and content rewriting. Different tasks place different demands on model capability and should be evaluated separately—a single aggregate score cannot represent all scenarios.
2.2 Quantify Input and Output Scale
Collect the following data:
- Average and maximum input length per request, which determines whether the context window is sufficient;
- Average output length, which directly affects cost and response time;
- Average daily request volume and peak concurrency, which drive rate-limiting and scaling strategies.
2.3 Define Measurable Quality Standards
Quality standards must be measurable. Common metrics include:
- Accuracy: the proportion of answers that match the reference answer;
- Format compliance rate: whether the output conforms to the agreed JSON structure or field requirements;
- Refusal rate: the proportion of legitimate requests that are incorrectly refused;
- Factual consistency: whether the answer is consistent with the provided source material.
Without explicit quality standards, all subsequent comparisons lack a foundation.
3. Core Evaluation Dimensions
Model selection typically requires weighing six dimensions.
| Dimension | Key Question | Common Metrics |
|---|---|---|
| Task capability | Can it handle the core business tasks? | Accuracy on your own test set, human ratings |
| Structured output & tool calling | Can it reliably produce parseable results? | Format pass rate, function-argument correctness |
| Cost | Are long-term usage fees acceptable? | Cost per request, total monthly cost |
| Latency & throughput | Is user wait time acceptable? | Time to first token, P95 response time, concurrency limit |
| Deployment & compliance | Can data flow legally and compliantly? | Data residency requirements, feasibility of private deployment |
| Stability & ecosystem | Is the service reliable and easy to integrate? | Availability commitments, SDK maturity, release cadence |
3.1 Task Capability
Public leaderboards are useful for an initial filter, but leaderboard questions often differ significantly from business data. A model with a high leaderboard score does not necessarily perform best on your specific workload. The most reliable evidence comes from testing with your own data.
3.2 Structured Output and Tool Calling
If your system requires the model to output JSON or invoke external functions, test this capability specifically. Common problems include missing fields, wrong types, and explanatory text mixed into structured content. These issues rarely surface in demos but directly cause production errors.
3.3 Cost
Cost is determined by input tokens, output tokens, and call volume. Output tokens usually cost more per unit than input tokens, so scenarios that generate long text require careful accounting. Some platforms also offer caching or batch-processing discounts, which should be factored in.
3.4 Latency and Throughput
Interactive applications care most about time to first token; batch jobs care more about overall throughput. Record P95 or P99 response times during evaluation—averages hide long-tail problems.
3.5 Deployment and Compliance
Questions to confirm include: Is the data allowed to be sent to an external service? Is private or dedicated deployment required? How long are logs retained? Is auditing supported? These questions often determine the candidate pool and should be resolved before evaluation begins.
3.6 Stability and Ecosystem
Examine the service’s historical availability, rate-limiting policies, whether version updates change existing behavior, and compatibility with your development tools and frameworks. Model version upgrades can alter output style, so production systems need a corresponding regression mechanism.
4. Building the Candidate Pool and Running a Small-Sample Evaluation
4.1 Limit the Number of Candidates
Keep the candidate pool to three to five models. Too many candidates raise evaluation costs and dilute conclusions. Filter first by compliance and cost constraints, then keep a few capability-comparable models for the formal evaluation.
4.2 Build the Evaluation Set
The evaluation set should come from real business data, not hand-crafted ideal inputs. Recommendations:
- Sample 200–500 examples from production logs;
- Cover normal requests, edge cases, and malformed inputs;
- Prepare a reference answer or scoring rubric for each sample;
- Have two annotators label independently, measure agreement, and have a third person adjudicate disagreements.
4.3 Use a Consistent Evaluation Method
All candidates should use identical prompts, parameters, and samples. Below is a generic evaluation harness that only handles invocation and statistics—the scoring function is business-specific.
import timefrom dataclasses import dataclassfrom typing import Callable, List, Dict@dataclassclass EvalCase:prompt: strexpected: strdef run_eval(call_model: Callable[[str], str],cases: List[EvalCase],scorer: Callable[[str, str], float],) -> List[Dict[str, float]]:"""Run the evaluation for a single candidate model and return per-sample scores and latencies."""results = []for case in cases:start = time.perf_counter()try:output = call_model(case.prompt)score = scorer(output, case.expected)except Exception:output, score = "", 0.0 # Failed calls score 0; also count failures separatelylatency = time.perf_counter() - startresults.append({"score": score, "latency": latency})return resultsdef summarize(results: List[Dict[str, float]]) -> Dict[str, float]:"""Aggregate the average score and P95 latency."""n = len(results)avg_score = sum(r["score"] for r in results) / nlatencies = sorted(r["latency"] for r in results)p95_index = min(n - 1, int(n * 0.95))return {"avg_score": round(avg_score, 4),"p95_latency_s": round(latencies[p95_index], 3),}
When using this harness, provide a uniform call_model function for each candidate and keep input/output formats consistent. Design the scoring function around the task—for example, exact string matching, field-level comparison, or LLM-assisted grading. If you use model-assisted scoring, manually review a sample to calibrate scoring bias.
4.4 Interpreting Results
After obtaining scores, also examine:
- Score differences across sample categories, to identify where a model is weak;
- Common patterns among failed samples—for example, whether failures cluster on long inputs or specific formats;
- Whether score gaps exceed random variation. A difference of only a few tenths of a point between two models is usually not a sufficient basis for a decision.
5. Cost and Latency Estimation
Cost estimation should be completed during the evaluation phase, not calculated after launch. Monthly cost can be estimated as:
Monthly cost ≈ average daily requests × 30 × (average input tokens × input price + average output tokens × output price)
Prices are typically quoted per million tokens. Actual prices are set by each provider and may change at any time, so verify them before making a decision.
Beyond per-request cost, consider:
- Whether retries and failed requests are billed;
- Whether overly long prompts keep inflating input-token counts;
- Whether caching, batching, or more concise outputs can reduce cost;
- Whether peak traffic requires additional concurrency quota.
For latency, measure under conditions close to the real network environment rather than locally or on an ideal network.
6. Compliance and Data Security
Compliance review should be completed during candidate screening. A recommended sequence:
- Data classification: identify which data is public, internal, sensitive, or restricted;
- Redaction: remove personal information such as ID numbers, phone numbers, and bank card numbers before sending data to the model;
- Data-flow assessment: confirm whether data leaves the local network or crosses borders, and whether this complies with applicable regulations;
- Retention policy: understand how long the provider stores requests and responses, and whether they are used for model training;
- Access control: apply least-privilege principles to API keys, store them in a key-management service or environment variables, and never write them into code or logs.
For highly sensitive scenarios, private deployment or dedicated instances are an option, at the cost of higher operational overhead and hardware investment.
7. Architecture That Reduces Switching Costs
Once a model is tightly coupled to business code, replacing it later becomes expensive. The right approach is to add an abstraction layer between the application and the model.
from typing import Protocol, List, Dictclass ChatProvider(Protocol):def complete(self, messages: List[Dict[str, str]], **params) -> str:...class ModelGateway:"""Unified entry point handling routing, timeout control, and fallback."""def __init__(self, primary: ChatProvider, fallback: ChatProvider):self.primary = primaryself.fallback = fallbackdef ask(self, messages: List[Dict[str, str]], **params) -> str:try:return self.primary.complete(messages, **params)except Exception:# Fall back to the secondary model when the primary is unavailable, and raise an alertreturn self.fallback.complete(messages, **params)
On top of this, you should also:
- Version-control prompts so every change can be traced and rolled back;
- Integrate the evaluation set into CI so that model or prompt changes trigger automatic regression runs;
- Use gradual rollouts: route a small share of traffic to the new model first, then scale up after confirming quality and cost;
- Set circuit breakers and timeout thresholds so a single model failure cannot take down the whole system.
8. Landing the Decision and Continuous Review
Document the selection decision in writing, including the evaluation-set version, each candidate’s scores and costs, the rationale, and known risks. This allows the team to quickly judge whether re-evaluation is needed when models are updated or business needs change.
Continue monitoring after launch:
- Quality: periodically sample production outputs and categorize error types;
- Cost: break down billing by business line or feature module;
- Experience: track response times and user feedback;
- Versions: when the provider releases a new version, rerun the same evaluation set to confirm behavior has not changed unexpectedly.
9. Common Pitfalls
- Looking only at leaderboard rankings without validating on your own data;
- Looking only at per-token prices while ignoring output length and call volume;
- Testing only success cases while ignoring format errors and malformed inputs;
- Selecting once and never re-evaluating, so changes introduced by model upgrades go unnoticed;
- Hard-coding the model into business logic, making any switch require large-scale refactoring.
The essence of LLM selection is reframing the question from “which model is better” to “which model performs better under my task, budget, and compliance constraints.” As long as the evaluation set, scoring standards, and switching mechanism are all in place, a team can maintain sound judgment in a rapidly evolving model landscape.
