Evaluating Large Language Models: Methods, Metrics, and Selection Practices
A practical guide to evaluating large language models: how to define evaluation goals, which dimensions and metrics matter, how to combine public benchmarks, human blind testing, and business replay sets, plus working code for cost estimation and long-context recall testing.
Evaluating Large Language Models: Methods, Metrics, and Selection Practices
1. Start by Defining Your Evaluation Goals
Before evaluating a large language model, answer three questions first: which task types does the evaluation serve, what decisions will the results drive, and what are the acceptable limits on cost and latency? The same model can perform very differently across code generation, document summarization, and image question answering. Discussing whether a model is “strong” without a specific scenario rarely produces conclusions that can guide decisions.
Write your goals as quantifiable statements. For example: “Locate defects in a code repository of roughly 200,000 tokens, with first-attempt localization accuracy of no less than 70%, and per-task cost within budget.” The more specific the goal, the easier it is to design focused tests and to reproduce your conclusions later.
2. Breaking Down the Evaluation Dimensions
2.1 General Reasoning and Knowledge
General capability covers instruction following, logical reasoning, mathematical computation, and factual question answering. Looking only at aggregate scores hides problems. Break down error types instead: comprehension errors, calculation errors, or formatting errors. Different error types have very different business impact and very different remediation costs.
2.2 Long-Context Capability
Context window length answers “how much content can the model receive,” while effective utilization answers “how much of that content can the model actually use well”—and the two may not match. A common pattern: recall is good when key information sits at the beginning or end of the input, but accuracy drops noticeably when it sits in the middle. Long-context capability therefore needs dedicated recall testing (see Section 6).
2.3 Multimodal Understanding
Evaluating image and video inputs involves three levels: recognition, reasoning, and generation. Video understanding typically depends on frame sampling strategy—sampling frequency and how much temporal information is retained directly affect results. When output is text, check whether numeric values are read accurately, spatial relationships are described correctly, and the order of events is clear.
2.4 Engineering and Coding Capability
The pass rate of a single code generation attempt does not reflect engineering ability. More informative metrics include: completion rate for multi-file modifications, tool-call success rate, number of self-correction attempts after failures, and regression results against a real test suite. Run the model in an executable environment during evaluation and judge by test outcomes—not by whether the code merely “looks reasonable.”
2.5 Cost, Latency, and Stability
Cost and experience metrics include time-to-first-token, output tokens per second, rate-limiting policies, error rate, and service availability. Input tokens are usually priced separately for cache hits and cache misses, and the two prices can differ substantially. For workloads with long, fixed system prompts or repeated questions against the same document, cache hit rate is the key cost variable.
3. Evaluation Methods
3.1 Public Benchmarks: Value and Limitations
Public benchmarks make horizontal comparison easy, but they have three limitations: questions may already be covered in training data; scores are sensitive to prompt templates; and question distribution may not match your specific business. Public benchmarks are therefore suitable for initial screening, not as the final basis for decisions.
3.2 Human Blind Testing
In blind testing, reviewers compare two models’ answers to the same question without knowing which model produced which, and you tally win rates. Three points matter in practice. First, write the review criteria in advance—for example, how much weight accuracy, completeness, and actionability each carry. Second, samples should cover a range of difficulty levels. Third, re-evaluate the same answer pairs with the display order swapped, to reduce position bias.
3.3 Business Replay Sets
A business replay set extracts representative requests from real production logs, anonymizes them, and freezes them into a fixed test set. Each time the model or its parameters change, re-run the same requests and compare results directly. This is the method closest to production behavior, but it requires ongoing maintenance to keep the test set from drifting out of sync with the business.
4. Understanding Model Scale Correctly
Parameter count is often treated as a proxy for capability, but it is only one influencing factor. Distinguish these concepts:
- Total parameters: the size of all weights in the model.
- Active parameters: the parameters actually involved in a single forward pass. In Mixture-of-Experts (MoE) architectures, each token passes through only a few expert networks, so active parameters are typically far fewer than total parameters.
- Training data and post-training quality: instruction tuning, preference alignment, and data mix often matter as much as scale for final performance.
For architecture details (such as attention mechanism variants), rely on official technical documentation or published papers. Without a reliable source, avoid drawing conclusions.
5. Cost Calculation Example
When selecting a model, don’t compare unit prices alone—compute total cost from real request samples. The example below estimates per-request cost across three parts: cache-hit input, cache-miss input, and output. Fill in the pricing parameters with your own quotes, keeping units consistent.
# Pricing config, unit: currency per million tokens; replace with actual quotesPRICE_CONFIG = {"input_cache_hit": 0.0,"input_cache_miss": 0.0,"output": 0.0,}def estimate_cost(input_tokens: int, output_tokens: int,cache_hit_ratio: float, price: dict) -> float:"""Estimate the cost of a single request; the result uses the same unit as the pricing config."""hit_tokens = input_tokens * cache_hit_ratiomiss_tokens = input_tokens - hit_tokenscost = (hit_tokens * price["input_cache_hit"]+ miss_tokens * price["input_cache_miss"]+ output_tokens * price["output"]) / 1_000_000return cost
How to use it: pull average input length, output length, and cache hit rate from your business logs, plug them into the function, then scale by monthly request volume. When comparing models, use the same request sample and record quality metrics alongside cost, since a cheaper model per token may need more turns to complete the same task.
6. Long-Context Recall Testing
The idea behind recall testing: insert one key piece of information at different positions inside a large block of irrelevant text, then ask a question and check whether the answer contains that information. By varying text length and insertion depth, you can plot an accuracy distribution and identify where the model’s performance degrades.
def build_haystack_case(filler_sentences, needle, depth_ratio, num_sentences):"""Take the first num_sentences filler sentences and insert the key information at the specified depth."""body = list(filler_sentences[:num_sentences])pos = int(len(body) * depth_ratio)body.insert(pos, needle)return "\n".join(body)def is_recalled(answer: str, expected: str) -> bool:return expected in answerdef run_long_context_eval(call_model, filler, needle, question, expected,lengths=(1_000, 5_000, 10_000),depths=(0.1, 0.5, 0.9)):results = {}for n in lengths:for d in depths:context = build_haystack_case(filler, needle, d, n)prompt = f"{context}\n\nQuestion: {question}"answer = call_model(prompt)results[(n, d)] = is_recalled(answer, expected)return results
Here lengths is measured in sentence counts; convert to actual token counts based on the tokenizer you use. call_model is your own wrapper responsible for invoking the model under test. For reproducibility, fix the filler text and repeat each combination multiple times, averaging the results.
7. Validating Multimodal and Engineering Capabilities
Consider these practices for validating multimodal and engineering capabilities:
- Image QA: prepare images containing numbers, tables, and spatial relationships, manually annotate ground-truth answers, and measure the exact-match rate for numeric reading.
- Video understanding: sample frames at a fixed rate, design questions that involve event ordering, and check whether the model describes the sequence correctly.
- Code modification: give the model a repository with failing tests and ask it to fix the problem, with the full test suite passing as the success criterion.
- Tool calling: define each tool’s parameter schema and measure the parameter format error rate and invocation success rate.
