How to Evaluate and Apply Complex Reasoning in Lightweight Models

    This article explains how to assess the capability limits of lightweight large language models on complex front-end tasks. It uses an HTML task that constructs a regular heptagon with a two-mark straightedge and animates the process as a test case. It covers the evaluation dimensions, common failure modes, engineering considerations for animation and GIF export, and a staged workflow for developers.

    As large language model applications move from asking whether a model can generate code to asking whether it can complete complex tasks accurately, developers are paying closer attention to the capability limits of lightweight models. Unlike traditional text question answering, complex front-end tasks often involve several stages at once: natural language understanding, mathematical reasoning, geometric algorithms, interaction design, animation, and file export. A model that can produce a web page has not necessarily understood the requirements, and its output may not follow the specified method.

    For this reason, lightweight models should not be judged only by output speed, code length, or whether a page opens. A more complete test framework is needed. Consider the task “construct a regular heptagon with a two-mark straightedge and generate an animation.” It looks like a small HTML experiment, but it tests instruction following, sequential reasoning, and engineering implementation at the same time.

    1. Why a Simple HTML Task Can Reveal Model Differences

    Many models can generate a web page with a canvas, buttons, and some shapes. If the requirement is only “draw a regular heptagon,” a model can usually hard-code the vertex coordinates or use trigonometric functions. If the task requires a specific ruler-and-compass construction procedure, however, the problem changes.

    In that case, the model must handle at least the following:

    1. Understand the geometric construction goal;
    2. Distinguish the final figure from the construction process;
    3. Organize the algorithm according to the steps the task specifies;
    4. Supply the standard compass-and-straightedge steps that the task leaves out;
    5. Show compass arcs only where they are needed;
    6. Turn each step into a visual animation;
    7. Provide runnable web page code;
    8. Add animation export.

    The difficulty does not lie in writing a few hundred lines of HTML. It lies in whether the model can keep the method fixed while getting the result right. If a model calculates the heptagon vertices directly and wraps them in an animation that looks like a construction, the page may look polished, yet it has departed from the original requirement.

    This shows that complex code tasks cannot be judged by the final screenshot alone. Intermediate steps and implementation logic must also be checked.

    2. The Core of the Test: Constructing a Heptagon with a Two-Mark Straightedge

    The test task can be broken down into the following parts:

    • Create a square as the base figure;
    • Construct the perpendicular bisector of the bottom edge;
    • Draw a circle centered at a specified vertex, with the diagonal as its radius;
    • Use the two-mark straightedge to complete a specific positioning procedure;
    • Use the resulting intersections or auxiliary lines to determine the key length needed for the heptagon;
    • Add the standard ruler-and-compass steps;
    • Draw all auxiliary lines, arcs, and edges in order;
    • Animate the construction process;
    • Finally, support exporting the animation as a GIF or another common animated image format.

    The most important factor is not any single coordinate but whether the process can be explained. In the program, the geometric construction should be split into independent steps rather than computing all the points at once.

    For example, the animation states can be designed as follows:

    1. Step 1: Draw the initial square
    2. Step 2: Show the midpoint of the bottom edge
    3. Step 3: Draw the perpendicular bisector of the bottom edge
    4. Step 4: Draw the specified circle
    5. Step 5: Simulate the movement of the two-mark straightedge
    6. Step 6: Record the key intersections
    7. Step 7: Draw the auxiliary arcs
    8. Step 8: Determine the heptagon vertices
    9. Step 9: Connect the edges in order
    10. Step 10: Export the animation

    This decomposition has two benefits. First, users can see directly whether each step matches the task. Second, developers can quickly locate errors, whether they come from the geometric algorithm, the animation timing, or the coordinate conversion for drawing.

    3. The Real Challenge: Instruction Following, Not Visual Polish

    In complex front-end tasks, models tend to fail in three main ways.

    1. Giving the final result directly

    The model skips all the construction steps and draws the heptagon from fixed coordinates. This is the easiest approach to implement, but it does not satisfy the process requirement. It shows that the model knows what a heptagon looks like, not that it understood the construction method the task requires.

    2. Adding extra steps to force the result

    In another case, the model produces a seemingly complete ruler-and-compass page but inserts calculations, scaling, or coordinate corrections that the task did not ask for. For example, it may calculate vertices with trigonometric functions and then add auxiliary lines as decoration, or use preset ratios to place the figure in the right position. Such an implementation may look correct in the final visual, but its algorithmic path does not match the task.

    3. Correct explanation, broken code

    Some outputs are complete at the explanatory level but contain obvious code problems, such as:

    • Inconsistent variable names;
    • Incorrect handling of coordinate system direction;
    • No synchronized scaling after the canvas size changes;
    • No state isolation between animation frames;
    • An export function that has a button but no real encoding;
    • Wrong arc angle direction;
    • No exception handling when an intersection does not exist;
    • Clipping of the page at different window sizes.

    Models must therefore be evaluated by checking language explanation, mathematical logic, and runnable code together.

    4. Strengths and Limits of Lightweight Models on Complex Tasks

    This kind of test shows that some lightweight models are not limited to simple completion. On tasks with clear structure and many constraints, they can also show considerable overall ability.

    Strength 1: Lower response cost

    Lightweight models are generally better suited to frequent calls, batch generation, and interactive development. For front-end prototypes, page drafts, algorithm explanations, and test code, a lower response cost helps teams iterate quickly.

    Strength 2: Handling long instruction chains

    If a model can maintain task context and break a complex requirement into stages, it is no longer just a code completer. It has some task planning ability. This matters especially for geometric visualization, flowchart generation, and interactive demonstrations.

    Strength 3: Output closer to a complete project

    High-quality output includes more than HTML structure. It should also contain styles, scripts, interactive controls, error messages, and export logic. A model that covers all of these in one pass shows some ability to organize an engineering project.

    Lightweight models still have clear limits. During long reasoning or complex generation, they may stall, repeat stages, or produce code that is inconsistent from one part to another. Some models reason unstably, especially on mathematical construction and multi-step programming tasks, where an assumption made early can change silently later in the output.

    For this reason, developers should not treat one successful output as proof of stable capability. Results should be confirmed through repeated tests and automated validation.

    5. Building a More Objective Evaluation System

    This kind of test can be divided into five dimensions.

    1. Instruction following

    Check whether the model strictly follows the specified method, and whether it replaces the algorithm, skips steps, or adds key assumptions without permission. This dimension is best judged by manually reviewing the flowchart and the code structure.

    2. Mathematical correctness

    Check whether the intersections, centers, radii, angles, and vertex positions satisfy the geometric relationships. Visual appearance alone is not enough, because some errors are not obvious after the page is scaled.

    3. Code runnability

    Run the code in a browser and verify the buttons, animation, reset, pause, step-by-step playback, and export functions. Code that looks reasonable does not necessarily run reliably.

    4. Explainability of results

    Each construction step should have a clear description, including which points, lines, circles, and intersections were used. For complex tasks, this explanation helps developers locate model errors.

    5. Robustness

    Change the canvas size, initial positions, color theme, and playback speed, then observe whether the program still works. If the code works only at a fixed size, its engineering quality is limited.

    6. Engineering Considerations for Animation and GIF Export

    When converting a geometric process into animation, a “state snapshot” approach is recommended. After each construction step, save the current canvas state or the list of geometric objects. During playback, render frames according to a timeline instead of drawing everything in one continuous function.

    Geometric objects can be abstracted as follows:

    1. Point: position, label, visibility
    2. Line: start point, end point, line style, color
    3. Circle: center, radius, start and end angles
    4. Arc: angular range, drawing direction
    5. Polygon: vertex list, fill and stroke properties

    This design is easier to maintain than issuing many Canvas drawing commands directly. It also makes undo, replay, and export easier to implement.

    GIF export requires attention to the following:

    • Use a consistent frame rate to avoid differences in playback speed across browsers;
    • Control the canvas size to keep file sizes manageable;
    • Compress the color palette appropriately;
    • Pause interactive animation before export;
    • Handle empty frames, transparent backgrounds, and cross-origin resources;
    • Show a clear message when encoding fails.

    If a third-party encoding library is used, confirm its loading state and browser compatibility. If the implementation does not depend on external resources, accept that its export capability will be more limited. Either way, treat “generating the animation” and “exporting the file” as two separate features to test.

    7. How Developers Should Use Lightweight Models

    In practice, the most effective approach is not to ask the model to generate all the code at once. Work in stages:

    1. Ask the model to explain the geometric construction and list the steps;
    2. Ask it to design the data structures and coordinate system;
    3. Implement only the static figure;
    4. Add step-by-step animation;
    5. Add interaction and export;
    6. Ask the model to fix problems based on test results.

    This workflow can significantly reduce the chance that a model understands the task correctly at first but drifts from it during implementation.

    The prompt should also clearly separate:

    • The algorithm that must be followed;
    • The interface that can be designed freely;
    • The simplifications that are not allowed;
    • The features that must be implemented;
    • The acceptance criteria;
    • The information the model must report when something fails.

    For example, the model can be asked to note the source of each geometric point in code comments and to include a “construction data” panel on the page. This makes verification easier and reduces the chance that the model replaces the actual construction with a black-box calculation.

    8. Conclusion: Judge a Model by Whether It Completes the Task

    The value of a lightweight model cannot be judged simply by parameter count or output speed. For complex HTML and mathematical visualization tasks, what matters is whether the model can understand the constraints, maintain its reasoning chain, implement the correct algorithm, and deliver code that runs, can be verified, and can be extended.

    Tests such as “construct a regular heptagon with a two-mark straightedge” are useful not because the page is complicated, but because they distinguish three levels of ability:

    • Producing visual effects only;
    • Explaining the basic idea;
    • Completing a full engineering implementation that strictly follows the specified method.

    Model evaluation for developers should therefore move from comparing single results to verifying the whole process. Only by checking instruction following, mathematical logic, code quality, interaction, and export together can a team judge objectively whether a lightweight model can handle complex development tasks.