Evaluating Code Generation Models with Geometric Construction Tasks

    Visual output tasks like geometric construction reveal whether a code generation model can truly understand instructions, reason about geometry, and produce correct code. This article explains how to design verifiable geometry-based benchmarks, break tasks into independently scored capability layers, replace visual judgment with numerical checks, and structure scoring dimensions to expose common failure modes, offering practical guidance for building a low-cost, high-signal evaluation pipeline.

    Evaluating Code Generation Models with Geometric Construction Tasks

    1. Why Test with Graphical Output

    Text-based Q&A tests can easily be fooled by superficially fluent answers. A model may produce a derivation that looks correct, yet the generated code renders a misaligned figure or an animation that skips a critical step. Graphical output turns abstract reasoning into something directly observable: whether a point lands in the right position, whether a line segment passes through the expected intersection, and whether animation frames are continuous. This makes such tasks well suited for testing the full chain of “understanding instructions, reasoning about geometric relationships, and implementing them in code.”

    It is worth noting that the value of this kind of test lies in exposing the boundaries of a model’s capability, not in ranking models. The result of a single problem only reflects performance on that class of task and cannot be generalized to all scenarios.

    2. Breaking One Problem into Verifiable Capability Points

    A seemingly simple construction problem usually tests multiple abilities at once. Take “complete a regular polygon construction with restricted tools and output an animation” as an example. It can be decomposed into five layers:

    1. Instruction parsing: identifying the order of steps and distinguishing which steps are given by the problem from the omitted parts the model must fill in on its own.
    2. Geometric reasoning: understanding relationships among perpendicular bisectors, circles, and intersections—for example, that any point on a perpendicular bisector is equidistant from the segment’s two endpoints.
    3. Numerical computation: determining circle radii and intersection coordinates with enough precision for rendering.
    4. Drawing implementation: correctly mapping geometric objects onto the canvas coordinate system, handling coordinate orientation and scaling.
    5. Animation and export: controlling the frame sequence, keeping traces only where necessary, and exporting the result to a standard animated image format.

    Each layer can be scored independently. If you only judge whether the final image roughly looks right, an instruction-understanding error at layer one and a drawing error at layer four get mixed together, making it impossible to locate the problem.

    3. Basic Principles for Designing Benchmark Problems

    1. Verifiable endpoints. Every problem should have a clear pass condition. For example, “a tick mark passes through the perpendicular bisector of the base” can be converted into a mathematical condition, and a program can check whether the error in the simulated result is within tolerance. A problem without a verifiable endpoint can only rely on subjective human scoring, and the results are hard to reproduce.

    2. Layered difficulty. Split each problem into subtasks, from drawing basic shapes, to deriving intersection positions, to producing animations. With layering, you can observe at which layer the model starts to fail, rather than getting a single pass/fail verdict.

    3. Beware of “looks right.” A figure may appear visually close to correct while its geometric relationships are badly off. Use numerical checks instead of eyeballing—for example, verify that all vertices are equidistant from the center and that adjacent side lengths are consistent.

    4. Control variables. Run the same problem multiple times and record result stability. If outputs vary widely for the same input, the task is sensitive to randomness, and this should be noted in the report.

    4. Example: Replacing Visual Judgment with Numerical Checks

    The following code demonstrates basic validation of a generated geometric result. It assumes the output contains a set of vertex coordinates and checks whether they satisfy the fundamental conditions of a regular polygon.

    1. import math
    2. def check_regular_polygon(vertices, n, tol=1e-3):
    3. """Check whether the vertex list forms a regular n-gon with equal sides and equal distances to the center."""
    4. if len(vertices) != n:
    5. return False, "Vertex count mismatch"
    6. cx = sum(x for x, _ in vertices) / n
    7. cy = sum(y for _, y in vertices) / n
    8. radii = [math.dist((x, y), (cx, cy)) for x, y in vertices]
    9. if max(radii) - min(radii) > tol:
    10. return False, "Vertex distances to center are inconsistent"
    11. sides = [
    12. math.dist(vertices[i], vertices[(i + 1) % n])
    13. for i in range(n)
    14. ]
    15. if max(sides) - min(sides) > tol:
    16. return False, "Side lengths are inconsistent"
    17. return True, "Pass"

    The value of this code is that its pass conditions are explicit. It doesn’t care about code style or visual polish—only whether the result holds mathematically. In a real evaluation, you should add angle checks and intersection-position checks as well.

    5. Scoring Dimensions and Common Failure Modes

    We recommend setting the following dimensions for each problem:

    • Instruction completeness: whether all steps are covered and whether omitted parts that should have been filled in are missing.
    • Geometric correctness: whether key points and lines satisfy the mathematical conditions.
    • Numerical precision: whether errors fall within the allowed tolerance.
    • Engineering usability: whether the code runs directly and dependencies are clear.
    • Output quality: whether the animation is continuous and the exported file opens properly.

    In practice, common failure modes include:

    1. Skipping the steps the problem asks the model to fill in and jumping straight to the conclusion.
    2. Misunderstanding geometric conditions—for example, treating a perpendicular bisector as an angle bisector.
    3. Getting the coordinate system orientation wrong, producing an upside-down figure.
    4. Lacking state continuity between animation frames, causing traces to jump.
    5. Claiming an export capability that produces files which cannot actually be used.

    Recording these failure modes is more valuable than simply counting pass rates. It provides direct input for improving prompts and selecting models.

    6. Practical Recommendations

    When building the evaluation pipeline, you can proceed in this order:

    1. Write down the mathematical conditions of a problem first, then the natural-language description.
    2. Write a numerical check function for each condition, and validate the check functions themselves using manually constructed correct and incorrect samples.
    3. Fix the runtime environment and random parameters, and test each problem multiple times.
    4. Archive scores by capability dimension to enable cross-version comparison.
    5. Update the problem set regularly, so that long-public problems are not specifically optimized against, which would destroy their discriminative power.

    Geometric construction problems are small in scope, yet they cover four categories of ability: comprehension, reasoning, computation, and implementation. With careful design, they make a low-cost, information-dense evaluation tool.