Can Lightweight Models Handle Complex Code Generation? A Single-Run Evaluation

    This evaluation examines whether a lightweight language model can follow a multi-step geometric construction prompt while generating HTML and JavaScript animation code. It compares the model with a larger flagship model and discusses the trade-off between instruction adherence and generation latency, along with practical cloud-native approaches for handling long-running inference tasks. The results are limited to one prompt and one run per model and should not be treated as a general model-selection benchmark.

    In recent years, large language models have split into two broad categories. Some prioritize overall capability, while others focus on lower inference costs and faster responses. For code assistance and automated script generation, lightweight models are becoming increasingly attractive because of their cost advantages.

    However, when a prompt contains multiple logical constraints and a long sequence of required steps, it is not clear whether lightweight models can complete the task consistently. This evaluation addresses two questions:

    • Can a lightweight model follow a complex geometric construction procedure exactly?
    • How can engineering teams mitigate long generation times?

    The conclusions apply only to this particular test and should not be used as a standalone basis for model selection.

    Why Standard Benchmarks Are Not Enough

    Code benchmarks such as HumanEval primarily test basic algorithmic problems. The problem statements are usually clear and contain relatively few constraints.

    Real-world development prompts often combine mathematical conditions, graphical rendering, specific algorithms, and strict output requirements. A model may perform well on simple coding tasks but deviate from instructions when several constraints must be satisfied at the same time.

    For this reason, evaluation should examine two separate dimensions:

    1. Whether the final result is correct.
    2. Whether the model follows the required process along the way.

    Test Task: Constructing a Regular Heptagon with a Two-Point Ruler

    The test prompt required an animated geometric construction implemented with HTML and JavaScript, using either Canvas or SVG. The construction had to include the following five steps:

    1. Start with a square and draw the perpendicular bisector of its bottom edge.
    2. Use the bottom-right vertex, E, as the center of a circle whose radius is the length of the square’s diagonal.
    3. Use a two-point ruler placed against the bottom-left vertex, D. Rotate the ruler until its first graduation mark reaches circle E and its second graduation mark passes through the perpendicular bisector of the bottom edge.
    4. Complete all omitted compass-and-straightedge construction steps. The compass should leave visible traces only where necessary.
    5. Add functionality to export the animation as a GIF.

    The main difficulty lies in the underlying geometry. A two-point ruler is not a standard straightedge-and-compass tool. If the model skips a required step or replaces the specified method with another approach, the final shape may look correct while the construction process no longer satisfies the prompt.

    Test Results and Comparison

    The test used two models: one lightweight model and one larger flagship model. The model names, versions, hardware environment, sampling temperature, and complete prompt were not disclosed, so the test cannot be directly reproduced. Each model was run only once.

    Evaluation item Lightweight model Flagship model
    Step adherence Implemented the steps in the requested order Added auxiliary steps that were not requested
    Compass-trace constraint Left traces only where required Not recorded
    GIF export Integrated Not recorded
    Single-run duration Approximately 34 minutes Approximately 20 minutes

    Lightweight Model

    The lightweight model’s generation process was clearly segmented. At one point, it spent a period of time producing no visible output.

    The recorded duration represents the end-to-end time for a single run. It does not separate queueing time from generation time, and no repeated measurements were performed. The figure therefore describes only this particular run.

    Based on the final code, the model implemented the perpendicular bisector, the trajectory of circle E, and the two-point-ruler condition in the requested order. It also integrated GIF export and did not add steps beyond those specified in the prompt.

    Flagship Model

    After approximately 20 minutes, the flagship model produced a page that displayed an animated regular heptagon.

    However, an inspection of its JavaScript logic showed that the implementation did not follow the described two-point-ruler procedure. Instead, it used additional auxiliary steps to obtain the regular heptagon.

    The page met the requirement visually, but the construction method did not follow the specified process. The author did not perform a line-by-line audit of the entire codebase, so this assessment is limited to the logic that was examined.

    Strengths and Limitations

    Strengths

    In this test, the lightweight model followed the constraints relatively strictly. It did not bypass the difficult part by introducing extra construction steps.

    For tasks that require every requirement to be checked individually, this behavior may reduce the amount of manual code review.

    Limitations

    The most obvious weakness was the long generation time. In interactive development, waiting tens of minutes can significantly affect the user experience and may also trigger client-side or gateway timeouts.

    In addition, a single sample cannot demonstrate model stability or reliability.

    Suitable Use Cases

    The model may be suitable for:

    • Scripts with clearly defined and individually verifiable constraints
    • API integration code
    • Strictly formatted structured output

    Less Suitable Use Cases

    It is less suitable for:

    • Low-latency code completion
    • Batch workloads that are sensitive to execution time
    • Open-ended design tasks without a reliable validation process

    Model Selection Checklist

    Before selecting a model for similar workloads, consider the following questions:

    1. Is there an automated test or visual acceptance standard?
    2. Can the same prompt be run repeatedly to measure the success rate?
    3. Are first-token latency and end-to-end duration acceptable for the application?
    4. Does the output require manual review at each stage?

    General Approaches to Reducing Inference Latency

    Inference latency does not depend only on the model itself. The following measures are general cloud-native practices, not conclusions derived from this particular experiment.

    1. Elastic Scaling

    Scale inference instances automatically according to queue length and GPU utilization to reduce peak-time queueing. Scaling thresholds should be based on measurements from the target workload.

    2. Asynchronous Jobs

    Place long-running tasks in a message queue and let worker processes consume them. The frontend can receive progress updates through WebSocket connections or polling, avoiding a single HTTP connection that remains open for an extended period.

    3. Persistent Intermediate Results

    Write intermediate outputs to object storage. If a task is interrupted, it can resume from the latest checkpoint instead of restarting from the beginning.

    4. Timeouts and Retries

    Set the timeout threshold above the historical P99 duration. Limit the number of retries and implement idempotent processing to avoid duplicate charges or repeated writes.

    5. Monitoring Metrics

    At a minimum, record:

    • First-token latency
    • End-to-end duration
    • Throughput
    • Error rate
    • Queue backlog length

    These metrics help identify where the bottleneck is located.

    Conclusion

    This evaluation used one prompt, with each model run only once. It cannot represent the overall capability of lightweight models.

    The test does suggest that, in a constraint-heavy geometric coding task, the lightweight model showed a stronger tendency to follow the specified sequence. Its clear weakness was the long generation time.

    For model selection, teams should use their own business prompts, run repeated offline evaluations, and retain a manual review process. For complex tasks, generated code should be judged by verifiable test results. A page that merely looks correct is not sufficient evidence that the required implementation process was followed.