Evaluating Code Generation Models with Geometric Construction Tasks
This article explains why geometric construction tasks are a more effective benchmark for evaluating code generation models than typical programming exercises. It outlines a task design framework, a hierarchical task decomposition method, and a scoring rubric covering geometric correctness, step completeness, animation logic, interaction quality, and code quality. Common failure modes such as coordinate system confusion and incomplete constraint updates are discussed, along with practical recommendations for building reliable evaluation sets. The approach translates abstract reasoning into observable, verifiable outputs, making it a valuable complement to standard model benchmarks.
Why Use Construction Tasks for Evaluation
Typical code generation benchmarks often ask models to implement a sorting function or build a form page. These tasks have a large solution space, but the difficulty is concentrated in a narrow band, making it hard to distinguish differences in complex reasoning capabilities. Geometric construction tasks offer a better alternative: every step is governed by explicit mathematical constraints, and the results can be verified through coordinates and distances. At the same time, the model must translate natural-language instructions into runnable UI code.
Evaluation with such tasks must check three abilities simultaneously: correctly interpreting geometric steps, mapping those steps to drawing logic, and implementing the correct dynamic behavior on both visual and interactive levels. If any one of these is missing, the page may look roughly correct while the details are already wrong.
Task Design Principles
- Steps must be decomposable. Each task contains several sub-steps with clear dependencies, and each step’s output can be checked independently.
- Constraints must be quantifiable. For example, “the radius of the circle equals the diagonal length of the square” can be computed and verified directly.
- Omissions are intentional. Standard construction steps that are deliberately omitted require the model to fill in the gaps, testing its understanding of geometric conventions.
- Output must be observable. The final result should be rendered as a directly runnable page, with support for exporting frame-by-frame images or an animated GIF for both manual and automated inspection.
Breaking a Task into Sub-Tasks
Consider a problem that constructs a regular heptagon using a “two-notch ruler” (a ruler with two marked ticks). The task can be split hierarchically:
- Base layer: Draw a square, label all vertices, and correctly compute the diagonal length.
- Geometric layer: Construct the perpendicular bisector of the base edge and find its intersection with a relevant side of the square.
- Dynamic layer: Draw a circle centered at a given vertex with radius equal to the diagonal length. Move the ruler under constraints until the second tick mark passes through the target segment.
- Finishing layer: Complete routine operations such as determining the circle center and perpendicular bisectors on the obtained points, keeping only necessary construction lines.
- Export layer: Export the entire animation as a GIF.
Each layer can be scored independently. If the coordinates in the base layer are wrong, the subsequent animation will necessarily deviate from the correct result. Thus, the scoring process must account for error propagation to avoid double-penalizing the same mistake.
Scoring Dimensions
The following framework can be used, with each dimension scored from 0 to 2:
- Geometric correctness: Whether the error between key coordinates and theoretical values stays within a tolerance.
- Step completeness: Whether all omitted construction steps are covered.
- Animation logic: Whether movement paths are continuous and whether trace-keeping rules match the problem statement.
- Interaction and output: Whether the page runs directly and the GIF export function works.
- Code quality: Whether the structure is clear, with no undefined variables or redundant drawing.
Geometric correctness can be verified automatically with numerical checks. For example, to verify that a point lies on a given circle:
import mathdef on_circle(px, py, cx, cy, r, eps=1e-6):return abs(math.hypot(px - cx, py - cy) - r) <= eps
Such checks quickly catch coordinate calculation errors. Animation smoothness and trace-keeping rules, however, require human review of the output.
Common Failure Modes
In these tasks, model errors typically fall into the following categories:
- Mixed coordinate systems. Screen coordinates have a y-axis that points downward, while mathematical coordinates point upward. Mixing them flips the figure vertically.
- Incorrect radius definition. Using the side length instead of the diagonal, or treating the diameter as the radius.
- Partially updated constraints. When moving the ruler, only the endpoints are updated without recalculating the intersection with the circle.
- Inaccurate trace rules. All intermediate points leave traces, or the required traces are cleared.
- Non-continuous animation frames. Each frame jumps directly to the target position without interpolation, making the exported GIF look like a slideshow instead of a smooth motion.
To mitigate these issues, the problem statement should explicitly define coordinate conventions, units, and drawing rules. The fewer ambiguities, the more the evaluation reflects the model’s actual capability rather than its guesses about intent.
Implementation Recommendations
- Version the task set. The evaluation set needs a version number so that results from different times are comparable.
- Keep intermediate artifacts. Record coordinates and screenshots at every step to locate the stage where an error occurs.
- Sample multiple times. Run the same task multiple times and report the pass rate rather than relying on a single result.
- Human review. Automated checks cover numerical correctness, but visual quality still requires manual judgment.
- Rotate tasks periodically. Publicly available tasks can be overfit. Change the construction target, for example by using other regular polygons or different straightedge-and-compass problems.
This type of testing turns abstract reasoning ability into observable, verifiable outcomes. It cannot replace a full benchmark suite, but it quickly exposes gaps between geometric reasoning and front-end implementation, making it a useful supplementary component in an internal evaluation pipeline.
