Multimodal Code Generation: Testing and Evaluation Methods
This article presents a practical framework for evaluating multimodal code generation in real development scenarios, where benchmark scores alone cannot indicate usability. It uses a shared prompt to compare models side by side, categorizes common failure modes, and extends testing to animation and material textures with verifiable checks. A weighted scoring table turns subjective impressions into measurable criteria, prioritizing structural correctness and constraint adherence over visual polish. Engineering recommendations cover building an internal benchmark set, fixing the runtime environment, automating assertions, retaining failure samples, and running reproducible evaluation pipelines.
1. Background: Why Higher Benchmark Scores Do Not Mean Better Usability
Recent model iterations have shown double-digit percentage point gains on a general reasoning benchmark. Such results do indicate progress in knowledge and reasoning. However, developers usually face a different kind of task in real projects: given a single natural language description, produce runnable graphics code directly. This task has no single correct answer, so evaluators must trade off structural correctness, visual quality, and constraint adherence.
A benchmark score alone cannot answer “is this usable?” Building trust requires an in-house testing process.
2. Evaluation Design: Compare Models With the Same Prompt
The original practice used a widely circulated graphics generation prompt, roughly “draw a pelican riding a bicycle as beautifully as possible.” Its value lies in containing three verifiable dimensions:
- Main subject structure: whether the pelican’s body, beak, and legs are complete and reasonably proportioned;
- Secondary objects: whether the bicycle frame, wheels, and pedals are present and correctly positioned;
- Interaction: whether the subject is actually riding the bike rather than floating or misaligned.
A unified prompt, a unified runtime environment, and unified sampling parameters are prerequisites for a fair side-by-side comparison. If any one of them differs, the conclusion does not hold.
3. Observations: Typical Failure Modes
Placing outputs from multiple models side by side shows that failures are highly concentrated and fall into four categories:
- Missing parts: the subject is missing a leg, or the vehicle has no pedals. This is especially common in flat illustration styles, because models tend to simplify strokes.
- Structural breakdown: confused anatomy and messy color schemes, indicating weaker organization of spatial hierarchy.
- Scene over-expansion: the background adds sky, roads, the sun, and birds; details are rich but the subject is diluted, effectively “hiding subject defects behind the background.”
- Vehicle disintegration: the subject renders well, but wheels drift and the frame breaks, indicating insufficient spatial consistency under multiple rigid-body constraints.
Notably, the most stable output is often not the most elaborate one, but the one that makes no compromises on structural completeness. This suggests that structural correctness comes first when evaluating code generation; decorative details come second.
4. Advanced Evaluation: Animation and Material Texture
Static graphics only measure half of the capability. A closer match to real requirements is to add constraints, for example requiring four weather states, animation, and material texture. Such requirements can be broken into verifiable engineering metrics:
// Example: turn vague requirements into assertable checksconst checks = {stateCount: 4, // number of weather stateshasTransition: true, // whether state switches have transitionshasTexture: true, // whether gradients/noise simulate textureframeRateStable: true, // whether the animation drops framesnoLayoutShift: true // whether the layout jitters on switch};
Implementation typically relies on vector graphics plus CSS animation or lightweight script driving. The key points are whether the state machine is clear, rendering is interruptible, and performance is controllable. The following structure can be used directly:
<svg viewBox="0 0 400 300" role="img" aria-label="Weather animation demo"><defs><linearGradient id="sky" x1="0" y1="0" x2="0" y2="1"><stop offset="0%" stop-color="#9fd0ff"/><stop offset="100%" stop-color="#e8f4ff"/></linearGradient></defs><rect class="sky" width="400" height="300" fill="url(#sky)"/><g class="layer" data-state="sunny"></g><g class="layer" data-state="rainy"></g></svg>
5. Scoring Table: Turning Impressions Into Quantifiable Metrics
A weighted score is recommended to avoid subjective arguments:
| Dimension | Weight | How to judge |
|---|---|---|
| Structural completeness | 35% | Whether required parts are present |
| Constraint adherence | 25% | Whether state count, animation, and texture are satisfied |
| Spatial consistency | 20% | Whether relative positions of parts are reasonable |
| Code runnability | 15% | Whether it passes on the first run without errors |
| Visual quality | 5% | Consistency of color scheme and style |
The core idea behind the weights is: runnable and structurally correct matters more than good-looking. Visual quality takes only a small share, because aesthetic preferences vary widely and are unsuitable as a primary criterion.
6. Engineering Recommendations
- Build an internal benchmark set: collect 30–50 real business prompts covering static graphics, animation, and data visualization.
- Fix the runtime environment: unify container images and dependency versions to avoid environment differences polluting conclusions.
- Automate assertions: turn the checks in the table above into scripts, run assertions first and review visual results manually afterward.
- Retain failure samples: failure cases are the most valuable asset and can be used for regression testing.
- Combine with general cloud capabilities: generated results can be hosted on object storage, with log services and monitoring alerts tracking call quality, while a container platform handles elastic scheduling of evaluation tasks.
7. Conclusion
Progress in model capability must be translated into engineering language before it can be trusted. With a unified prompt, categorized failure modes, added animation and texture constraints, and a weighted scoring table, developers can reach conclusions in their own business that are more reliable than public leaderboards. For higher-throughput batch evaluation, a pipeline can be built with general capabilities on Baidu AI Cloud, such as the container platform and object storage, making evaluation itself a reproducible, regression-testable engineering asset.
