Visual Code Generation with Large Models: Testing and Evaluation Methods
This article presents a practical framework for testing and evaluating visual code generation by large language models. Using two representative tasks—a 3D process demo and reference-image-to-webpage reproduction—it explains how to design real-world test cases, score results across five dimensions, and add an automated validation loop. Readers will learn how to move beyond impressive demos and assess whether generated code is functional, state-consistent, interactive, visually faithful, and delivered within acceptable latency.
1. Background: Why “It Generates” Does Not Mean “It Works”
Over the past year, the code generation capabilities of large models have evolved rapidly from “snippet completion” to “full-page application generation.” Among these, visual code generation is the most intuitively perceivable category: a user describes a scene or interaction in natural language, and the model directly produces a runnable web page file. Because the result is visible and executable, it is often treated as a window into a model’s overall capabilities.
However, there is a clear gap between the hype and real performance. A generated result that looks stunning in a demo video may expose problems in real business scenarios, such as chaotic state management, unusable interactions, and missing edge cases. Therefore, the more valuable question is not “can it generate,” but:
- Does the generated result implement all the states and interactions required by the task?
- Can it remain logically consistent in complex scenarios?
- Does the generation latency fall within an acceptable range?
- Is there a reproducible and comparable evaluation standard?
This article uses two typical task types as samples—a 3D process demonstration and reference-image-to-webpage reproduction—to abstract a general testing framework. The article does not involve any specific product; the capabilities and practices discussed are common industry practices.
2. Task Design: Replacing Toy Problems with Real Problems
The first principle of evaluation is that tasks must come from real usage scenarios. Toy problems make it easy for models to produce pretty but hollow results; only real tasks force out engineering details.
2.1 Task A: 3D Process Demonstration
The model is required to generate a single-file web page that demonstrates the complete process of “an aircraft launching from the shore, stage separation, and recovery on an offshore platform.” The constraints should be clearly specified:
- Have a three-dimensional sense of volume and basic lighting;
- The ignition phase has exhaust flames and smoke;
- Stage separation occurs after liftoff;
- The recovery phase deploys legs and uses reverse thrust for deceleration;
- Users can pause, change playback speed, drag the timeline, and switch camera views.
The key to this type of task is not “drawing realistically,” but whether it handles a multi-stage state machine: each stage has entry conditions, duration, and exit conditions, and the timeline can be jumped arbitrarily without state confusion.
2.2 Task B: Reference Image to Webpage Reproduction
Given a reference image of an event registration page, the model is required to reproduce the layout, color scheme, and information hierarchy, and ensure that text such as the title, date, and ticket price is accurate. The evaluation focuses equally on visual consistency and text correctness, rather than just “looking similar.”
The acceptance items can be described using the following structure:
Acceptance Checklist (Example)- Text accuracy: word-for-word comparison of title/date/ticket price- Layout reproduction: grid structure, alignment, whitespace ratio- Visual reproduction: primary color, button states, hierarchy contrast- Responsiveness: overflow or occlusion on narrow screens- Accessibility: semantic tags, contrast, keyboard reachability
3. Evaluation Dimensions: Breaking Down “Feels Good” into Scorable Items
A five-dimension scoring approach is recommended, with each dimension scored from 1 to 5, and the original screen recording and generated files retained for review.
- Functional completeness: whether each constraint listed in the task is implemented; missing one item results in a deduction.
- State consistency: whether contradictions occur after timeline jumps, pause/resume, or camera switches.
- Interaction usability: whether controls actually work, and whether there are pseudo-interactions that are “visible but unclickable.”
- Visual and reproduction fidelity: the layering of the 3D scene, and the color and hierarchy deviation of the reference image.
- Generation latency: the time from request submission to a runnable result; the fluctuation range should be recorded rather than a single value.
When scoring, it is recommended to introduce a “veto item”: for example, text errors, the page failing to run, or core interactions completely failing. If any of these occur, the overall result is judged unusable, avoiding high scores masking fatal defects.
4. Test Observations: Typical Performance of the Two Task Types
In the 3D process demonstration task, a more mature performance is producing a complete single-file result that includes sky and sea reflections, a launch tower and offshore platform, a close-up camera during ignition, a switch to follow mode after liftoff, and a pull-back to the platform view during recovery. Particularly noteworthy is the deployment of legs before landing, flames pointing downward, and finally stabilizing on the platform, which shows that the model handled multi-state coupling rather than simply making an “upward displacement” animation. The generation time is usually significantly longer than for ordinary page tasks, which is a reasonable cost.
In the reference image reproduction task, the time consumption usually drops significantly. Elements such as a light background, dark primary buttons, a left-text-right-image structure, and stacked geometric color blocks on the right can be preserved. Common shortcomings are concentrated in details: compressed font hierarchy, inconsistent spacing, and element crowding on narrow screens.
It should be emphasized that the above observations are used to illustrate the evaluation method and do not constitute conclusions about the performance of any specific system; different implementations, different prompts, and different context lengths will significantly change the results.
5. Engineering Implementation: Making Generated Results Truly Deliverable
5.1 Engineering Context and Prompts
Visual code generation is extremely sensitive to context. It is recommended to structure requirements into four parts: goal, constraints, acceptance checklist, and output format (single file, no external dependencies). Constraints should be as verifiable as possible, avoiding vague expressions like “make it look better.”
5.2 Automated Validation Loop
After generation, validation must be run rather than a quick human visual scan:
Generate -> Static checks (syntax/dependencies) -> Headless browser rendering -> Screenshot comparison -> Interaction script replay -> Scoring and archiving
Interaction script replay is especially important: automatically clicking pause, dragging the timeline to the middle, switching camera views, and then comparing screenshots can efficiently expose state inconsistency problems.
5.3 Latency and Cost Management
Long-running tasks should set timeouts and segmentation strategies: first produce a runnable skeleton, then gradually enhance details; for rendering tasks, progressive enhancement can be used to ensure the first screen is usable.
5.4 Security and Compliance Boundaries
Generated code is untrusted by default. Network access should be restricted, unnecessary system interfaces disabled, rendering performed in an isolated environment, and external resource references whitelisted. If cloud deployment is involved, object storage can host static artifacts, container platforms can host rendering services, and logging services and monitoring alerts can track failure rates and latency distributions—all common capability categories.
6. Conclusion
The value of visual code generation lies not in a stunning one-time demo, but in whether it can be delivered stably under real constraints. Writing tasks into verifiable acceptance checklists, breaking evaluation into scorable dimensions, and connecting generated output to an automated validation loop is the path to turning hype into productivity. For teams, it is recommended to first solidify the evaluation set and scoring standards, then horizontally compare different implementations, so that conclusions are reproducible, traceable, and iterable.
