LLM Evaluation and Selection: From Leaderboards to Production
Public leaderboards can help shortlist large language models, but production selection requires task-specific evidence. This article explains how to define acceptance criteria, build realistic evaluation datasets, compare quality, latency, and cost, test long-context performance, and establish a reproducible evaluation pipeline with ongoing regression testing.
1. What Leaderboard Scores Can—and Cannot—Tell You
Public leaderboards provide standardized test datasets and scoring methods, making them useful for an initial shortlist of candidate models. However, their task distributions, prompt templates, and scoring methods often differ substantially from real business requirements.
A model that scores highly on mathematical reasoning may not reliably rewrite customer support responses or extract contract clauses. Leaderboards can therefore answer, “How capable is this model overall?” They cannot directly answer, “Can it solve our problem?”
Keep three limitations in mind:
- Different task distributions: The capabilities emphasized by a leaderboard may not be those your application needs most.
- Different scoring methods: Automated scoring, rule-based scoring, and human evaluation differ considerably in consistency and cost.
- Rapid version changes: Model versions, inference settings, and server-side updates can change results. Evaluation conclusions should always include the test date and model version.
2. Define Business Objectives and Acceptance Criteria First
Before evaluation begins, translate business requirements into measurable acceptance criteria. Common dimensions include:
- Task type: Classification, extraction, generation, question answering, coding assistance, or multi-turn conversation.
- Input and output formats: Whether responses must follow a fixed JSON schema, use specific field names, or stay within length limits.
- Minimum quality thresholds: For example, a required format compliance rate or accuracy threshold for extracting critical fields.
- Latency limits: Acceptable time to first token and time to receive a complete response.
- Cost limits: A per-request spending limit and a monthly budget estimated from expected request volume.
- Compliance requirements: Whether data may cross jurisdictional boundaries, whether private deployment is required, and whether audit logs are necessary.
Specific acceptance criteria make comparisons easier. If the only requirement is “good results,” stakeholders may interpret “good” differently, and evaluation conclusions will be difficult to reuse.
3. Build an Evaluation Dataset That Reflects Real Workloads
The evaluation dataset is the foundation of the process. A strong dataset usually has the following characteristics:
- Samples come from real data. Sample production logs and remove sensitive information before use. Manually written examples tend to favor ideal inputs.
- Three categories of samples are covered. Normal cases represent common scenarios. Edge cases include missing fields, unusually long text, and ambiguous wording. Adversarial cases include misleading inputs or inputs likely to trigger errors.
- Scoring criteria are explicit. Each sample should include a reference answer or an actionable scoring rubric.
- Dataset size grows gradually. Start with approximately 200 samples to validate the workflow, then expand critical tasks to several thousand samples to reduce statistical variability.
- Tuning and evaluation data remain separate. Data used for prompt optimization or fine-tuning must not appear in the final evaluation set, or scores will be artificially inflated.
Update the dataset as business requirements evolve. Add representative production failures to build a growing regression test suite.
4. Balance Quality, Latency, and Cost
Model selection rarely produces a single best option. It usually involves trade-offs among quality, latency, and cost.
Quality
Quality metrics include task accuracy, format compliance, factual consistency, and the rate of unnecessary refusals. Track unnecessary refusals separately, because excessive refusal directly affects the user experience.
Latency
Distinguish between two latency measures:
- Time to first token: Determines how long users perceive they are waiting.
- Time to complete the response: Affects throughput for batch workloads.
Time to first token matters more for streaming interactions. For offline batch processing, total processing time and concurrency capacity matter more.
Cost
Token-based request costs can generally be estimated as:
Cost per request ≈ Input token count × Input token price + Output token count × Output token price
Use the provider’s published prices and record the date they were checked, because prices may change. Long prompts and lengthy outputs can substantially increase costs, making prompt simplification and output length control common cost-reduction measures.
5. Understand Architecture Trends: Long Context and Efficient Attention
Standard self-attention has computational complexity proportional to the square of sequence length, written as O(n²). When input documents reach tens of thousands of tokens or more, computation and GPU memory requirements rise quickly.
Several approaches aim to address this:
- Sparse attention: Computes attention relationships only between selected positions.
- Linear attention and hybrid designs: Uses linear-complexity attention alongside standard attention, either across layers or in alternating arrangements, to reduce computation for long sequences.
- KV cache compression: Reduces the memory occupied by cached keys and values during inference, improving concurrency capacity.
- Chunking and retrieval augmentation: Retrieves relevant passages first, then sends a smaller amount of content to the model, avoiding excessively long inputs at the application level.
These approaches affect the cost curve and the document lengths a model can process. Evaluation should focus on how quality degrades at the target context length—not just the advertised maximum context window.
A practical method is an information retrieval test: place a key fact at different positions in documents of varying lengths, ask the model a related question, and measure recall across position-and-length combinations. This reveals the difference between supporting a long context window and using that context effectively.
6. Build a Reproducible Evaluation Pipeline
Script the evaluation workflow so results can be reproduced. The following minimal example is provider-independent; the team implements the model invocation and scoring functions.
import jsonimport timefrom dataclasses import dataclass, fieldfrom statistics import mean, medianfrom typing import Callable@dataclassclass Case:case_id: strprompt: strexpected: strtags: list = field(default_factory=list)def load_cases(path: str) -> list[Case]:"""One JSON object per line, with id, prompt, expected, and tags fields."""cases = []with open(path, encoding="utf-8") as f:for line in f:item = json.loads(line)cases.append(Case(item["id"], item["prompt"],item["expected"], item.get("tags", [])))return casesdef run_eval(cases: list[Case],call_model: Callable[[str], str],judge: Callable[[str, str], float]) -> list[dict]:records = []for case in cases:start = time.perf_counter()output = call_model(case.prompt)latency = time.perf_counter() - startrecords.append({"id": case.case_id,"score": judge(output, case.expected),"latency": latency,"tags": case.tags,})return recordsdef summarize(records: list[dict]) -> dict:scores = [r["score"] for r in records]latencies = [r["latency"] for r in records]return {"count": len(records),"mean_score": round(mean(scores), 4),"worst_score": min(scores),"median_latency_s": round(median(latencies), 3),"p90_latency_s": round(sorted(latencies)[int(len(latencies) * 0.9) - 1], 3),}
When using this workflow, pay attention to the following:
- Isolate the adapter layer. Encapsulate
call_modelin a separate module. Switching models should require replacing the adapter, not changing the evaluation logic. - Choose an appropriate scorer. Options include exact matching, regular expressions, structural validation, human review, or a calibrated model-based judge. If using model-based scoring, compare a sample of its judgments with human ratings to verify agreement.
- Run repeated samples. Generated outputs vary. Run critical cases multiple times and record both average results and their variability.
- Preserve evaluation records. Archive model versions, parameters, prompt templates, dates, and scores together so later comparisons are traceable.
7. Common Evaluation Mistakes
- Testing only once. A single result may be an outlier. Repeated runs are needed to assess stability.
- Looking only at average scores. Averages can conceal a small number of severe failures. Review the worst-performing cases and high-percentile latency as well.
- Ignoring version drift. Providers may update models behind an endpoint, so the same API can behave differently over time. Re-evaluate periodically and monitor continuously after deployment.
- Using unfair prompting conditions. Carefully tuning one model while using a default prompt for another makes the comparison unreliable. Either standardize evaluation conditions or use each model’s recommended prompt practices and document them honestly.
- Using evaluation data for tuning. Once evaluation samples enter the optimization process, scores become misleading. Keep final evaluation sets held out and use them only for validation.
8. Production Readiness Checklist
- Business tasks, output formats, and acceptance thresholds are documented and agreed upon.
- The evaluation dataset uses real data with sensitive information removed and covers normal, edge, and adversarial cases.
- Evaluation data is separate from tuning data.
- Quality, latency, and cost have all been measured, with test dates and model versions recorded.
- Long-context scenarios have been validated through information retrieval tests, rather than advertised context limits alone.
- Critical cases have been run multiple times, with variability recorded.
- Evaluation scripts are reproducible, and complete result records have been preserved.
- Continuous production monitoring and periodic regression testing are in place.
Following this checklist produces a more reliable selection decision than relying on leaderboard rankings alone—and makes the decision easier to explain to both the engineering team and management.
