Evaluation-Driven LLM Selection: Code Generation, Spatial Reasoning, and Defect Repair Benchmarks

    This article presents a practical framework for evaluating large language models (LLMs) for technical teams. It covers a structured approach combining public benchmarks with private evaluation sets, and details three core tasks: code generation, 3D scene generation, and defect repair. Key metrics, testing procedures, and selection criteria such as functional accuracy, spatial error rates, and P95 latency are defined to help teams make data-driven model choices.

    I. Conclusions and Metric Definitions

    Public leaderboards indicate a model’s upper capability limit, but they cannot substitute for business-specific data. During model selection, teams should use both public benchmarks and internal private evaluation sets. Use the same metrics to compare candidate models, and incorporate latency and cost into the final decision. Public benchmarks answer the question, “How strong is the model generally?” Private evaluation sets answer the question, “Does the model work for our specific tasks?” They serve different purposes and should be used together.

    The table below compares the purposes of the two types of evaluation sets.

    Field Public Benchmarks Private Evaluation Sets
    Task General code generation and general reasoning Team-specific code generation, 3D scenes, defect repair
    Sample count Hundreds to thousands At least 50 per category; conclusions are unstable with too few samples
    Metrics Officially defined Defined in Sections II to IV of this article
    Thresholds For reference only Determined by the responsible lead before evaluation
    Owner Usually none Assigned to a specific individual

    Every metric must have a clear definition, measurement method, and acceptance threshold. The following standards are used in this article.

    Metric Definition Measurement Method Initial Threshold
    Functional accuracy Percentage of code generation tasks that pass all hidden tests Hidden unit tests Baseline: existing model
    Defect repair Pass@1 Percentage of tasks where the first generated patch passes hidden tests Script from Section IV Baseline: existing model
    Mean coordinate error Average Euclidean distance error of object center points, in meters Function from Section III 0.05 m
    Relationship accuracy Percentage of correctly judged directions: front/back, left/right, up/down Function from Section III ≥ 95%
    Collision pass rate Percentage of scenes with no overlapping objects and all objects within the boundary Function from Section III 100%
    P95 latency Time within which 95% of requests return Each task run 5 times, excluding warm-up requests; take the 95th percentile (i.e., the slowest of 5 runs) Per business SLA
    Cost per task Average cost of one complete evaluation Billing logs Per budget

    Each sample in the private evaluation set should use a consistent structure.

    1. {
    2. "id": "cg-001",
    3. "task_type": "code_generation",
    4. "dataset_version": "v1.0",
    5. "input": "tasks/cg-001/requirement.md",
    6. "expected": "hidden_tests/cg-001/"
    7. }

    II. Code Generation Evaluation

    Evaluation Task. The model reads a programming requirement and returns a complete function implementation. The evaluation compares whether the generated function passes all hidden unit tests.

    Prompt Template.

    1. You are an expert Python developer. Complete the function according to the requirements below. Return only the Python code, enclosed in a code block.
    2. Requirements:
    3. {requirement}
    4. Function signature:
    5. {function_signature}

    The variable {requirement} is the textual description of the programming task, and {function_signature} defines the required function interface.

    Evaluation Data. Each sample is a programming task description. The evaluation set contains 100 samples covering the following difficulty levels:

    • 20 simple tasks
    • 50 medium tasks
    • 30 complex tasks

    The difficulty rating is based on the presence or absence of specific constraints. For example, a medium task may involve string processing with additional constraints, while a complex task may require implementing a specific algorithm from scratch.

    Pass Conditions. A task is considered passed only if the generated code passes all hidden unit tests. The overall functional accuracy is the percentage of passed tasks out of the total number of tasks.

    III. 3D Scene Generation Evaluation

    Evaluation Task. The model receives a natural language description of a 3D scene and must output a JSON array of object information, where each object includes the name, center coordinates (x, y, z), and dimensions (length, width, height).

    Request Format.

    1. Scene requirement:
    2. {requirement}
    3. Output format:
    4. A JSON array of objects. Each object has fields: name, center: {x, y, z}, dimensions: {length, width, height}.

    Evaluation Metrics. Three metrics are used to score the generated scenes.

    1. Mean Coordinate Error. Each object is located by its center point. For each object, calculate the Euclidean distance between the generated center and the ground-truth center, then average over all objects in the scene. The specification is:

    mean_coordinate_error = average(||center_generated − center_ground_truth||₂)

    The initial threshold is 0.05 m.

    2. Relationship Accuracy. This checks whether the relative position of two objects is correct based on the direction words from the text. The implementation extracts all direction indicators (front/back, left/right, up/down) and verifies that the generated object positions satisfy each relationship. For example, the phrase “the red cube is to the left of the blue sphere” is checked by comparing their x-coordinates (using a 0.1 m tolerance). Relationship accuracy is the percentage of correctly judged relationships out of all tested direction indicators.

    3. Collision Pass Rate. This verifies two conditions: no two objects overlap, and all objects are within the venue boundary. Each object is treated as an axis-aligned bounding box. Two boxes overlap if their projections overlap in the x, y, and z axes simultaneously. An object is within the boundary if its minimum coordinate values are greater than or equal to zero and its maximum coordinate values are less than or equal to the venue dimensions. Collision pass rate is the percentage of scenes in which all sampled objects satisfy both conditions. If any overlapping or out-of-bounds object is found, the scene is marked as failed. The initial threshold is 100%.

    IV. Defect Repair Evaluation

    Evaluation Task. The model receives a buggy code snippet along with a failing test case and is asked to output a patch. The evaluation measures whether the patch is correct.

    Prompt Template.

    1. You are an expert developer. The following code has a bug that causes the provided test to fail. Please output a patch that fixes the code.
    2. Buggy code:
    3. {buggy_code}
    4. Failing test:
    5. {failing_test}
    6. Output the patch in unified diff format.

    Format Validation. Validate the output in two steps.

    1. Format check. Verify the patch is valid unified diff text. If not, the task is marked as failed.
    2. Patch application. Apply the patch to the original code. If the patch does not apply cleanly, the task is marked as failed.

    Scoring. The patched code must pass all hidden tests to count as a success. The metric is Defect Repair Pass@1 (only one patch attempt per task). The initial threshold is set using the existing model as the baseline.

    V. Model Selection Considerations

    Functional Comparison. Evaluate all candidate models on the same private evaluation set to ensure fairness. Use the functional accuracy metric for code generation, the mean coordinate error metric for spatial generation, and the Defect Repair Pass@1 metric for defect repair.

    Performance and Cost Decision. After functional evaluation, select models that meet the functional thresholds. Then, for each candidate model, measure P95 latency and the cost per task to make a final decision. The evaluation environment should reflect the production deployment scenario. The request volume and concurrency used during the test should match the actual business load as closely as possible.

    Public vs. Private Benchmarks. Public benchmarks such as HumanEval or LiveCodeBench provide a general indication of model capabilities. They cannot replace business-specific testing. A model may score high on general-purpose benchmarks yet fail on specialized tasks such as 3D generation or defect repair. The team should use public benchmarks to shortlist candidates initially, then run the full private evaluation to make the final selection.

    When running the private evaluation, models with 7B–32B parameters are preferred for deployment. These models offer balanced inference speed and operational cost. Preferences are given to open-weights models that support self-hosting, which helps keep private code and data within the team’s own infrastructure.