Evaluating the Coding Capabilities of Lightweight Models: How to Assess and Verify Real-World Performance

    Lightweight AI models are often judged by their ability to balance cost, latency, and output quality, but a simple "it works" demo is not enough. This article explains how to rigorously evaluate and verify a lightweight model's coding capabilities, using a complex web animation task — constructing a regular heptagon with a marked ruler — as a concrete example. It covers the difference between correct output and correct process, how to break a prompt into testable technical specifications, the importance of geometric verification before implementation, a layered design for the web page, and a reproducible evaluation method that tracks not just the final result but also the construction steps. The goal is to help developers determine whether a lightweight model can reliably reduce the cost of trustworthy delivery in real engineering scenarios.

    Why “It Works” Is Not Enough for Lightweight Models

    The real value of a lightweight model lies in balancing response cost, interaction latency, and task completion quality. But “lightweight” is not a unified technical specification, nor does it directly imply a certain parameter count, inference speed, or coding capability. For developers, the more important question is: can the model reliably complete a target task under limited resources and clear constraints?

    A representative test from the original case is instructive: ask the model to generate a webpage that uses animation to demonstrate the construction of a regular heptagon using a marked ruler (a ruler with two scale marks), fills in the omitted construction steps, and finally supports exporting the animation file.

    On the surface, this is a web programming task. In reality, it involves geometry understanding, constraint solving, interaction design, animation choreography, and file generation. It exposes a common problem: the generated result may look like a correct answer, but the internal implementation may bypass the intended construction method.

    For example, the model could simply compute the seven vertices of a regular heptagon and then draw some auxiliary lines so the page appears to show a step-by-step construction. The visual output might be beautiful, but it does not prove that the specified construction method was correctly implemented.

    Therefore, evaluation must distinguish two questions:

    • Is the final figure correct?
    • Was the final figure obtained through the required steps?

    For engineering tasks, this distinction applies equally to data processing, permission checks, business workflows, and algorithm implementations. Correct output does not guarantee a compliant process.

    Breaking a Complex Prompt into Testable Technical Specifications

    The original task involves a square, the perpendicular bisector of its bottom side, a specified circle, the movement of a marked ruler, the determination of subsequent centers, and animation export. Handing these requirements directly to a model often leads to confusion and omitted details.

    A safer approach is to first organize them into four layers of specifications.

    1. Geometry Input Layer

    Clearly define the square’s vertex names, side length, coordinate orientation, and which vertex serves as the center and as the ruler’s contact point.

    The definition of the marked ruler must also be specified. The key point is not just that “the ruler has two scale marks,” but also the distance between the marks, its relationship to the square’s side length, and the geometric constraints that must remain true while the ruler moves.

    If this information is missing, the task may not be uniquely determined. The model should proactively point out ambiguity or clearly label any assumptions used for demonstration, rather than silently adding conditions and presenting the result as a strict solution to the original problem.

    2. Construction Process Layer

    Break the description into concrete operations, for example:

    1. Establish the initial square.
    2. Construct the perpendicular bisector of the bottom side.
    3. Draw a circle centered at the specified vertex with a radius equal to the square’s diagonal.
    4. Show the marked ruler moving under its constraints.
    5. Mark the position(s) that satisfy the scale-mark condition.
    6. Complete the subsequent construction steps using the confirmed geometric relationships.
    7. Generate the final polygon and verify it.

    Here, “completing the subsequent construction” is not free-form. Any new step must have a clear geometric justification and must not change the originally allowed set of operations.

    3. Animation Presentation Layer

    Distinguish between the current tool, auxiliary objects, historical traces, and the final result. For instance, the current position of the compass should be managed separately from already drawn arcs; when moving the ruler, you should not default to permanently retaining every position it passes through.

    “Leave traces only where necessary” should be turned into explicit display rules, not left to the model’s subjective sense of visual effect.

    4. Delivery Function Layer

    The page being able to play does not mean the entire task is complete. You must also check pause, replay, step skipping, window resizing, and file export.

    In particular, the export function must actually generate an openable animation file, not just place a button or show an “Export Successful” message.

    Geometric Correctness: Prove It Before You Draw It

    The technical difficulty in this case lies first in geometry, not in page styling.

    It is important to note that a regular heptagon cannot be constructed precisely with only a classical unmarked straightedge and compass. A marked ruler can introduce extra construction capability under specific usage rules, but that does not automatically mean any two scale marks and any movement constraint will achieve the goal.

    Therefore, you must not misinterpret “a marked ruler can participate in construction” as “the given vague steps are definitely valid.” During evaluation, you should first verify the construction conditions and the mathematical derivation, then discuss code quality.

    1. Expressing Constraints with Coordinates

    Set coordinates for the initial square:

    • Lower-left corner D = (0, 0)
    • Lower-right corner E = (a, 0)
    • The other two vertices are (0, a) and (a, a)
    • The perpendicular bisector of the bottom side is x = a/2
    • The circle centered at E with radius equal to the diagonal satisfies:

    (x – a)² + y² = 2a².

    If the ruler’s line passes through D, you can describe points on the ruler with a direction vector:

    P = t₁(cosθ, sinθ)
    Q = t₂(cosθ, sinθ)

    Then write equations for “the first mark lies on the circle,” “the second mark lies on the perpendicular bisector,” and “the distance between the two marks is fixed.”

    Whether t₁ and t₂ can take negative values, how the marks are ordered, and in which direction the ruler is allowed to move all need to match the real construction rules. Ignoring these conditions may lead the solver to a position that is algebraically valid but operationally forbidden.

    2. Numerical Solving Is Not Equal to Geometric Construction

    A web implementation can use numerical methods to find a position that satisfies the constraints, but it should honestly state that it is a numerical simulation of the geometric conditions.

    If the task requires a complete demonstration of the construction process, it is not acceptable to compute the final vertices first and then add decorative auxiliary lines in reverse. Numerical solving should serve the confirmed construction relationships, not replace the explanation of the construction itself.

    You should also specify the error tolerance, the rule for selecting among candidate solutions, and how to handle cases where no solution is found. When multiple solutions exist, you must filter them according to geometric position and step requirements, not simply take the first result.

    3. Verifying Both the Result and the Process

    The final regular heptagon should at least satisfy:

    • The seven vertices are approximately equidistant from the same center.
    • The seven side lengths are approximately equal.
    • The central angles between adjacent vertices are approximately 2π/7.
    • The vertex order is correct, and the polygon does not self-intersect.

    Errors are best measured using relative quantities, such as dividing the side-length error by the average side length, to avoid the acceptance criteria failing when the figure is scaled up or down.

    But these metrics only verify the final figure. You must also check whether the key points lie on the specified objects, whether the ruler always maintains the required contact and scale conditions, and whether the auxiliary lines are generated by the allowed operations. Result verification and process verification are both indispensable.

    Web Implementation: Let Mathematics, Animation, and Interface Each Do Its Job

    The most common problem in complex animations is mixing coordinate calculation, drawing code, and time control together. Once a geometric condition changes, the entire program becomes difficult to modify and verify.

    A layered design is recommended.

    1. Geometry Layer: “What the Object Is”

    The geometry layer stores points, lines, circles, intersections, and dependencies, and provides distance calculation, intersection solving, and constraint checks.

    All drawing objects should fetch data from this layer, avoiding direct modification of key coordinates just to improve the visual effect.

    2. Time Layer: “Where We Are in the Process”

    Organize the construction process into a state sequence, for example:

    “Initial figure → perpendicular bisector construction → specified circle drawing → marked ruler movement → key position confirmation → subsequent construction → final verification.”

    Each step should have a defined start and end time, along with the tool position, object visibility, and trace range during that period.

    Animation frames should ideally be computed directly from time rather than by continuously accumulating displacement. This ensures consistent rendering when jumping, replaying, or exporting, and reduces accumulated errors.

    3. Rendering Layer: “How to Display”

    The rendering layer handles colors, line widths, labels, and coordinate mapping. Geometric calculations use stable logical coordinates; window size changes only affect the mapping from logical coordinates to screen coordinates.

    For traces, you can distinguish:

    • Base objects that are always retained.
    • Temporary auxiliary objects shown during the current step.
    • Arcs or segments that appear progressively as the process advances.
    • The final result highlighted after completion.

    This design reduces visual clutter and also makes it easier for reviewers to verify the construction order.

    Why Animation Export Deserves Separate Acceptance Testing

    Animation file export is not a simple UI add-on; it is an independent data processing flow.

    Typically, you need to generate frames at fixed time intervals, convert those frames to image frames, encode them into a GIF animation, and provide a download. The entire process involves dimensions, frame rate, loop mode, color handling, and memory control.

    Assume a frame size of 800×600 pixels and four bytes per pixel. An uncompressed frame is about 1.92 MB. If you retain a large number of frames at once, memory usage rises quickly. This is only an order-of-magnitude estimate for raw pixel data and does not represent the final file size.

    Therefore, the export implementation should consider batch processing, progress feedback, protection against repeated clicks, and failure notifications. When possible, separate the encoding task from the UI drawing to avoid long periods of page unresponsiveness.

    Acceptance testing should check at least:

    • Whether the downloaded file is indeed in the target animation format.
    • Whether the animation opens and plays correctly.
    • Whether the exported steps match those shown on the page.
    • Whether there are blank frames, dimension jumps, or missing labels.
    • Whether the page remains usable after export finishes.

    A button that cannot produce a file should not be counted as a passing feature.

    Building a Fair and Reproducible Model Evaluation

    A single case can only show how a model performs on a specific input and environment; it cannot directly prove that the model is generally better than others.

    Generation time also cannot be attributed solely to the model. It can be affected by input length, inference settings, tool calls, network state, runtime environment, and the number of modification rounds. Without these records, time comparisons leave too much room for interpretation.

    A more reliable evaluation should record:

    • The full prompt and all supplementary instructions.
    • Whether internet access, code execution, or file reading was allowed.
    • Input/output sizes and key configuration settings.
    • The first submitted result and the number of subsequent corrections.
    • Actual runtime behavior, errors, and verification logs.
    • Total time and the level of human intervention.

    It is recommended to break the evaluation into the following dimensions rather than giving only a single overall score:

    Dimension Main Check Items
    Requirements adherence Whether all constraints were covered, whether the process was changed without permission
    Mathematical correctness Construction basis, constraint residuals, and validity of the final figure
    Implementation quality Clarity of structure, reliability of state management
    Functional completeness Whether play, pause, replay, and export are actually usable
    Stability Consistency across multiple runs and under abnormal conditions
    Delivery efficiency Time and human cost required to obtain an acceptable result

    Among these, mathematical correctness and adherence to key constraints should be treated as hard gates. No matter how attractive the page looks, it cannot compensate for a wrong construction method.

    The Core Value of Lightweight Models: Reducing the Cost of Trustworthy Delivery

    From this type of task, a more practical judgment standard emerges: the value of a model is not whether one demo is impressive, but whether it consistently reduces the developer’s verification and repair work.

    Capabilities worth paying attention to include: actively identifying requirement ambiguity, maintaining constraint consistency over long processes, breaking complex problems into testable modules, and providing locatable error messages when something fails.

    In actual usage, a workflow of “plan first, verify second, implement third” can be adopted: first have the model list its assumptions and construction basis, then check the mathematical relationships, then implement the animation and interactions, and finally verify each item step by step.

    Web animation tests have their place, but they are better suited as diagnostic tools for composite capabilities rather than as rankings for general performance. Only by separating visual presentation, process compliance, mathematical correctness, and delivery cost can we determine whether a lightweight model is truly suitable for the target development scenario.