Lightweight LLM Evaluation: Complex Reasoning and Code Generation

    This article examines how lightweight models should be evaluated on complex reasoning and code generation, using a demanding geometry animation task as an example. It explains why complex web page generation can reveal gaps between visually plausible results and correct implementation, identifies the capabilities to observe in lightweight models, and proposes a fairer evaluation process with unified test conditions, layered scoring, and separate review of results and process.

    As large model products continue to move toward lighter-weight designs, there is often a trade-off among response speed, deployment cost, and reasoning capability. A lightweight model does not necessarily mean that it can only handle simple question answering or template-based code generation. Some newer lightweight models are already capable of multi-step reasoning, complex front-end interactions, and visualization tasks with explicit constraints.

    However, judging whether a model is “strong” cannot rely only on whether it eventually generates a runnable web page, nor on whether the page looks attractive. For complex tasks, what matters more is whether the model truly understands the user’s requirements, whether it implements the specified steps, whether it can handle implicit geometric relationships, and whether it has self-checking and error-correction capabilities.

    1. Why Complex Web Page Generation Is a Good Test of Model Capability

    Ordinary web page generation tasks can often be completed by applying common templates. For example, when generating a calculator, a to-do list, or a simple animation, a model may be able to assemble a runnable result quickly from existing code patterns even without a deep understanding of the requirements.

    Complex geometric animations are different. They usually combine several types of requirements at once:

    1. Natural language understanding: The model needs to accurately identify objects, directions, order, and constraints.
    2. Mathematical modeling: Concepts such as points, lines, circles, perpendiculars, and trajectories need to be converted into coordinates and geometric relationships.
    3. Algorithm design: The model needs to decide how to calculate intersections, how to construct auxiliary lines, and how to ensure that the final figure satisfies the target.
    4. Front-end drawing: Web drawing capabilities are needed to produce both static figures and dynamic processes.
    5. Interaction and export: The task may also involve play, pause, step-by-step execution, reset, and animation export.
    6. Result validation: The model must check whether the final figure satisfies the problem constraints, rather than merely looking similar.

    Therefore, this type of task can expose the depth of a model’s reasoning in a relatively comprehensive way. If a model only generates a visually similar regular polygon without following the specified construction process, then it has actually completed only a result simulation, not the problem itself.

    2. A Typical Test: Reproducing a Complex Straightedge-and-Compass Construction on a Web Page

    A test task can be designed as follows: ask the model to generate a web page animation that demonstrates how to complete a regular heptagon construction using specified auxiliary tools. The task includes a square, the perpendicular bisector of the base, auxiliary circles, a specific marked tick line, a movement process, and subsequent steps for determining the circle center. It also requires filling in omitted straightedge-and-compass construction steps and providing animation export at the end.

    The difficulty of such a prompt is not drawing a regular heptagon. The vertices of a regular heptagon can be calculated directly from the circle center, radius, and angle formula, and can even be generated quickly using trigonometric functions. The real difficulty is:

    • Whether the model strictly follows the construction route given in the task;
    • Whether it represents the process of moving the ruler;
    • Whether it retains necessary trajectories instead of drawing many irrelevant auxiliary lines;
    • Whether it distinguishes temporary elements in the construction process from the final result;
    • Whether it keeps the animation steps consistent with the mathematical logic;
    • Whether it can ensure, at the code level, that figure proportions, coordinate transformations, and animation timing are correct.

    If the model directly uses an angle formula to generate seven vertices and then adds some decorative lines, the page may look very good, but this does not prove that the model understood the original task.

    3. The Most Common “Looks Correct” Problem in Evaluation

    In complex code generation tasks, the most common problem is “correct result, wrong process.” This phenomenon is especially likely to appear in geometric animations, data visualizations, and algorithm demonstrations.

    For example, a model may adopt the following strategies:

    • Directly calculate the vertices of the target figure;
    • Use preset coordinates to draw the final shape;
    • Omit key auxiliary steps;
    • Replace real animation with textual explanations;
    • Add extra steps not required by the task to hide missing logic;
    • Generate a runnable page without implementing the export function;
    • Keep all auxiliary lines permanently visible, making the process inconsistent with the task.

    From a user experience perspective, such results may already be “close enough.” From a technical evaluation perspective, however, they do not satisfy the task constraints. A more reliable model should be able to split the requirements into several independent stages and establish clear inputs, outputs, and validation conditions for each stage.

    4. Capabilities to Watch for When Observing Lightweight Models

    4.1 Requirement Decomposition

    The model should first decompose a long prompt into steps such as initialization, construction, movement, intersection, circle center determination, result drawing, and animation export. Each step should have clear geometric objects and state changes.

    If the model immediately outputs a large block of code without establishing a task structure, the probability of omissions later increases noticeably. By contrast, a model with stronger planning capability usually organizes the coordinate system, layers, animation states, and algorithm flow before moving into implementation.

    4.2 Constraint Retention

    Complex tasks best reveal whether a model can retain constraints over a long span. Rules stated by the user at the beginning may only become relevant dozens of code fragments later. The model needs to remember consistently:

    • Which elements must be displayed;
    • Which elements should be displayed only in specific steps;
    • Which trajectories need to be retained;
    • Which auxiliary lines must not appear prematurely;
    • How the animation sequence must be arranged;
    • What restrictions apply to the final output format.

    If the model focuses only on the final visual result, it is prone to “locally correct, globally non-compliant” outcomes.

    4.3 Conversion from Mathematics to Code

    A geometric description cannot run directly; it must be transformed into computable data structures. For example, point objects can represent coordinates, line segment objects can represent boundaries, circle objects can represent trajectories, and new construction points can be obtained through intersection algorithms.

    A clearer implementation usually separates geometric logic from drawing logic:

    1. const point = (x, y) => ({ x, y });
    2. function distance(a, b) {
    3. return Math.hypot(a.x - b.x, a.y - b.y);
    4. }
    5. function midpoint(a, b) {
    6. return point((a.x + b.x) / 2, (a.y + b.y) / 2);
    7. }
    8. function drawCircle(ctx, center, radius) {
    9. ctx.beginPath();
    10. ctx.arc(center.x, center.y, radius, 0, Math.PI * 2);
    11. ctx.stroke();
    12. }

    The illustrative code itself does not complete the full construction, but it reflects an important principle: first establish a verifiable geometric foundation, and then let the drawing layer handle presentation. If all calculations, animations, and interface operations are mixed together, the code generated by the model will be difficult to debug.

    4.4 Self-Checking and Error Correction

    A high-quality model should not stop immediately after generating code. It should actively check:

    • Whether the page can load;
    • Whether the animation buttons actually work;
    • Whether all referenced variables and functions exist;
    • Whether the figure exceeds the canvas;
    • Whether the export function truly generates an animation file;
    • Whether the construction order matches the textual requirements;
    • Whether shortcuts not required by the task have been added by mistake.

    For complex tasks, pauses, repeated revisions, or stage-by-stage refactoring during generation do not necessarily indicate insufficient capability. What matters is whether the model can ultimately locate problems and make effective corrections. By contrast, smoothly outputting a large amount of code without validating the result at all may be more likely to produce hidden errors.

    5. How to Build a Fairer Model Evaluation Process

    To avoid accidental results, it is advisable to use a unified test environment and multidimensional scoring rather than comparing only a single generation result.

    Unified Test Environment

    The prompt, browser environment, canvas size, runtime, and export conditions should be fixed. For tasks that require longer reasoning time, the total time from the start of generation to the final runnable result should also be recorded, but speed should not be used as the only metric.

    Layered Result Scoring

    Scoring can be divided into the following dimensions:

    • Requirement coverage: Are all explicit requirements implemented?
    • Process correctness: Is the specified construction flow followed?
    • Mathematical accuracy: Are the relationships among points, lines, circles, and intersections correct?
    • Code runnability: Can the page load and interact normally?
    • Visual clarity: Are layers, colors, labels, and animations easy to understand?
    • Maintainability: Does the code have reasonable function separation?
    • Export completeness: Is animation export truly usable?
    • Self-repair capability: Can the model complete modifications after discovering errors?

    Separate Review of Result and Process

    The final page should be checked together with the generation process. Looking only at the page makes it easy to mistake an implementation that “precomputes the final answer” for a complete solution. During review, the following points should be confirmed:

    1. Whether auxiliary lines appear at the correct time;
    2. Whether trajectories are drawn only at necessary stages;
    3. Whether moving objects actually move according to the conditions;
    4. Whether the final figure is naturally derived from the preceding steps;
    5. Whether there are hidden shortcuts that bypass the core requirements of the task.

    6. Practical Application Scenarios for Lightweight Models

    This type of task shows that lightweight models are not necessarily limited to simple code. As long as the task boundaries are clear, the prompt structure is complete, and the model is allowed to perform necessary stage-by-stage reasoning, it may also be able to complete fairly complex interactive page generation.

    Suitable scenarios include:

    • Teaching demonstration pages;
    • Geometry and physics experiment simulations;
    • Data chart prototypes;
    • Front-end interaction samples;
    • Rapid construction of internal tools;
    • Code refactoring and local fixes;
    • Product concept validation.

    In formal production environments, however, it is still not advisable to rely entirely on a single generation result. Code involving mathematical calculations, financial logic, permission control, data processing, and file export all requires human review, automated testing, and runtime validation.

    Conclusion

    The value of lightweight models is not only “faster output” or “lower cost.” It also lies in whether they can complete complex tasks under resource constraints. Complex geometric web page generation shows that the capabilities that truly differentiate models include long-context constraint retention, mathematical reasoning, code organization, process visualization, and result self-checking.

    Therefore, when evaluating a lightweight model, it is not enough to ask “Can it generate a page?” We should also ask: Does it understand the problem, follow the process, validate the result, and make the code easy for developers to maintain? Only by combining the final effect with the implementation logic can we reach more objective and useful technical conclusions.