Evaluating Lightweight LLMs: From Web-Based Geometry Construction to Constraint Verification

    This article explains how to test lightweight large language models with a geometry construction web page. It covers turning vague requirements into an executable specification, checking whether generated code follows the specified construction method, verifying results numerically, and measuring cost, time, and manual repair effort.

    1. How should we judge the advantages of a lightweight LLM?

    Developers who choose a lightweight LLM usually want lower call costs, faster response times, and enough reasoning and code generation ability to handle everyday tasks. However, “lightweight” does not automatically mean “faster,” and “flagship” is not a quantifiable technical metric. The meaningful question is whether the model can reliably complete the target task under a given resource budget and time constraint.

    In intelligent programming scenarios, the code a model outputs may be syntactically correct and visually polished, yet fail to implement the algorithm the user specified. If we only look at the final screenshot, it is easy to mistake “the result looks correct” for “the task is complete.”

    Therefore, evaluating a lightweight LLM should distinguish at least three levels:

    • Expressive ability: Can the model clearly explain the requirements and generate well-structured code?
    • Execution ability: Does the code run, and do interaction, animation, and export features work?
    • Semantic correctness: Does the implementation follow the specified method, and do the computed results satisfy the mathematical or business constraints?

    Of these, the third level is the easiest to overlook, and it is also the most important acceptance condition for complex tasks.

    2. Why is a geometry construction web page a good test case?

    A geometry construction web page looks like a small front-end project. In practice, it involves requirement understanding, mathematical modeling, numerical computation, state management, dynamic graphics, and file encoding, which makes it a comprehensive test with high information density.

    For example, one task asks the model to use a given square, a circle, and two-mark ruler operations to demonstrate the construction of a regular heptagon, fill in the missing intermediate steps, and provide animated image export. The model cannot just draw seven evenly spaced vertices. It also needs to explain how each auxiliary object is produced and how later steps depend on earlier results.

    A regular heptagon cannot be constructed exactly with only a classical unmarked straightedge and compass. Introducing a marked ruler changes the set of allowed operations. This does not mean that any vague description of two-mark ruler operations is enough to determine a correct construction.

    Therefore, the test does not really check whether the model can draw a heptagon. It checks whether the model can identify the problem definition, establish valid constraints, and keep the program’s implementation consistent with the mathematical process.

    3. Turn the problem into an executable specification before testing

    Natural-language requirements often contain implicit conditions. If these conditions are not unified, different models may solve different problems, and the test results lose comparability.

    1. Define the two-mark ruler clearly

    A two-mark ruler usually refers to a straightedge with two fixed marks, and the distance between the two marks stays constant during operations. The test must specify:

    • the distance between the two marks, or its relationship to the side length of the square;
    • whether passing the ruler through a specified vertex means that the ruler’s edge passes through that point, or that one of the marks coincides with that point;
    • which geometric condition the first and second marked points must satisfy;
    • whether the ruler’s orientation is restricted, and how to choose the target solution among multiple possible solutions.

    If any of these is ambiguous, it may affect the subsequent construction. A high-quality model should actively point out missing necessary information rather than quietly adding unstated conditions.

    2. Fix coordinates and scale

    Let the side length of the square be (a), with the lower-left corner at (D=(0,0)) and the lower-right corner at (E=(a,0)). Then the perpendicular bisector of the bottom edge is:

    [
    x=\frac{a}{2}
    ]

    The circle centered at the lower-right corner, with a radius equal to the square’s diagonal, can be expressed as:

    [
    (x-a)^2+y^2=2a^2
    ]

    These equations only describe the geometric objects that are explicitly given. They are not enough on their own to prove that the subsequent steps will form a regular heptagon. The test program must also combine the mark spacing, the ruler’s position relationships, and the complete construction rules to establish the remaining constraints.

    A unified coordinate system lets different implementations be checked against the same numerical criteria, without relying on screen size or visual judgment.

    3. Define the boundaries of “filling in the missing steps”

    Asking a model to supply omitted steps does not mean it may freely replace the algorithm. Reasonable additions include drawing perpendicular lines, finding intersections, and constructing segment perpendicular bisectors, which the construction logic already requires. If the model introduces new key auxiliary points, a different positioning method, or directly uses a coordinate formula for the target polygon, that choice must be explained and verified separately. It cannot be assumed to follow the original requirement.

    4. Separate “drawing the target” from “implementing the construction”

    This is the most critical judging principle in the entire test.

    If the program first computes seven equally spaced points on the circle and then uses animation to show some auxiliary lines, the final figure may look very regular. But those auxiliary lines may not actually participate in determining the vertices. Such an implementation completes “drawing a regular heptagon,” but not “constructing a regular heptagon by the specified method.”

    A reliable implementation should have explicit data dependencies:

    1. Generate auxiliary lines and circles from the initial objects;
    2. Compute the relevant positions according to the two-mark ruler constraints;
    3. Use these positions to compute subsequent intersections, centers, or side lengths;
    4. Generate the final vertices from the construction results;
    5. Pass the same set of geometric objects to the rendering module for drawing.

    During acceptance, check the source of the final vertices. Were they computed by the construction steps, or does an independent target-shape generation function output them directly?

    The latter can be used for verification or comparison, but it should not be presented as the construction process itself.

    5. Numerical verification cannot rely on visual inspection

    For small figures on screen, an approximate regular heptagon and a result that truly satisfies the constraints may be hard to tell apart. Therefore, a numerical verification mechanism should be established.

    1. Check basic constraint residuals

    Suppose a point corresponding to one mark is (P=(x_P,y_P)), and it must lie on the circle above. We can compute:

    [
    r_{\text{circle}}=
    \left|(x_P-a)^2+y_P^2-2a^2\right|
    ]

    If another mark point (Q) must lie on the perpendicular bisector of the bottom edge, check:

    [
    r_{\text{line}}=\left|x_Q-\frac{a}{2}\right|
    ]

    In addition, verify constraints such as fixed mark spacing and the collinearity of points with the ruler. Since different residuals may have different units, normalize them separately by the side length or the square of the side length, then set reasonable tolerances.

    2. Check the final polygon

    For the vertex sequence (V_0,\ldots,V_6), verify at least:

    • whether the seven side lengths agree within tolerance;
    • whether the vertices lie on the same circle;
    • whether the central angles between adjacent vertices are close to (2\pi/7);
    • whether the vertex order is correct and whether any edges intersect;