Evaluating Lightweight Language Models: A Geometric Programming Verification Practice

    Learn how to evaluate lightweight language models through a geometry programming task. This article covers capability dimensions, constraint modeling, numerical solving with residuals, layered web implementation, result verification, and reproducible benchmarking for reliable model selection.

    1. Evaluating Lightweight Models: Distinguish Positioning from Actual Capability

    Lightweight language models are typically aimed at scenarios sensitive to response latency, compute resources, or API costs. But “lightweight” is not a unified technical specification. It does not necessarily mean weaker reasoning, and you cannot infer model size, internal architecture, or deployment requirements from the name alone.

    For developers, the more valuable question is: can the model reliably complete real tasks within a given resource budget?

    One model may respond quickly on short text generation but frequently drop conditions in multi-constraint programming tasks. Another may generate more slowly, yet reduce manual rework so much that overall delivery is actually faster. Evaluation therefore cannot stop at “how fast is the output” or “how pretty is the page.” It should cover at least the following dimensions:

    • Task correctness: does the final result satisfy the requirements, and are the key conclusions valid?
    • Constraint adherence: are the specified methods, operation order, and interaction requirements preserved?
    • Engineering completeness: does the code run, and are edge cases and failure states handled?
    • Verifiability of results: does the model provide derivations, residuals, or tests rather than verbal assurances?
    • End-to-end efficiency: from submitting the requirement to obtaining an acceptable result, how much total time and manual effort is required?

    Without unified test conditions and repeated experiments, a single successful case only shows that a model has some potential. It cannot support a conclusion of overall superiority.

    2. Why a Geometry Web Task Works Well as a Capability Probe

    Common web page generation tests tend to overemphasize visual effect. A tidy layout, harmonious colors, and smooth animations do reflect part of a model’s code generation ability, but they do not necessarily test complex reasoning.

    By contrast, the task “use a marked ruler to assist in constructing a regular heptagon, and build an interactive geometry demonstration web page” involves multiple interdependent stages:

    1. Convert the geometric operations described in natural language into precise definitions;
    2. Distinguish the capability boundaries of an unmarked straightedge and compass versus a marked ruler;
    3. Establish constraint relationships among points, lines, and circles;
    4. Solve for the geometric positions that satisfy the constraints;
    5. Convert the solution into an explainable drawing process;
    6. Verify whether the final figure is truly the target figure.

    The value of this kind of task is not in comparing whose heptagon looks prettier, but in observing whether the model can connect “mathematical definition — numerical solving — program state — visual presentation” end to end.

    That said, a single geometry test is still only a capability probe. It cannot replace a complete evaluation oriented toward real business workloads.

    3. First Identify the Mathematical Premises; Don’t Use Animation to Mask Missing Conditions

    A regular heptagon cannot be constructed exactly using only an unmarked straightedge and compass. A ruler with fixed markings allows additional positional constraints and belongs to a different operational system from classical straightedge-and-compass construction. Therefore, the evaluation should first check whether the model understands the tool permissions, rather than jumping straight into writing the page.

    The core requirement of the original task can be abstracted as:

    First define a square and the perpendicular bisector of its base; then draw a circle centered at the lower-right vertex with the square’s diagonal as radius; then adjust a marked ruler passing through the lower-left vertex so that its two marks satisfy positional conditions relative to the circle and the perpendicular bisector.

    But this description alone is not sufficient to produce a unique, complete implementation. At minimum, the following must also be clarified:

    • What is the distance between the two marks?
    • Is the lower-left vertex on the ruler’s edge, or must it coincide with one of the marks?
    • How is the front-to-back order of the two marks along the ruler determined?
    • Are there restrictions on the quadrant, ray direction, or valid region where the ruler may lie?
    • If multiple positions satisfy the conditions, which branch is chosen?
    • After the ruler operation, how are the target side length or target circle obtained from the known points?

    Among these, the mark spacing is a substantive mathematical condition and cannot be assigned arbitrarily just to make the program run. If the construction basis does not specify it, it should be listed as a condition pending confirmation, rather than claiming the exact construction is complete.

    Admitting that conditions are insufficient is usually more reliable than generating an animation that looks complete but cannot actually be proven.

    4. Converting the Geometric Narrative into Computable Constraints

    For ease of implementation, let the square have side length (a>0), and take the lower-left vertex as:

    [
    D=(0,0)
    ]

    The lower-right vertex is:

    [
    E=(a,0)
    ]

    The perpendicular bisector of the base is then:

    [
    x=\frac a2
    ]

    The circle centered at (E) with the square’s diagonal as radius satisfies:

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

    Let the unit direction vector of the ruler be:

    [
    u=(\cos\theta,\sin\theta)
    ]

    If the line containing the ruler passes through (D), the points corresponding to the two marks can be written as:

    [
    P=D+tu
    ]

    [
    Q=D+(t+s)u
    ]

    where (s>0) is the fixed distance between the two marks, and (t) is the signed position of the first mark relative to (D).

    Requiring the first mark to lie on the circle and the second mark to lie on the perpendicular bisector gives:

    [
    (t\cos\theta-a)^2+(t\sin\theta)^2=2a^2
    ]

    [
    (t+s)\cos\theta=\frac a2
    ]

    The importance of this modeling step is that it turns “move the ruler until the conditions hold” into a computable and verifiable problem.

    Note, however, that these equations only express the mark placement conditions. They do not automatically prove that a regular heptagon can subsequently be constructed. A complete solution must also provide the geometric derivation from the solved points to the final polygon.

    5. Numerical Solving Must Include Branches, Residuals, and Failure Handling

    Simply rotating the ruler at preset angles until it visually approaches the target position is not rigorous solving. A more robust implementation solves first, then plays back the construction process.

    A general workflow looks like this:

    1. Input geometric scale, mark spacing, allowed directions, and error threshold
    2. Set up positional constraints for the mark points
    3. Search for candidate solutions within the allowed range
    4. Refine the candidates numerically
    5. Compute residuals for each constraint
    6. Filter out solutions that violate direction or position limits
    7. If multiple valid solutions exist, select one by an explicit rule
    8. If no valid solution exists, display the failure reason

    For the conditions above, the circle constraint residual can be defined as:

    [
    r_1=\left||P-E|-a\sqrt2\right|
    ]

    and the perpendicular bisector constraint residual as:

    [
    r_2=\left|Q_x-\frac a2\right|
    ]

    To accommodate different drawing scales, normalized residuals can be used:

    [
    \hat r_i=\frac{r_i}{a}
    ]

    Only when all relevant residuals fall below a pre-declared threshold should the program mark the step as complete.

    Error thresholds should be set based on numerical precision, the solving method, and display requirements. “The deviation is invisible on screen” must not be used as the acceptance criterion. For near-degenerate positions, numerical stability should also be checked to avoid tiny input changes causing the construction branch to switch abruptly.

    6. Distinguish “Drawing a Regular Heptagon” from “Completing the Specified Construction”

    A program can easily draw a regular heptagon by evenly dividing the central angle. Given a center (O) and radius (R), the vertices are:

    [
    V_k=O+R
    \left(
    \cos\left(\varphi+\frac{2\pi k}{7}\right),
    \sin\left(\varphi+\frac{2\pi k}{7}\right)
    \right)
    ]

    where (k=0,\ldots,6).

    This formula is suitable for generating a reference figure and for verifying the final result. But if the task requires demonstrating a specific construction process, these vertices must not be quietly substituted for the derived results.

    Otherwise, the page becomes misleading: the ruler, circle, and auxiliary lines at the front are merely decoration, while the final heptagon comes from a different computation entirely.

    The correct approach is to keep the two kinds of data separate:

    • Constructed result: produced by the operations allowed in the task and by proven relationships;
    • Reference result: generated from the analytic formula, used only for error comparison.

    If the construction chain is not yet closed, the page should be clearly labeled “constraint solving demonstration” or “construction proof pending,” rather than claiming an exact construction has been completed.

    7. The Web Implementation Should Use a Layered Structure

    For ease of inspection and maintenance, the program should be divided into three layers.

    7.1 Geometry and Solving Layer

    Responsible for points, vectors, lines, circles, intersections, distances, and constraint solving. This layer does not depend on page elements, making it easy to test independently.

    Geometric computation must handle tangency, non-intersection, coincidence, and near-parallelism. It must not assume a unique intersection every time.

    7.2 Construction State Layer

    Responsible for organizing operation steps, such as “create the square,” “draw the auxiliary circle,” “solve the ruler position,” and “generate subsequent auxiliary lines.”

    Each state should explicitly record its input objects, output objects, and conditions of validity. This enables step-back, step-forward, reset, and jumping to a specific step, instead of guessing progress from animation timing.

    7.3 Presentation and Interaction Layer

    Responsible for coordinate transformation, object rendering, labels, zooming, and playback control.

    The presentation layer may interpolate positions for smooth animation, but intermediate frames must be treated as transitional states. A constraint cannot be considered satisfied merely because the picture passed through a certain position.

    8. How to Verify the Final Figure and the Construction Process

    Complete acceptance cannot merely check “whether there are seven vertices.” It should cover at least three categories of metrics.

    The first is the correctness of local operations: whether the mark points lie on the specified circle, whether auxiliary lines are perpendicular, and whether a circle center comes from the intersection of the corresponding perpendicular bisectors.

    The second is the correctness of the final figure. Check the consistency of the seven side lengths, the consistency of vertex-to-center distances, and whether the central angle between adjacent vertices is close to:

    [
    \frac{2\pi}{7}
    ]

    Also check the vertex ordering and edge connectivity, to avoid connecting equally spaced vertices into a self-intersecting figure.

    The third is the correctness of process dependency. The final vertices must be traceable to the allowed construction steps, rather than being overwritten by reference coordinates during rendering.

    Numerical checks increase credibility but cannot replace general mathematical proof. Especially when discussing “exact construction,” one must clearly distinguish between geometric conclusions, floating-point approximations, and display effects.

    9. Upgrading a One-Off Demo into a Reproducible Model Evaluation

    To compare the actual capabilities of different lightweight models, fix the task description, runtime environment, output budget, and number of repair attempts, and save the raw responses along with every modification record.

    It is recommended to track separately:

    • The proportion of outputs that run on the first generation;
    • Recognition of mathematical premises and constraints;
    • The proportion of geometric results passing verification;
    • Omissions of key requirements;
    • Manual repair time;
    • First response latency and full generation time;
    • Total time to reach an acceptable state.

    Among these, “total time to reach an acceptable state” is usually closer to business value than raw generation speed. A slower output that is correct the first time may be more efficient than a very fast output that requires repeated fixes.

    In addition, the test set should include different task types, such as state management, data validation, edge-case handling, and requirement changes, to prevent generalizing one geometry problem’s performance into a broad capability conclusion.

    10. Conclusion: The Advantage of Lightweight Models Should Be Proven by Reliable Delivery

    The potential advantage of lightweight models worth attention is completing sufficiently complex work under limited resources—not visual wow in a single demo.

    Through a geometry programming task, you can deeply observe whether a model can identify incomplete conditions, build constraints, handle multiple solutions, organize program state, and verify results. These abilities are much closer to real engineering needs than simply generating a pretty page.

    For developers, a reliable selection principle is: define acceptable results first, build reproducible tests second, and then comprehensively compare correctness rate, repair cost, response latency, and resource overhead. Only through such verification can there be a clear and credible answer to whether a lightweight model suits a given workload.