Constraint-Based Evaluation of Lightweight Models for Complex HTML Drawing Tasks

    This article explores how to evaluate lightweight models on complex HTML geometry and animation tasks rather than judging them only by final screenshots or average accuracy. It proposes structured constraint checklists, quantitative metrics, and failure-mode analysis for tasks such as drawing a regular heptagon with a two-mark ruler and exporting the result as a GIF. It also presents an engineering evaluation pipeline and a verifiable Canvas animation skeleton, arguing that lightweight models are best used as cost-effective candidate generators within a workflow that combines automated validation, stage logging, and tiered routing.

    1. Problem Background: Why Lightweight Models Need “Complex Task” Evaluation

    As the trade-off between model scale and inference cost becomes increasingly important, lightweight models are no longer limited to summarization, classification, simple question answering, and similar tasks. They are beginning to enter more complex development scenarios such as code generation, front-end page construction, data visualization, and animation implementation. At this point, evaluating model capability only with average accuracy or short question-answering scores can easily hide critical differences: Can the model fully follow multi-step constraints? Can it maintain intermediate state through long-chain reasoning? Can it produce engineering artifacts that are runnable, verifiable, and reproducible?

    The task discussed in the original context—“complex HTML animation + geometric drawing”—is a typical stress test. On the surface, it only asks for a web page to be generated. In practice, it examines multiple capabilities at the same time:

    1. Natural-language constraint parsing: understanding drawing steps, object relationships, order, and limiting conditions;
    2. Long-range reasoning and state management: maintaining consistency among points, lines, circles, intersections, perpendicular bisectors, and other geometric objects across dozens of operations;
    3. Code engineering capability: translating geometric constructions into runnable HTML/CSS/JavaScript and handling Canvas or SVG drawing;
    4. Instruction-following completeness: not omitting required steps and not adding unrequested steps without authorization;
    5. Artifact verifiability: the page can be opened, the animation can play, the GIF can be exported, and the geometric result matches the description;
    6. Output stability: whether streaming output is continuous, whether there is “thinking without output,” and whether the model can recover after a timeout.

    Therefore, when evaluating lightweight models, the focus should not be only on whether the final image “looks similar.” It should also examine whether the process is compliant, whether the artifact is verifiable, and whether failures can be localized.

    2. Evaluation Task Design: Breaking “Apparent Difficulty” into Verifiable Constraints

    Take the task “draw an HTML page that implements a regular heptagon construction with a two-mark ruler and adds GIF export functionality” as an example. This task includes geometric construction, straightedge-and-compass construction, two-mark ruler constraints, animation demonstration, and export capability. If only a natural-language prompt is provided, different models may produce visually similar results while taking very different implementation paths. To prevent “accidentally correct results” from masking “non-compliant processes,” it is advisable to break the task into a checklist of verifiable constraints.

    For example, the key requirements in the prompt can be abstracted into the following structured constraints:

    1. {
    2. "task": "html_geometry_animation",
    3. "geometry": {
    4. "target": "regular_heptagon",
    5. "method": "neusis_with_two_mark_ruler",
    6. "required_steps": [
    7. "construct_square",
    8. "construct_perpendicular_bisector_of_bottom_edge",
    9. "draw_circle_centered_at_bottom_right_vertex_with_diagonal_radius",
    10. "place_two_mark_ruler_through_bottom_left_vertex",
    11. "first_mark_on_circle",
    12. "second_mark_on_perpendicular_bisector",
    13. "complete_omitted_compass_straightedge_steps"
    14. ]
    15. },
    16. "rendering": {
    17. "platform": "html_canvas_or_svg",
    18. "show_compass_traces_only_when_necessary": true,
    19. "animation": true
    20. },
    21. "export": {
    22. "format": "gif",
    23. "trigger": "user_action_or_auto"
    24. }
    25. }

    With a constraint checklist, quantitative metrics can be designed:

    • Step coverage: whether each step in required_steps appears in the code or animation;
    • Constraint violation count: whether unrequested constructions are used, whether the two-mark ruler condition is skipped, and whether “trace marks” are drawn in unnecessary areas;
    • Geometric consistency: whether the final heptagon vertices are equidistant, whether the angle error is within a threshold, and whether the relationship between the circle center and the perpendicular bisector is correct;
    • Runnability: whether the page has no errors, whether the animation can play, and whether the export button works;
    • Reproducibility: whether differences across multiple generations from the same prompt are acceptable;
    • Process stability: whether there are long periods without output, missing stage logs, or no recovery after a timeout.

    This kind of evaluation is closer to engineering practice than “looking only at screenshots,” and it is easier to turn into an automated pipeline.

    3. Abstracting Core Advantages: Lightweight Models Should Focus on “Constraint Preservation Capability”

    From the perspective of complex-task evaluation, the core advantage of a lightweight model should not be simply described as “fewer parameters, therefore faster.” The focus should be on its balance among cost, latency, and capability. Specifically, the advantages can be summarized into the following categories.

    1. Completeness of Instruction Following

    In complex HTML drawing tasks, the failure mode most easily overlooked is “visually correct but procedurally deviant.” For example, the final page does draw an approximate regular heptagon, but the implementation adds auxiliary steps that were not in the prompt, or skips the key constraint of the two-mark ruler. Such a result may “look usable” in a demo, but it is unacceptable in engineering scenarios that require explainability, auditability, and reproducibility. If a lightweight model can maintain high completeness under multi-step constraints, it has value as a “cost-effective candidate generator.”

    2. State Consistency in Long-Range Reasoning

    Geometric drawing requires continuous maintenance of object relationships: point E is the circle center, the diagonal is the radius, the first mark of the two-mark ruler moves on the circle, and the second mark passes through the perpendicular bisector. Any misalignment in an intermediate state will cause cascading errors in subsequent steps. Evaluation should examine whether the model can explicitly maintain state in code rather than merely “patch” the figure through the final drawing. A model with good state consistency is better suited to development workflows that require step-by-step validation.

    3. Artifact Verifiability and Explainability

    A good artifact must not only “run” but also be “inspectable.” For example, does the code retain comments for construction steps? Are key point coordinates separated from constraint conditions? Is there a debug switch that displays auxiliary lines? The stronger the verifiability, the lower the manual review cost, and the easier it is to deploy in team collaboration.

    4. Output Stability and Controllability

    In experimental observations, long tasks may exhibit discontinuous streaming output, a disconnect between the thinking phase and the production phase, or even “thinking without output.” For engineering systems, this affects usability more than “slightly lower generation quality.” Therefore, evaluation should record metrics such as stage heartbeats, time to first token, incremental output intervals, and timeout retry success rate. If a lightweight model can maintain an observable output rhythm during long tasks, it is more suitable for integration into automated toolchains.

    5. Cost and Deployment Flexibility

    The value of lightweight models is also reflected in inference cost, concurrency capability, and deployment elasticity. For a process of “generate candidates first, automatically verify next, and manually review last,” a lightweight model can serve as the first-layer filter, leaving high-cost large-model calls for failed samples or high-risk tasks. This tiered routing strategy is more consistent with engineering economics than having a single model handle all tasks.

    4. Typical Failure Modes: Extracting Evaluation Points from Failures

    Failure Mode 1: Visually Correct but Procedurally Non-Compliant

    Some models may, after a long generation, provide an HTML page that “appears to meet the requirements.” The final figure is close to the target, but the implementation does not match the prompt description; the model forcibly achieves the result by adding nonexistent steps. This type of problem shows that the final screenshot cannot be the only acceptance criterion. Evaluation must introduce step-level checks, such as parsing the order of construction function calls in the code or requiring the model to output a construction log.

    Failure Mode 2: Thinking Without Output and Streaming Stalls

    In long tasks, a model may remain in the reasoning phase for a long time, with only scattered increments visible on the front end or even blank stages. From an engineering perspective, the following should be established:

    • stage heartbeats and timeout alerts;
    • incremental output buffering and placeholder prompts;
    • retry from the latest checkpoint after failure;
    • separate records for the “thinking process” and “code artifact” to avoid front-end misjudgment.

    Failure Mode 3: GIF Export Ignored or Pseudo-Implemented

    “Add the ability to output as GIF” is a typical compound requirement. Some implementations may provide only static screenshot download, or merely claim “GIF support” without actual frame-sequence capture and encoding. Evaluation should check whether there is frame-by-frame drawing, whether frame-rate control exists, whether download is possible, and whether the file can be opened by a standard decoder. If front-end encoding is costly, server-side frame-sequence composition can be used, but end-to-end verifiability must be ensured.

    Failure Mode 4: Confusion Between Necessary and Excessive Traces

    The prompt requires that “using a compass will produce traces of point movement, but traces will only appear in necessary parts.” This tests the model’s ability to distinguish between “visual expression” and “geometric constraints.” Too many traces interfere with the image, while too few fail to reflect the construction process. Evaluation can use screenshot comparison and manual scoring to check whether traces appear only at key construction stages.

    5. Engineering Evaluation Pipeline Recommendations

    To make evaluation repeatable, the following pipeline is recommended:

    1. Task templating: write the prompt, constraint checklist, expected metrics, and timeout thresholds into configuration;
    2. Multi-run sampling: run the same task multiple times and calculate success rate and variance;
    3. Automated static checks: check HTML structure, script syntax, presence of key functions, and presence of a GIF export entry point;
    4. Browser automation validation: load the page, capture console errors, trigger animation and export, and save screenshots and artifacts;
    5. Geometric numerical validation: extract key point coordinates from code or runtime, and calculate errors in edge lengths, angles, center distances, and similar values;
    6. Manual spot checks: perform step-level review of samples that are “visually correct but procedurally questionable”;
    7. Log archiving: archive prompts, model outputs, stage logs, screenshots, GIFs, and validation results to object storage, and build search indexes through logging services;
    8. Tiered routing: let a lightweight model generate candidates first, and escalate to a larger model or manual intervention after automated validation fails.

    At the deployment layer, general-purpose cloud services—such as object storage for archiving artifacts, logging services for recording stage logs and metrics, and container platforms for browser automation and batch jobs—can be used to build the evaluation environment. This approach does not depend on a specific model brand and is easy to scale horizontally.

    6. Example: A Verifiable Canvas Animation Skeleton

    Below is a native Canvas pseudocode skeleton unrelated to any specific brand. It illustrates how to decouple “construction steps” from “animation frames” for easier automated validation:

    1. <canvas id="stage" width="800" height="800"></canvas>
    2. <button id="export">Export GIF</button>
    3. <script>
    4. const steps = [];
    5. function recordStep(name, drawFn) {
    6. steps.push({ name, drawFn });
    7. }
    8. function renderFrame(index) {
    9. const ctx = document.getElementById('stage').getContext('2d');
    10. ctx.clearRect(0, 0, 800, 800);
    11. for (let i = 0; i <= index; i++) {
    12. steps[i].drawFn(ctx);
    13. }
    14. }
    15. function play() {
    16. let i = 0;
    17. const timer = setInterval(() => {
    18. renderFrame(i);
    19. i++;
    20. if (i >= steps.length) clearInterval(timer);
    21. }, 300);
    22. }
    23. // Key: each construction step is recorded independently for step coverage checks
    24. recordStep('construct_square', ctx => { /* draw square */ });
    25. recordStep('draw_perpendicular_bisector', ctx => { /* draw perpendicular bisector of bottom edge */ });
    26. recordStep('draw_circle_E', ctx => { /* draw circle centered at bottom-right vertex */ });
    27. recordStep('place_two_mark_ruler', ctx => { /* draw two-mark ruler and mark constraints */ });
    28. // ... omitted subsequent straightedge-and-compass steps
    29. play();
    30. </script>

    The core idea of this skeleton is that every step can be named, recorded, and verified. An evaluation system can check whether the steps array covers the constraint checklist, and it can also capture screenshots by index at runtime to form an auditable animation process.

    7. Conclusion

    For lightweight models, complex HTML drawing tasks are not “toy tests.” They are a comprehensive examination of instruction following, long-range state management, code engineering capability, and output stability. A truly valuable evaluation should not only check whether the final image is close to the target. It should also check whether the construction steps are compliant, whether the artifact is runnable, whether GIF export is genuinely effective, and whether failure modes can be localized.

    From an engineering practice perspective, the reasonable role of lightweight models is not to blindly replace larger models, but to serve as cost-effective candidate generators used together with constraint checklists, automated validation, stage logs, and tiered routing. Samples that are “visually correct but procedurally deviant” must be intercepted through step-level validation. For long tasks that “think without output,” observability must be improved through heartbeats, timeouts, and checkpoint mechanisms. Only by moving evaluation from “looking at results” to “looking at process, constraints, and reproducibility” can lightweight models deliver stable value in real development workflows.