Evaluating Lightweight LLMs for Coding: A Practical Framework with a Complex Geometry Task
This article presents a practical methodology for evaluating the coding capabilities of lightweight large language models. Using a geometric construction animation webpage as a comprehensive test case, it explains how to define evaluation criteria, verify requirement completeness, build verifiable mathematical models, detect "correct result but wrong process" implementations, structure animation code into testable layers, handle animation export as an independent engineering task, and assess models based on the cost per accepted deliverable rather than surface-level demos.
1. Evaluating Lightweight Models Starts with Defining “Capability”
For programming tasks, lightweight large models are generally expected to strike a balance between inference cost, response latency, and output quality. However, “lightweight” does not automatically mean faster responses, and “flagship” is not a technical metric you can use for engineering acceptance.
The actual user experience depends on many stages: the model’s inference strategy, input context length, output size, service queuing, tool invocation, and the testing-and-fixing cycle after code generation. Even when two models both produce a runnable page in the end, they may differ significantly in requirement understanding, algorithmic authenticity, and time to delivery.
Therefore, judging whether a model is suitable for development work should answer at least four questions:
- Did it accurately understand the task the user asked for?
- Did it use the required method, rather than merely producing a similar-looking result?
- Is the generated code runnable, verifiable, and maintainable?
- Are the time and resources needed to reach acceptance acceptable?
These four questions correspond to requirement compliance, process correctness, engineering quality, and delivery efficiency. Looking only at a page screenshot usually covers a very small part of them.
2. Why a Geometric Animation Page Works Well as a Comprehensive Test
An ordinary static page mainly tests layout, styling, and basic interaction. An animated page with geometric construction constraints, by contrast, must handle mathematical relationships, program state, and visual expression at the same time, which exposes far more hidden problems.
Consider a task that requires: first constructing a square, then drawing a specific circle and perpendicular bisector, using a ruler with two marked lines to find positions that satisfy given conditions, completing the subsequent geometric steps, and finally providing an animation export feature.
Such a task contains at least five interrelated sub-problems:
- Translating natural language into explicit points, lines, circles, and their constraints;
- Computing geometric positions that satisfy those constraints;
- Organizing construction steps in the specified order;
- Distinguishing the tool’s motion trail from the auxiliary lines that are formally retained;
- Converting an interactive animation into a savable animated image.
A model may excel at some of these while failing at others. For example, the page may look polished with complete buttons, yet the key vertices are precomputed directly with trigonometric functions, and the animation is only a retrospective visualization.
Such an implementation produces the correct appearance but does not prove that the specified construction process was carried out.
The real value of a comprehensive test is not how complex the visuals are, but that there is a checkable causal relationship between the result and the process.
3. Review Whether the Problem Statement Is Complete Before Judging the Implementation
A complex prompt is not necessarily a complete technical specification. Before testing a model, developers should first check whether the requirements are sufficient to determine a unique or acceptable solution.
3.1 A Two-Mark Ruler Construction Must Specify the Mark Relationship
A ruler with two marks has not only a direction but also a fixed distance between the marks. If the problem does not state how the mark spacing relates to the side length of the initial square, then “the first mark lands on the circle and the second mark lands on the perpendicular bisector” is usually not enough to fully define the intended construction.
The following points also need clarification:
- What is the distance between the two marks?
- Does the known vertex lie on the ruler’s line, or must it fall between the two marks?
- Which directions and intersection branches are allowed?
- Which subsequent intersections will serve as vertices of the target polygon?
When these conditions are missing, the more reasonable model behavior is to point out the ambiguity, request clarification, or explicitly list the assumptions used in the implementation—rather than directly claiming a rigorous construction has been completed.
3.2 Distinguish Classical Straightedge-and-Compass from Marked-Ruler Construction
With only an unmarked straightedge and compass, a regular heptagon cannot be constructed exactly. Once a marked ruler is introduced, the set of permitted geometric operations changes, and the process can no longer be treated as classical straightedge-and-compass construction.
That said, not every marked-ruler operation sequence yields a regular heptagon either. The specific construction still requires mathematical justification, and the selected solution must be checked against the target conditions.
Evaluation should therefore judge separately:
- Whether the tools permitted by the problem are sufficient;
- Whether the given construction relationships hold;
- Whether the program faithfully implements those relationships.
Otherwise, it is easy to mistake an incomplete problem statement for a model capability problem.
4. Building a Verifiable Mathematical Model from Natural-Language Constraints
To reduce interference from presentation code on mathematical logic, you can first build the model in a planar coordinate system.
Let the square have side length (a>0), with bottom-left corner (D=(0,0)) and bottom-right corner (E=(a,0)). The perpendicular bisector of the bottom edge is:
[
x=\frac{a}{2}
]
The circle centered at (E) with radius equal to the square’s diagonal is:
[
(x-a)^2+y^2=2a^2
]
Suppose the ruler’s line passes through (D) with unit direction vector:
[
u=(\cos\theta,\sin\theta)
]
If the first mark is at (P=tu) and the fixed spacing between the two marks is (s>0), the second mark can be expressed as:
[
Q=(t+s)u
]
Under this convention, the two positional constraints are:
[
(t\cos\theta-a)^2+(t\sin\theta)^2=2a^2
]
[
(t+s)\cos\theta=\frac{a}{2}
]
These equations are merely mathematical expressions of the explicitly stated conditions; they do not automatically prove that a regular heptagon results. The mark spacing, direction range, and subsequent construction must be combined to determine the correct solution branch.
Numerical Solving Should Also Preserve Residuals
If numerical methods are used to find the ruler’s position, the output should not be just a set of coordinates—it should also quantify how well that position satisfies the constraints.
You can define separately:
- The distance error from the first mark to the target circle;
- The distance error from the second mark to the perpendicular bisector;
- The error between the actual mark spacing and the specified spacing;
- The distance error from the known vertex to the ruler’s line.
Length errors can be normalized by the square’s side length so that the acceptance criteria stay consistent across different canvas sizes.
Numerical tolerance should be set according to computational precision and display purpose, not arbitrarily chosen as a very small number. “Visual coincidence” in an animation demo and “strict equality” in the mathematical sense should also be clearly distinguished in the documentation.
5. How to Detect “Correct Result, Wrong Process”
The most common shortcut in geometric webpages is to generate the target polygon first, then add auxiliary lines that have no computational dependency on it.
For example, computing seven vertices directly from a center, radius, and equal angular divisions yields a regular heptagon. But if the task requires these vertices to be produced by the specified construction steps, this approach can only serve as an independent verification tool—it cannot replace the main construction.
5.1 Check the Provenance of Coordinates
Every key point should be traceable to a concrete geometric operation, such as:
- Intersecting two lines;
- Intersecting a line with a circle;
- Intersecting two circles;
- Constructing the perpendicular bisector of a segment;
- Solving for a ruler position satisfying the mark constraints.
If all final vertices come directly from a fixed angle array while the earlier construction process plays no role in the computation, beware of “answer first, animation later.”
5.2 Check the Dependency Chain
The entire construction can be organized as a dependency graph:
“Initial square → reference circle and perpendicular bisector → ruler-constraint solution → subsequent intersections → target polygon.”
When upstream parameters change, downstream objects should be recomputed. If resizing the square only changes the background while the target vertices stay fixed, the program’s data dependencies are likely incomplete.
5.3 Check the Final Geometric Properties
For the seven generated vertices, independently verify edge lengths, interior angles, concyclicity, and vertex ordering.
Checking only that “the seven edges are roughly equal” is insufficient, because vertex ordering errors or self-intersection may still occur. Proper validation must consider both geometric dimensions and topological relationships.
It is important to emphasize: passing the final shape validation only proves the result satisfies the relevant properties—it does not by itself prove that the specified construction method was followed.
6. Animation Implementation Should Revolve Around Geometric State, Not Stacked Drawing Commands
To make a complex webpage easier to test and maintain, the implementation can be divided into three layers.
Geometry Computation Layer
Responsible for intersections, constraint solving, error computation, and degenerate-case detection. This layer does not depend on the canvas, making it independently testable.
When two circles do not intersect, lines are nearly parallel, or the constraints admit no usable solution, it should return a clear status rather than continue drawing with invalid coordinates.
Construction Flow Layer
Responsible for describing each step’s start and end conditions, duration, visible objects, and retained traces. It should answer “what is being done right now,” not merely “what is being drawn right now.”
For example, while the compass moves, the active radius and pen tip can be displayed, but the formal trace is only retained over the designated interval. This is what separates tool motion from actual construction results.
Rendering and Interaction Layer
Responsible for coordinate transformation, scaling, play, pause, reset, and step descriptions.
To support replay and animation export, the frame state should be determined by a unified time parameter: given the same time and parameters, the same frame is produced. This avoids cumulative modifications that depend on the previous frame, reducing frame-skip, pause-resume, and export state inconsistencies.
7. Animation Export Is Not an Extra Button—It Is an Independent Engineering Task
“Supports export” cannot be accepted merely because a button appears in the UI. A complete pipeline includes at least fixed-interval time sampling, frame-by-frame rendering, image encoding, file generation, and download feedback.
Key issues to handle during export:
- Time consistency: do not rely on the incidental frame intervals of real-time playback;
- Visual consistency: exported content should match the preview’s geometric state, text, and layers;
- Resource usage: higher resolution, frame rate, and duration generally increase processing and caching pressure;
- Interaction feedback: long tasks should show progress and support cancellation and failure messages;
- Exception cleanup: after export failure or cancellation, temporary resources should be released and the UI state restored.
During testing, the exported file should also be reopened to check whether it is blank, missing its second half, or playing at an abnormal pace. A successful download does not equal a correct export.
8. Build an Evaluation System More Reliable Than “Watching One Demo”
Evaluating a lightweight model’s coding ability should use layered acceptance rather than compressing all behavior into a single subjective impression.
| Evaluation dimension | What to check |
|---|---|
| Requirement understanding | Whether key constraints, ambiguities, and missing conditions are identified |
| Mathematical correctness | Whether equations, solution branches, and geometric properties hold |
| Process compliance | Whether the result is actually derived from the specified operations |
| Code quality | Whether structure, exception handling, and state management are sound |
| Feature completeness | Whether play, reset, step display, and export all work |
| Delivery efficiency | Time to first usable output, number of fix rounds, total time to acceptance |
| Stability | Whether repeated runs consistently meet requirements |
Key requirement constraints should act as hard gates. A beautiful page cannot offset a core algorithm error, and a slow first-round generation should not be dismissed if it reduces later repair work.
Fair testing should also standardize input requirements, runtime environment, tool permissions, and acceptance criteria as much as possible, and record whether internet access is allowed, whether code execution is permitted, and whether manual edits were involved.
A single success case proves a model can potentially complete a certain class of task, but it is not enough to prove sustained superiority across all programming scenarios. More reliable judgments come from multiple tasks, repeated runs, and failure classification.
9. Enterprise Selection Should Focus on “Cost per Accepted Deliverable”
For real projects, text generation speed is not the only metric. What matters more is: to complete one task that passes acceptance, how many model calls, how much human review, code repair, and compute resources are required?
A fast output with critical logic errors may simply shift the cost onto developers; a slower inference that delivers a more complete result may still be unsuitable for latency-sensitive interactive applications.
Therefore, different working modes can be adopted according to task risk:
- For simple UIs and low-risk changes, prioritize response efficiency;
- For tasks involving algorithms and strict constraints, add independent verification;
- For long-running generation, use asynchronous tasks with progress feedback;
- For high-risk results, retain human review;
- For repetitive tasks, build up test sets and automated acceptance rules.
The advantage of lightweight models worth paying attention to should not rest on the name or a single demo. It should manifest as: reliably completing well-specified tasks within an acceptable resource budget, and reducing rework across the entire development loop.
Ultimately, the core of evaluation is not “how much code the model generated,” but “whether that code passes explainable, reproducible, and executable acceptance.” Only by examining the result, the process, and the delivery cost together can you truly judge a model’s engineering value.
