Evaluating Process Fidelity in Code Generation Models: A Geometric Drawing Approach

    Evaluating the true reasoning capabilities of code generation models requires more than just checking the final output. This article explores using geometric drawing tasks to assess process fidelity—a model's ability to follow strict, sequential construction steps. We introduce a three-layer evaluation framework covering results, process, and presentation, analyze common failure modes, and provide practical guidelines and sample code for designing robust evaluation schemes.

    I. Why Use Geometric Drawing Tasks to Test Models

    These types of tests are often referred to as “HTML tests” or “drawing tests” because they require the model to accomplish three things simultaneously: understand a text description with strict sequential steps, translate each step into executable computational and drawing code, and render the result into an observable image.

    This category of tasks has two main characteristics. First, geometric constraints are hard constraints. For a regular polygon, all sides must be equal in length, the distance from each vertex to the center must be the same, and the central angle between adjacent vertices must be 360° divided by the number of sides. Any violation of these constraints can be detected numerically. Second, the construction steps have strict sequential dependencies. The points, lines, and circles used in a subsequent step must be generated by preceding steps; they cannot appear out of nowhere.

    Therefore, these tests evaluate both mathematical understanding and engineering implementation. However, their value depends heavily on whether the evaluation method is sufficiently rigorous. If the evaluation only looks at the final rendered image, the test easily loses its discriminative power.

    II. Splitting the Task into Three Layers

    A comprehensive evaluation should inspect three separate layers:

    1. Result Layer: Does the final shape satisfy the target geometric properties, such as vertex count, side length consistency, and circumscribed circle consistency?
    2. Process Layer: Is each construction step legal? Does it only use the tools and operations allowed by the problem? Do the intermediate points, lines, and circles generated match the problem description?
    3. Presentation Layer: Does the animation or output file sync with the construction process? Do pauses, trajectories, and trace retention meet the requirements? Is the export format correct?

    Among these three, the result layer is the easiest to pass, the process layer best reflects the quality of reasoning, and the presentation layer reflects engineering completeness. Evaluating only the result layer makes it difficult to discover whether the model took an incorrect approach.

    III. Common Failure Modes

    In actual testing, the following types of issues are typical:

    (1) Correct result, deviated process. The model might use a shortcut to directly calculate the vertex coordinates of a regular polygon and then draw them using a plotting function. The image is completely correct, but the model did not execute the required construction steps. If the task explicitly specifies a construction method, such results should be deemed unqualified.

    (2) Unjustified intermediate steps. Some implementations might introduce auxiliary points not present in the problem description or use unexplained approximate values, leading to the accumulation of final errors. The verification method involves checking the source of each new object step-by-step.

    (3) Animation-logic disconnect. The animation might just be playing pre-written frames, with no connection to the actual computational process. When parameters are modified, the animation does not change accordingly, indicating that the presentation layer is not driven by the process layer.

    (4) Incomplete output. After long reasoning, there might be cases where only the thought process is outputted without usable code, or the code is truncated midway. These issues are related to the model’s generation stability and long-output capability and need to be recorded separately.

    IV. Designing the Evaluation Scheme

    It is recommended to score based on the following dimensions, providing a pass/fail judgment for each item and recording the reasons.

    Dimension Check Content Judgment Method
    Geometric Correctness Consistency of vertex count, side lengths, and circumradius Numerical verification, error below threshold
    Step Legality Is each new object generated by allowed operations? Manual or script step-by-step verification
    Step Completeness Are all required sub-steps implemented? Check against step list
    Animation Synchronization Does the animation order match the computation order? Observe changes after modifying input
    Output Format Is the specified format file exported as required? Open and check directly
    Stability Are results consistent across multiple runs? Is output complete? Run at least three times

    During testing, prompts, runtime environments, and random seeds (if applicable) should be fixed, and raw outputs should be saved for review.

    V. Sample Inspection Code

    For regular polygon results, the following function can be used for numerical verification. This function only checks geometric properties, not the construction process; process verification requires integration with step logs.

    1. import math
    2. def is_regular_polygon(points, tol=1e-6):
    3. """points: list of vertices arranged in order [(x, y), ...]"""
    4. n = len(points)
    5. if n < 3:
    6. return False
    7. # Approximate center using the average of vertices
    8. cx = sum(x for x, _ in points) / n
    9. cy = sum(y for _, y in points) / n
    10. # Distance from each vertex to the center should be equal
    11. radii = [math.hypot(x - cx, y - cy) for x, y in points]
    12. radius_ok = max(radii) - min(radii) < tol
    13. # Length of each side should be equal
    14. sides = [math.dist(points[i], points[(i + 1) % n]) for i in range(n)]
    15. side_ok = max(sides) - min(sides) < tol
    16. return radius_ok and side_ok
    17. # Example validation for a regular heptagon
    18. heptagon = [
    19. (math.cos(2 * math.pi * k / 7), math.sin(2 * math.pi * k / 7))
    20. for k in range(7)
    21. ]
    22. print(is_regular_polygon(heptagon)) # Output: True

    The process layer can be designed as a log-recording structure. Each step records the operation type, input objects, and output objects. The validator checks whether each input object has appeared in a previous step and whether the operation type is in the allowed list.

    VI. Practical Advice and Limitations

    First, “allowed operations” and “forbidden shortcuts” should be clearly defined before evaluation; otherwise, it is difficult to determine if the result is compliant.

    Second, passing the result layer does not mean passing the process layer. When reporting test conclusions, judgments for both layers should be provided separately to avoid substituting a correct image for a correct method.

    Third, a single test conclusion is unreliable. Model outputs are random; you should run multiple times and calculate the pass rate.

    Fourth, geometric drawing tests are just one slice of capability. They are suitable for testing combined multi-step reasoning and code implementation skills, but cannot represent the model’s performance on other tasks. They should be used in combination with tests for code completion, bug fixing, and document understanding.

    Fifth, test samples should be updated regularly to avoid artificially inflated scores caused by training data leakage. For public problems, parameter variants can be designed—such as changing the number of sides or the initial shape—to observe whether the model truly understands the method.

    In conclusion, the core value of geometric drawing tests lies in splitting “whether the correct image is achieved” into “whether the correct method was used to achieve the image.” Adopting an evaluation approach that uses layered checks, process logs, and multiple runs can more accurately reflect the model’s true capabilities, making it highly suitable for engineering selection and quality assurance.