How to Evaluate Large Language Models: Six Key Dimensions and Engineering Practices
This guide explains how to break large language model evaluation into measurable dimensions, including factual accuracy, long-context understanding, precise instruction following, reasoning and coding, and agentic programming. It also covers how to build a reproducible evaluation workflow, calculate per-task cost, and monitor models after deployment to support model selection.
1. Why Evaluation Should Be Broken Down into Multiple Dimensions
A single overall score rarely reflects how a model performs in real business use. One model may answer knowledge questions reliably but miss key clauses when summarizing long documents. Another may reason well but frequently time out during tool calls. If teams only look at a composite ranking, they can overlook weaknesses that matter directly to their business when selecting a model.
Evaluation should therefore be split into several observable dimensions. Each dimension maps to a specific business risk and has its own pass criteria.
2. Core Evaluation Dimensions
2.1 Factual Accuracy and Hallucination Control
A hallucination is model output that conflicts with facts or with the provided source material. In scenarios such as customer support, legal clause retrieval, and financial data analysis, hallucinations can cause serious losses.
When evaluating this dimension, you can use the following methods:
- Build a question set with reference answers that covers common knowledge, specialized knowledge, and time-sensitive questions.
- Judge whether each answer can be verified, and classify results as wrong answers, fabricated grounds, or appropriate refusals.
- Given a source document, check whether the answer goes beyond the content of that document.
The metrics include factual accuracy rate, the proportion of statements without grounds, and the appropriate refusal rate. These three should be reviewed together. A model that refuses too often can keep its hallucination rate very low, but it will hurt the usability of the system.
2.2 Long-Context Understanding
Long-context ability has two parts: whether the model can locate information within a large input, and whether it can combine several passages to reason.
There are two common types of tests. The first is a location test, which places one key piece of information inside a long text and checks whether the model can find it. The second is a cross-passage reasoning test, which requires the model to combine clues spread across different positions to reach a conclusion.
Key information should appear at the beginning, middle, and end of the input, so the results do not show that the model only handles the start and end well. Report results separately for each length range, because model performance often drops noticeably as inputs get longer.
2.3 Precise Instruction Following
Precise instruction following means whether a model can meet constraints on format, length, number of fields, language, and banned words. This ability determines whether downstream programs can parse the model output correctly.
The key to evaluating it is to design an automatically checkable rule for each instruction. For example, “the output must be valid JSON containing exactly three fields,” “the body must not exceed 100 characters,” and “the full text must not contain specified words” can all be checked by a program. Automatic checks avoid the subjectivity of human scoring and make large-scale regression testing practical.
2.4 Complex Reasoning and Software Engineering
Complex reasoning covers mathematical derivation, multi-step logical judgment, and planning problems. Software engineering covers tasks such as code generation, bug localization, and refactoring suggestions.
Both types of tasks should be judged by executable methods. For coding problems, you can run pre-written test cases. For reasoning problems, you can compare the key conclusions against a reference answer. Scoring based only on whether the code “looks reasonable” or the reasoning “seems correct” produces unreliable results.
2.5 Agentic Programming: Completion Rate, Timeouts, and Cost
Agentic programming means a model works in a loop: it reads code, calls tools, modifies files, runs tests, and iterates until the task is complete. These tasks demand much higher stability than single-turn question answering. The evaluation should record three metrics:
- Completion rate: whether all subtasks were executed and passed verification.
- Timeout rate: whether a single task exceeded the preset time limit.
- Output token count and cost per task.
Timeout rate is easy to overlook. If a model gets stuck in repetitive output during its reasoning chain, it can slow down the entire pipeline and raise resource consumption, even when its capability score is high.
3. Building a Reproducible Evaluation Workflow
A reproducible evaluation workflow usually has four steps: prepare the dataset, use consistent call parameters, judge and record results automatically, and summarize and analyze. The code below shows the basic structure. The client and checker functions must be implemented for your own environment.
import timedef run_eval(model_client, dataset, timeout_s=120):"""Call the model on each item in the dataset and record pass status,timeouts, and token usage.Note: in production, set a hard timeout on the client. This snippetonly shows the structure."""records = []for item in dataset:start = time.time()try:resp = model_client.generate(prompt=item["prompt"],temperature=0, # Fix randomness for reproducibilitymax_tokens=item.get("max_tokens", 2048),)elapsed = time.time() - starttimed_out = elapsed > timeout_spassed = item["checker"](resp.text) and not timed_outrecords.append({"id": item["id"],"passed": passed,"timed_out": timed_out,"input_tokens": resp.usage.input_tokens,"output_tokens": resp.usage.output_tokens,})except Exception as exc:records.append({"id": item["id"],"passed": False,"timed_out": False,"error": str(exc),})return records
When running an evaluation, fix the following variables: sampling temperature, system prompt, maximum context length, and retry policy. If any of these change, the results before and after are no longer comparable.
4. Calculating Cost per Task
The cost of a single task has two parts, input and output, and is calculated as follows:
Cost per task = input tokens × input price + output tokens × output price
Keep three points in mind when calculating cost. First, when comparing different versions or models, use the same set of questions. Second, report the average cost rather than only the best single-task result. Third, include the cost of retried calls in the total.
Gains in capability and reductions in cost do not always happen together. A new version of a model may answer more questions correctly, but if its output becomes longer, the cost per task can rise. For this reason, each evaluation should report both capability scores and cost data in the same table for comparison.
5. Model Selection and Ongoing Monitoring
When applying evaluation results, you can follow these practices:
- Define the core business scenarios first, then set the weight of each dimension based on those scenarios.
- Build an internal baseline dataset and run regression tests on it regularly.
- Set alert thresholds for timeout rate, refusal rate, and format error rate.
- After a model version update, roll it out to a small group first, and switch fully only after the metrics stay stable.
The monitoring pipeline can use a logging service to record the inputs, outputs, and latency of each call. Monitoring alerts can then notify the responsible person when metrics fall outside their thresholds. Once evaluation data is accumulated, it can support long-term version comparison and cost optimization.
