How to Evaluate LLM Capabilities Scientifically in Engineering Practice

    Teams often judge large language models by personal impressions, which are easily skewed by task type, prompt wording, and service load. This article explains how to build a repeatable evaluation covering task accuracy, reasoning cost, throughput and latency, stability, and safety boundaries, with a lightweight framework, test set guidelines, result interpretation, and deployment recommendations.

    1. Why Systematic Evaluation Is Needed

    Teams often choose and use large language models based on personal experience. That kind of judgment is easily affected by many factors. For example, conclusions can flip completely depending on the task type. The way a prompt is written changes output quality. During periods of high service load, response speed and stability may also decline.

    A model version update can also make the same model worse on some tasks. The industry commonly calls this capability regression or performance degradation. Without baseline data, teams struggle to notice such changes and to tell whether the cause lies in the model, the prompt, or the external service.

    Engineering decisions therefore need repeatable data. Evaluation should center on real business tasks, produce metrics that can be compared, and be repeatable after the model or configuration changes.

    2. Five Dimensions of Evaluation

    1. Task Accuracy

    Accuracy is the most direct metric. Evaluation cases should come from real scenarios, such as historical support tickets, fixed defects, or problems found in code reviews. Each case needs a clear pass criterion. For code repair tasks, the most reliable check is running unit tests or regression tests, not reading the output and judging it subjectively.

    2. Trade-off Between Reasoning Depth and Cost

    Many model services offer several reasoning intensity levels. A higher reasoning budget usually means longer latency and higher cost, but it does not always bring a proportional gain in quality. Teams should measure the pass rate at each level on the same case set, calculate the benefit per unit of cost, and find the level that fits each type of task.

    3. Throughput and Latency

    Throughput is usually measured in tokens generated per second. Latency includes time to first token and total completion time. For interactive scenarios, time to first token shapes the user experience. For batch tasks, throughput determines the total runtime. Record median and P95 values instead of only the average, because a few very slow requests can noticeably inflate the average.

    4. Stability and Regression

    Large model outputs are random. A case that passes once does not necessarily pass every time. Each case should run several times, and the pass ratio should be calculated. A case whose pass ratio falls between 0 and 1 shows that the model is unstable on that task and needs closer attention.

    5. Safety and Alignment Boundaries

    Evaluation should also cover the model’s behavioral boundaries. This includes whether it respects permission constraints, whether it performs actions beyond its authorization, and whether its output stays controllable. This part needs dedicated test cases. For example, ask the model to access an unauthorized resource, then check whether it refuses or asks for confirmation.

    3. Building an Evaluation Set

    The quality of the evaluation set determines how reliable the conclusions are. We recommend the following practices:

    • Use real sources: prioritize defects that have already been fixed, and turn their problem descriptions and reproduction steps into cases.
    • Define clear pass criteria: for each case, specify the input, the expected behavior, and the judging function.
    • Keep the size manageable: start with 20 to 50 cases that cover the main task types, then expand gradually.
    • Update regularly: after business changes, replace outdated cases so the evaluation set stays aligned with actual work.
    • Prevent leakage: do not write evaluation cases directly into prompt templates or training data, or the results will be inflated.

    4. Example: A Lightweight Evaluation Framework

    The code below shows how to organize an evaluation workflow. call_model is a calling function that your team implements. It should return the model’s output text and the number of generated tokens. The exact implementation depends on the service interface your team uses, and the code does not include any vendor-specific API names.

    1. import statistics
    2. import time
    3. from dataclasses import dataclass
    4. from typing import Callable
    5. @dataclass
    6. class EvalCase:
    7. name: str
    8. prompt: str
    9. check: Callable[[str], bool] # Receives the model output and returns whether it passes
    10. def run_suite(call_model, cases, repeats=3):
    11. """Run each case repeatedly and record pass results, latency, and throughput."""
    12. records = []
    13. for case in cases:
    14. for _ in range(repeats):
    15. start = time.perf_counter()
    16. output, completion_tokens = call_model(case.prompt)
    17. elapsed = time.perf_counter() - start
    18. records.append({
    19. "case": case.name,
    20. "passed": case.check(output),
    21. "latency": elapsed,
    22. "tps": completion_tokens / elapsed if elapsed > 0 else 0.0,
    23. })
    24. return records
    25. def summarize(records):
    26. """Summarize overall metrics and compute the pass rate for each case."""
    27. per_case = {}
    28. for r in records:
    29. per_case.setdefault(r["case"], []).append(r["passed"])
    30. return {
    31. "pass_rate": round(sum(r["passed"] for r in records) / len(records), 3),
    32. "p50_latency_s": round(statistics.median(r["latency"] for r in records), 3),
    33. "mean_tps": round(statistics.mean(r["tps"] for r in records), 1),
    34. "per_case_pass_rate": {
    35. name: round(sum(flags) / len(flags), 2)
    36. for name, flags in per_case.items()
    37. },
    38. }

    How the judging function works depends on the task type. For code repair cases, you can write the model output into a temporary workspace, run the test command, and use the exit code to decide whether the case passes. Code generated by a model must run in an isolated environment with restricted file system and network access, so that mistakes or malicious code cannot affect production systems.

    5. Interpreting Results

    When you have the data, keep the following points in mind.

    • When comparing two configurations, check whether the difference in pass rates exceeds random variation. With few cases or few repetitions, small differences often have no statistical significance.
    • Consider quality and cost together. Divide the pass rate by the average cost per case to get the effective output per unit of cost, which makes horizontal comparison easier.
    • Compare results across task types. A model may perform well on code review but poorly on long-document understanding. A single overall score hides these differences.
    • Set up regression monitoring. Run the evaluation on the same baseline set every week or after each model version change. Trigger an alert when the pass rate drops below a preset threshold.

    6. Security and Permission Boundaries

    The more capable a model is, the stricter its permission controls must be. Even if a model performs well in evaluation, it should not receive write access to production environments directly.

    • Least privilege: the model can access only the resources needed for its task. Code repositories are read-only by default.
    • Sandboxed execution: scripts, commands, and patches generated by the model run in an isolated environment first.
    • Human approval: patches must pass tests and code review before they are merged into the main branch.
    • Use restrictions: tasks involving vulnerability analysis or security testing must be limited to authorized systems and scope, and operation logs must be kept.

    Code auditing and vulnerability repair capabilities can be used for defense, but they can also be misused. Teams should decide which models and which people may handle each type of task, based on their internal risk classification policy.

    7. Implementation Recommendations

    1. Establish a baseline first. Before introducing a new model, measure the pass rate, latency, and cost of the current setup on a unified case set.
    2. Select models by task tier. Use low-cost, low-latency configurations for simple, repetitive tasks. Use configurations with higher reasoning budgets for complex problems.
    3. Integrate evaluation into continuous integration. After each prompt change, model version switch, or parameter adjustment, run the evaluation automatically and save the results.
    4. Record version information. Save the model version, inference parameters, prompt version, and evaluation set version to make later reproduction and comparison possible.
    5. Review regularly. Each quarter, check whether the evaluation set still covers the main business scenarios, and adjust the selection strategy based on the results.

    With this process, teams can use data instead of subjective impressions to decide whether a model fits a specific job, and adjust their approach promptly when capabilities change.