How to Systematically Evaluate Large Language Models for Software Development
This article explains how to evaluate large language models for development scenarios in a repeatable way. It covers defining use cases, breaking down evaluation dimensions, building an evaluation set, testing stability and cost, interpreting results, and turning evaluation into ongoing decision management.
1. Why Systematic Evaluation Is Needed
Many developers choose models based on scattered usage experience. If a generated function looks good once, they assume the model is reliable overall; if an answer fails once, they reject it entirely. Such judgments use few samples, are easily affected by memory bias and current mood, are hard to reproduce, and are difficult to align within a team.
The goal of systematic evaluation is to turn “it feels useful” into metrics that can be recorded, compared, and retested. Only then can model selection and usage strategy have a basis.
2. Define the Evaluation Scenarios First
Before evaluation, define the intended use. Common development scenarios include code generation, defect localization and fix suggestions, unit test generation, code review, documentation writing, and explanation of logs and error messages.
Different scenarios have very different capability requirements. Code completion cares more about response speed and context understanding, while code review cares more about accuracy and whether key issues are missed. If one generalized set of questions is used to measure all scenarios, the results are easily distorted.
For each scenario, record three things: typical input, expected output format, and acceptable error range. These three items directly inform the design of the later evaluation set.
3. Break Down Key Evaluation Dimensions
3.1 Task Accuracy
Accuracy refers to whether the output meets the requirement. For code tasks, the conclusion should be based on compilation results and test case pass rates, not on a manual glance.
3.2 Output Stability
Stability refers to how consistent results are when the same input is run multiple times. In production workflows, stability is often more important than a single best result. A model that performs well once but fluctuates widely is difficult to include in automated steps.
3.3 Instruction Following
Instruction following refers to whether the model returns results in the required format and obeys constraints. For example, when a task only requires modifying one function, the model should not change unrelated code or introduce undeclared dependencies.
3.4 Response Latency
First-token latency and total response time should be recorded separately. Interactive scenarios care about first-token latency, while batch tasks care about overall throughput. The optimization directions differ, and looking at them together can lead to wrong conclusions.
3.5 Cost
Cost should be calculated per valid task, not just by the price per call. What needs to be counted is the total consumption to complete a task, compared with the time required for a person to complete the same task.
3.6 Verifiability
Whether the output includes supporting evidence and whether it is easy for a person to verify quickly are also important metrics. Output that is hard to verify increases review cost even if it is correct.
4. Build an Evaluation Set
The evaluation set is the core asset of the entire evaluation effort. It is recommended to sample 50 to 200 cases from real work, covering simple, medium, and difficult levels. Each case should store acceptance criteria, such as the standard answer, expected test results, or key elements that must appear.
Sample sources can include historical tickets, fixed defects, and common code patterns in the team. Avoid using only public examples, because such samples may already be covered by model training data, leading to inflated scores.
The evaluation set should be managed separately from prompts and model configurations, and updated regularly. Each evaluation should record the model version, prompt version, parameter settings, and execution date. Without this information, results cannot be reproduced, and it is impossible to explain the cause of a score change.
5. Example Evaluation Framework
The following example shows the basic structure of an evaluation framework. The model call function is a placeholder and should be replaced with the client for the service in actual use.
from dataclasses import dataclass, fieldfrom typing import Callableimport time@dataclassclass Case:case_id: strprompt: strcheck: Callable[[str], bool] # Receives model output and returns whether it passes@dataclassclass Report:total: int = 0passed: int = 0latencies: list = field(default_factory=list)def call_model(prompt: str) -> str:"""Placeholder function: replace with the actual model client call."""raise NotImplementedErrordef run_eval(cases: list[Case]) -> Report:report = Report()for case in cases:report.total += 1start = time.perf_counter()try:output = call_model(case.prompt)except Exception as exc:print(f"{case.case_id} call failed: {exc}")continue # Call failures count as failed casesreport.latencies.append(time.perf_counter() - start)if case.check(output):report.passed += 1return reportdef summarize(report: Report) -> dict:avg = sum(report.latencies) / len(report.latencies) if report.latencies else 0.0return {"total_cases": report.total,"pass_rate": round(report.passed / report.total, 3) if report.total else 0.0,"avg_latency_s": round(avg, 3),}def check_test_output(output: str) -> bool:"""Simplified acceptance rule: the output should contain a test function and assertions.In a real project, the generated code should be run in an isolated environment to run tests."""return "def test_" in output and "assert" in output
This code only demonstrates the flow. In real evaluation, the check function should execute the generated code and run tests, rather than only doing string matching. Executing generated code must be done in an isolated environment with restricted file system and network access to avoid accidental operations or security risks.
6. Stability Testing
For the same sample, it is recommended to run three to five times and record the pass status each time. If a sample passes only some of the runs, the task is sensitive to randomness. There are usually three ways to handle this: add clearer constraints to reduce output freedom; use multiple samples and manual selection; or exclude the task from automated workflows.
7. Cost and Quota Management
Many platforms charge by credits, quotas, or subscription periods. During evaluation, all costs should be converted into “consumption per completed valid task,” rather than directly comparing unit prices.
When quotas have expiration dates, usage pace needs to be planned in advance. First list low-risk work suitable for the model in the near term, such as format conversion, batch comments, and test sample generation. Spread consumption across the quota period to avoid concentrating it near expiration on unfamiliar high-risk tasks. Such tasks require extensive manual review, and the actual benefit may be lower than expected.
It is also important to note that quota consumption does not equal value output. If generated content cannot be adopted, the cost is wasted no matter how low it is. Therefore, cost metrics should be tracked together with adoption rate.
8. Interpreting Results and Making Decisions
Put the results for each dimension in the same table for comparison, and set thresholds in advance. For example, candidate models with accuracy below the baseline are eliminated directly; for models above the baseline, compare cost and latency. Avoid making decisions with only one composite score, because a composite score hides weaknesses.
Decision conclusions should state the applicable scenarios. For example, “suitable for generating test samples, not suitable for directly modifying core modules” is more instructive than “works well.”
Common pitfalls in evaluation include:
- Sample leakage: evaluation samples overlap with prompt examples, causing inflated scores.
- Ignoring review cost: generation is fast, but requires extensive modification, so total efficiency may not be higher.
- Looking only at the best output: production environments care more about worst cases and result fluctuation.
- Mixing scenarios: directly extending a conclusion from one scenario to other scenarios.
9. Implementation Recommendations
- First select two to three high-frequency scenarios for small-scale evaluation, and form a first version of conclusions within two weeks.
- Put evaluation scripts under version control, and rerun them whenever the model is changed or the prompt is modified.
- Keep decision records for the team, including date, model version, evaluation results, and known limitations.
- When sensitive code or data is involved, first confirm the scope of use and compliance requirements, and then decide whether to call external services.
Conclusion
The core of systematic evaluation is to turn usage experience into reproducible evidence. By defining scenarios, breaking down dimensions, building an evaluation set, and including cost and adoption rate in the judgment, different options can be compared with consistent standards. Regular retesting can also reveal the impact of changes in models or business needs in time, turning model selection from a one-time judgment into ongoing management.
