How to Systematically Evaluate LLMs for Code Optimization and Communication

    Teams often evaluate large language models (LLMs) through subjective impressions, which are difficult to reproduce or use for team decisions. This article presents a practical framework for assessing LLMs in development scenarios across four dimensions: problem localization, restraint in optimization plans, code maintainability, and communication quality. It also explains how to design test sets, build scoring rubrics, run blind reviews, aggregate results, avoid common pitfalls, and roll out the evaluation process as part of regular engineering quality management.

    1. Why Systematic Evaluation Matters

    In community discussions about LLM capabilities, common claims include “one model is a tier above another” or “it feels smooth to use.” Such judgments have reference value, but they are difficult to reproduce and difficult to use for team decisions. A good conversation may simply reflect good luck, and a failed answer may result from an inappropriate prompt.

    The purpose of systematic evaluation is to break “feels useful” into observable, recordable, and comparable metrics. Once the evaluation criteria are clear, a team can compare different models on the same set of tasks and check whether capabilities have regressed after a model upgrade.

    2. Breaking Down Evaluation Dimensions

    Evaluating how LLMs perform in development scenarios can start from four dimensions.

    2.1 Problem Localization

    Problem localization refers to whether a model can quickly find the root cause of an issue. Consider performance optimization as an example. A good answer usually first confirms where the bottleneck lies—for example, whether time is concentrated in I/O, lock contention, repeated computation, or memory allocation—and then proposes changes. A weaker answer tends to list many generic suggestions that “might help,” such as “add caching” or “use concurrency,” without explaining how those suggestions relate to the current code.

    The criteria can be summarized in two questions: First, does the answer reference specific snippets from the input code? Second, does it explain the basis for its judgment, such as the time complexity of a loop or the call frequency of a database query?

    2.2 Restraint in Optimization Plans

    Restraint means that the scope of changes matches the scale of the problem. If a problem can be solved by changing three lines of code but the model suggests refactoring the entire module, the plan is over-engineered. In engineering practice, small and precise changes are easier to review, test, and roll back.

    Restraint can be examined with the following questions:

    • Are the suggested changes limited to the function or module where the problem occurs?
    • Does the plan introduce new dependencies, new abstraction layers, or new configuration items?
    • Does it explain why the untouched parts can remain as they are?

    If the answers to all three questions lean toward “controlled scope,” the plan has good restraint.

    2.3 Code Maintainability

    Optimized code needs to be read by the team over the long term. Maintainability evaluation focuses on whether naming is clear, control flow is intuitive, boundary conditions are handled explicitly, and comments explain “why this is done” rather than repeating what the code does.

    For example, the following two snippets have similar runtime efficiency but differ clearly in readability:

    1. # Harder to understand
    2. r = [x for x in d if x[1] and x[2] > t and not x[3]]
    3. # Clearer intent
    4. active_users = [
    5. user for user in users
    6. if user.is_active and user.score > threshold and not user.is_banned
    7. ]

    During evaluation, the model can be asked to provide both the before and after versions, and reviewers can score naming, structure, and testability.

    2.4 Communication Quality

    The value of a technical answer depends partly on whether readers can understand it and take action. Communication quality can be measured at three levels.

    The first level is structure. Does the answer give the conclusion first, then the evidence, and finally the operational steps? The second level is terminology. Are technical terms accurate, and is the same concept referred to with a consistent name? The third level is tone. Does the answer point out problems directly while avoiding irrelevant pleasantries and repetition?

    In daily development, clear communication reduces back-and-forth follow-up questions. A clearly stated recommendation is often more useful than a long analysis with a vague focus.

    3. Building an Evaluation Workflow

    After the dimensions are defined, they need to be implemented in a concrete workflow. A feasible workflow includes four steps: test set design, scoring rubric development, blind review execution, and result aggregation.

    Test Set Design

    The test set should come from real business scenarios rather than artificially constructed ideal examples. You can extract several representative issues from an internal codebase, such as a data access module with N+1 queries, a cache module with race conditions under high concurrency, or a piece of legacy logic that is difficult to read. Each sample should include background information, including the runtime environment, performance goals, and known constraints.

    The test set does not need to be large, but it should cover different difficulty levels and problem types. At least twenty samples are recommended, divided into simple, medium, and complex levels.

    Scoring Rubric

    The scoring rubric should provide operational descriptions for each dimension. For problem localization, for example, the following definitions can be used:

    Score Description
    5 Accurately identifies the bottleneck, cites specific code, and explains the basis for the judgment
    3 Points in the right direction but lacks specific evidence
    1 Gives generic suggestions with weak connection to the input code

    Other dimensions can use the same five-level structure, with typical characteristics described at each level to reduce differences in interpretation among reviewers.

    Blind Review Execution

    Blind review is key to reducing bias. Reviewers should not know which model produced an answer, and the format and length of answers should be as consistent as possible. A system can remove model identifiers and present results to reviewers in random order.

    The following is a simplified evaluation script idea for aggregating scores from multiple reviewers:

    1. from collections import defaultdict
    2. from statistics import mean
    3. def summarize_scores(records):
    4. """
    5. records: list where each item is (item_id, dimension, reviewer, score)
    6. Returns the average score for each dimension and the score gaps between reviewers.
    7. """
    8. by_dimension = defaultdict(list)
    9. by_item = defaultdict(list)
    10. for item_id, dimension, reviewer, score in records:
    11. by_dimension[dimension].append(score)
    12. by_item[(item_id, dimension)].append(score)
    13. dimension_avg = {d: round(mean(s), 2) for d, s in by_dimension.items()}
    14. # Items with large score gaps need review; the rubric may not be clear enough.
    15. disputed = [
    16. key for key, scores in by_item.items()
    17. if max(scores) - min(scores) >= 2
    18. ]
    19. return dimension_avg, disputed

    Items with large score gaps are worth discussing separately. These items often indicate ambiguity in the rubric or controversy in the sample itself.

    Result Aggregation

    When aggregating results, look at both average scores and distributions. Two models may have similar averages, but one may be stable on simple problems and highly variable on complex ones, while the other shows the opposite pattern. These two cases have different implications for how a team should use the models, so they should be recorded separately.

    4. Common Pitfalls

    The following problems are common during evaluation.

    Looking only at the first answer. In real work, developers ask follow-up questions, make corrections, and add context. Evaluation should also include multi-turn interactions to observe whether the model can adjust its plan based on feedback.

    Replacing records with impressions. Scoring from memory after the evaluation is finished makes results susceptible to the most recent experience. Each sample should have its score and rationale recorded on the spot.

    Ignoring cost and latency. A model that produces high-quality answers but takes too long may not be suitable for interactive development. Response time and invocation cost should be included as reference factors during evaluation.

    Mistaking good communication for strong capability. Fluent, well-structured answers can sometimes mask reasoning errors. Communication quality and correctness should be scored separately and should not substitute for each other.

    Sample leakage. If test samples have already appeared in a model’s training data or prompts, evaluation results will be inflated. Teams should update the test set regularly and keep some private samples for acceptance testing.

    5. Rollout Recommendations

    If you plan to introduce this evaluation method within a team, you can proceed in the following order.

    First, select two or three scenarios most relevant to the business, such as API performance optimization, legacy code refactoring, and incident troubleshooting. Second, compile around twenty samples from historical tickets or code review records and label their difficulty. Third, create a scoring rubric, organize two or three reviewers for a pilot evaluation, and revise the descriptions based on disagreements. Fourth, run the formal blind review and record scores and rationales. Fifth, summarize the results into a short report describing performance on each dimension, typical failure cases, and recommended usage scenarios.

    Evaluation results should serve concrete decisions, such as determining which tool should assist with a certain type of task or which steps must retain human review. Model capabilities change with versions, so evaluation should ideally be repeated regularly and treated as part of ongoing engineering quality management rather than a one-time selection activity.