Limitations of Multimodal LLM Code Generation and Engineering Improvements

    This article examines where multimodal large language models fall short in code generation, breaking the limitations into three layers: structure, graphics, and visual feedback. It categorizes common defects such as scale imbalance, layer overlap, texture errors, and responsive breakage, then presents engineering fixes including design-token constraints, staged generation, screenshot review loops, automated visual assertions, and human-in-the-loop review. It also recommends multi-dimensional evaluation metrics instead of a single overall score.

    1. Background: From “Code That Runs” to “Code That Ships”

    Over the past year, multimodal large language models with code generation capabilities have been widely adopted in front-end delivery workflows. A common pattern has emerged across the industry: on medium-difficulty web page generation tasks, mainstream models now perform similarly overall, with the remaining differences showing up in detail-level stability rather than in the ability to scaffold a page. As a result, the focus of model selection is shifting from “which model is smarter” to “which model leaves fewer defects that require manual rework.”

    A typical problem highlighted in the source material is representative: when a task expands from a standard page to mixed content that includes 2D drawing and vector graphics, generation quality drops noticeably. Visual capability is also weak, so models struggle to provide effective feedback on their own output, leaving obvious defects in the delivered result. The sections below abstract these problems into a reusable analysis framework.

    2. Three Layers of Capability Boundaries

    2.1 Structure Layer: Layout Skeletons Are Usually Reliable

    For grid and flex layouts, common component combinations, forms, and lists at medium complexity, models rely on high-frequency patterns in their training data and typically produce semantically reasonable, runnable skeleton code. Problems at this layer are mostly “inconsistent styling” rather than “unusable output.”

    2.2 Graphics Layer: The Weak Spot for Vectors and 2D Drawing

    Once 2D drawing and vector graphics are introduced, coordinate systems, transformation matrices, stacking order, and the interaction between stroke and fill all come into play at once. A mistake in any one of them shows up as visible misalignment. Failures on these tasks are usually not syntax errors but geometry errors: the code runs, but the picture is wrong.

    2.3 Feedback Layer: Missing Visual Self-Check

    A generative model’s self-correction depends on a closed loop of “observe the output, locate the deviation, apply a fix.” When visual understanding is weak, the model cannot read proportion issues, layer intersections, or texture mismatches from the rendered result. The loop breaks, and defects are delivered as-is.

    3. Root Causes of Common Defects

    • Scale and proportion imbalance: Container sizes, font-size hierarchy, and spacing tokens lack unified constraints, so the model assembles locally reasonable pieces into an unbalanced whole.
    • Layer intersection (overlap): Absolute positioning and stacking order lack explicit conventions, so elements visually cover one another.
    • Texture and asset errors: Inconsistent asset paths, size declarations, and repeat-tiling rules cause stretching or misalignment.
    • Responsive breakage: Scattered breakpoint definitions lead to overflow or compression in intermediate width ranges.

    4. Engineering Improvements

    4.1 Replace Free-Form Output with Constraints

    State design tokens and geometry constraints explicitly in the prompt, turning “make it look good” into “satisfy numeric conditions”:

    1. :root{
    2. --space-1:4px; --space-2:8px; --space-3:16px;
    3. --radius:8px; --z-base:1; --z-overlay:10;
    4. }

    4.2 Generate in Layers: Skeleton First, Graphics Later

    Split the task into four sequential stages — structure, styling, graphics, and interaction — and validate each stage’s output before moving to the next. This significantly reduces the accumulation of geometry-related defects.

    4.3 Close the Loop with Screenshot Review

    Add a rendering-screenshot step to the automated pipeline and feed the image back to the model together with a defect list, forming a “render, compare, fix” iteration. This is the most direct way to compensate for missing visual feedback.

    4.4 Automated Regression and Visual Assertions

    1. // Example: geometry assertions on key elements
    2. const box = el.getBoundingClientRect();
    3. expect(box.width).toBeGreaterThan(0);
    4. expect(box.top).toBeGreaterThanOrEqual(container.top);

    Writing “overlapping, overflowing, or zero-sized” as assertions converts subjective visual judgment into repeatable checks.

    4.5 Human-AI Division of Labor and Observability

    Position the model as an accelerator for producing first drafts, with humans responsible for final visual review. Collect the distribution of generation failure types through logging services and monitoring alerts, and continuously refine prompt templates and validation rules. If you need to host batch generation output, object storage and container platforms can provide isolation and elastic scaling.

    5. Selection and Evaluation Recommendations

    When evaluating these capabilities, drop the single overall score in favor of per-dimension scoring: structural correctness rate, graphics geometry correctness rate, visual self-check hit rate, and rework rounds. Together these four metrics determine the real delivery cost and prevent vague conclusions like “overall performance is similar” from misleading the decision. A realistic expectation plus engineering guardrails is the most reliable practice at this stage.