Choosing an LLM Beyond Leaderboards: A Reproducible Evaluation Method
This guide explains why public leaderboard scores alone are unreliable for model selection and lays out a repeatable method for evaluating LLMs. It covers defining capability dimensions, building a private test set, checking long-context and multimodal performance, assessing agentic coding tasks, estimating cost, and handling integration concerns such as retries and log redaction.
1. Why Leaderboard Rankings Are Not Enough
After a large language model (LLM) is released, the industry often compares models using composite indexes, coding benchmarks, and blind-vote leaderboards. These numbers have reference value, but using them directly for model selection often leads to mistakes, for three main reasons.
First, a composite index is a weighted sum of several sub-scores, and the weights determine the final ranking. A model may lead on coding but trail on document understanding or multilingual tasks, yet still have a similar overall score. When selecting a model, check the sub-scores rather than the total alone.
Second, public benchmarks suffer from saturation and data contamination. Once test questions spread widely, training data may already contain them, so scores can exceed true capability. When two models differ by only a small margin on the same benchmark, the difference is usually not statistically meaningful.
Third, blind-vote leaderboards reflect user preference on specific tasks. Preferences are influenced by response style, length, and formatting. Vote leaderboards show which outputs users prefer, but they do not directly indicate answer accuracy.
Leaderboards are therefore useful for shortlisting candidate models. The final decision should be based on your own business data.
2. Break Down the Evaluation Dimensions
Before evaluating, you need to turn “strong capability” into dimensions you can measure. Common dimensions include the following.
- Instruction following: whether the model produces output in the required format, such as JSON with fixed fields, a word limit, or a specified tone.
- Reasoning and knowledge: accuracy on math, logic, or domain knowledge questions.
- Code and engineering: whether generated code passes unit tests, and whether modifications to existing code break its original functionality.
- Long context: the ability to locate information and reason across paragraphs in inputs of hundreds of thousands of tokens.
- Multimodal understanding: accuracy in interpreting images, screenshots, charts, and video frames.
- Agent execution: success rate for tool calls and multi-step tasks, and the ability to detect and correct errors partway through.
- Stability and latency: whether output is consistent for identical inputs, plus time to first token and total response time.
- Cost: the cost of a single task, calculated from input, output, and cache usage.
Each dimension should correspond to a set of tests that can be run repeatedly. A dimension without tests can only be judged by subjective impression, so its conclusions are unreliable.
3. Build Your Own Evaluation Set
The quality of the evaluation set determines the value of the evaluation results. Build it in the following steps.
Step 1: Collect real tasks. Sample from business logs and anonymize the data. The samples should cover three types of tasks: high-frequency tasks, high-value tasks, and edge cases. Edge cases include incomplete inputs, vague instructions, and contradictory requirements. They are the most effective way to expose a model’s weaknesses.
Step 2: Define scoring rules. Where a task can be judged by a program, write an automated check, such as whether all fields are present, whether code passes its tests, or whether a numeric value matches the reference answer. For tasks that cannot be judged automatically, use human review with defined scoring criteria so that different reviewers score consistently.
Step 3: Fix the experimental conditions. Record the model version, system prompt, temperature, and input length. Scores from the same question set under different conditions cannot be compared directly.
Below is a minimal evaluation framework. You implement the model call function yourself.
import jsonfrom dataclasses import dataclassfrom typing import Callable@dataclassclass EvalCase:case_id: strprompt: strchecker: Callable[[str], bool] # Takes the model output and returns whether it passesdef check_json_fields(output: str, required: list[str]) -> bool:"""Check whether the output is valid JSON and contains all required fields."""try:data = json.loads(output)except json.JSONDecodeError:return Falsereturn isinstance(data, dict) and all(k in data for k in required)def run_eval(cases: list[EvalCase],call_model: Callable[[str, float], str],temperature: float = 0.0) -> tuple[float, list[dict]]:results = []for case in cases:output = call_model(case.prompt, temperature)results.append({"id": case.case_id, "passed": case.checker(output)})pass_rate = sum(r["passed"] for r in results) / len(results)return pass_rate, results
The pass rate is only a starting point. Categorize each failed case and determine whether the failure was a comprehension error, a formatting error, or missing knowledge. This root-cause analysis guides model selection and prompt optimization more effectively than the overall score.
4. How to Verify Long-Context Capability
The context window length a vendor advertises only indicates how much input the model can accept. It does not show whether the model can reliably find and use information within that input. Two types of tests are useful for verification.
The first type is information localization. Insert a single fact, called the “needle,” into a large body of unrelated text, then ask the model a question that depends on that fact. Vary the insertion position and the total text length, record the recall rate, and plot the results in a two-dimensional table. This shows where in the input the model tends to miss information.
def build_haystack(filler_paragraphs: list[str],needle: str,position_ratio: float) -> str:"""Insert the target paragraph at the specified relative position among unrelated paragraphs."""idx = int(len(filler_paragraphs) * position_ratio)paragraphs = filler_paragraphs[:idx] + [needle] + filler_paragraphs[idx:]return "\n\n".join(paragraphs)
The second type is cross-paragraph reasoning. The question requires the model to combine information from two or more places to answer, for example by comparing the breach-of-contract clauses in two contracts. This type of test is closer to real business use than simple retrieval, and it is more likely to expose problems.
Note that longer inputs usually mean higher time to first token and higher cost. Test with the input length your application actually needs, not the maximum the window allows.
5. How to Verify Multimodal Capability
Multimodal capability usually includes image understanding, screenshot understanding, and video understanding. Two points matter during evaluation.
For images, prepare four types of material: ordinary photos, screenshots containing text, data charts, and hand-drawn sketches. The questions should cover reading values, comparison, localization, and inference. For example, ask the model to read the value for a specific quarter from a chart, or to identify the location of a button in an interface screenshot. Annotate the correct answers in advance so that the results can be scored automatically.
For video, models typically do not process every frame of a full video. They extract key frames according to some strategy. The same video can therefore produce different results at different frame sampling rates. When testing, record the frame sampling rate, resolution, and video duration. Otherwise, the results cannot be reproduced.
Human review cannot be skipped. For interface and design tasks, automated checks can usually tell whether something is present but rarely whether it is good. Reviewers need to score these outputs against predefined criteria.
6. Evaluating Agentic Coding Tasks
Agentic tasks require the model to complete multi-step work on its own, such as reading a code repository, running commands, modifying files, and verifying the results. The evaluation focus for these tasks differs from single-turn question answering.
The execution environment must be isolated. Run tasks in a container or sandbox, restrict the network access scope and writable directories, and prevent mistakes from affecting real data.
Completion should be judged by test cases, not by the model’s own report. Models often claim a task is “done” when the tests have not actually passed. Each task should therefore come with an automated acceptance test.
Record the following metrics:
- Task completion rate: the share of tasks where all acceptance tests pass.
- First-attempt pass rate: the share of tasks completed without manual intervention.
- Average number of tool calls: the number of calls needed to complete a task, which reflects execution efficiency.
- Manual interventions: the number of times a human had to prompt or correct the model.
- Rollback count: the number of times a change caused previously passing tests to fail.
For safety, review the commands the model generates. Commands that delete files, change permissions, or access external addresses should be checked by rule-based filters or confirmed by a person before execution.
7. Cost Estimation Model
The key to cost evaluation is matching unit prices to usage. Most models bill for three components: input tokens that miss the cache, input tokens that hit the cache, and output tokens. Cache-hit input is usually priced well below cache-miss input, so prompt structure directly affects cost.
You can estimate monthly cost with the following formula:
Monthly cost = [cache-miss input tokens × miss price + cache-hit input tokens × hit price + output tokens × output price] ÷ 1,000,000
def estimate_monthly_cost(calls_per_month: int,avg_input_miss: int,avg_input_hit: int,avg_output: int,price_miss: float,price_hit: float,price_output: float) -> float:"""Prices are per million tokens. Returns the estimated monthly cost."""per_call = (avg_input_miss * price_miss+ avg_input_hit * price_hit+ avg_output * price_output) / 1_000_000return per_call * calls_per_month
Several common practices help reduce costs.
First, place stable content at the front of the prompt, such as system instructions, fixed examples, and knowledge base summaries. When the prefix stays the same, the cache hit rate is higher.
Second, control output length. Output is usually priced higher than input, so asking the model to answer concisely directly lowers cost.
Third, route tasks by difficulty. Send simple tasks to smaller, cheaper models and call the flagship model only for hard tasks. Routing rules can be based on task type or on the result of a preliminary classification.
Base estimates on the usage distribution in real logs rather than on averages. A small number of very long requests can account for most of the cost.
8. Integration Considerations
How you integrate a model affects maintenance cost and stability over time. Consider the following points during design.
First, build a unified model call layer. Business code should not hard-code model names. Instead, it should read model identifiers from configuration. This way, switching models or running A/B tests only requires a configuration change, not changes to business logic.
Second, set up timeout, retry, and fallback strategies. Model services can be rate-limited or time out. Retries should use exponential backoff to avoid adding to congestion. After the retry limit is reached, switch to a backup model or return a predefined fallback result.
import timedef call_with_retry(call, payload,max_retries: int = 3,base_delay: float = 1.0):"""Retry on timeout errors with exponential backoff. Raise all other exceptions immediately."""for attempt in range(max_retries):try:return call(payload)except TimeoutError:if attempt == max_retries - 1:raisetime.sleep(base_delay * 2 ** attempt)
Third, redact logs. Prompts and outputs may contain personal information, business data, or access credentials. Logs should keep only request IDs, latency, token usage, and error codes. Log body content should be masked according to policy or not persisted at all.
