Evaluating LLM Code Generation and Visual Quality: A Practical Framework

    How should teams evaluate large language model code generation beyond flashy demos? This article presents a practical evaluation framework covering correctness, runnability, maintainability, visual quality, and robustness, illustrated through two case studies: animated SVG generation and pure-code light-and-shadow rendering. It includes checklists, sample code, a scoring rubric, and engineering practices for building a reproducible evaluation pipeline with human blind review.

    As flagship model previews arrive in rapid succession, code generation, agentic capabilities, multimodal perception, and 3D/lighting rendering have become major focal points. Faced with demo videos and cherry-picked examples, developers can easily be misled by “wow moments.” A more reliable approach is to break down model capabilities into reproducible, general-purpose tasks, and evaluate them systematically using a unified environment, fixed prompts, multiple sampling runs, and human blind review. This article does not target any specific product. Instead, it uses two representative cases—animated SVG generation and pure-code light-and-shadow rendering—to discuss how to evaluate LLM coding ability, visual performance, and aesthetic quality, and offers practical engineering recommendations.

    1. Define Evaluation Dimensions First, Not Just Demo Effects

    The quality of LLM-generated code cannot be judged by “does it run” alone. At minimum, evaluation should cover these dimensions:

    1. Functional correctness: Does the code implement the core features in the prompt? Do interactive controls work? Is state handled consistently?
    2. Runnability: Can the output run directly in a clean environment? Does it depend on external resources? Does it still work after export or offline opening?
    3. Maintainability: Is the structure clear? Are variable names sensible? Is there heavy code duplication or hard-to-locate hardcoding?
    4. Performance and cost: Are rendering frame rate, memory usage, first-load time, and offline rendering time within acceptable ranges?
    5. Visual quality: Do composition, lighting, materials, color, level of detail, and stylistic consistency meet the target?
    6. Robustness: Are results stable when prompts change, parameters are adjusted, or generation is repeated?
    7. Security and compliance: Are there external resource leaks, unclearly licensed assets, dangerous scripts, or uncontrolled dependencies?

    Functional correctness and runnability lend themselves to automated checks, while visual quality requires “automated metrics plus human blind review.” Judging a model’s strength from a single success case is rarely reliable.

    2. Case One: A Checklist for Animated SVG Generation

    Animated SVG is an excellent composite task: it tests code structure, graphics drawing, timeline control, interactive state, and self-contained export all at once. The task can be abstracted as: generate an animated SVG featuring a character, a vehicle, an environment background, looping animation, speed control, day/night switching, and pause functionality—with the requirement that it still works when opened offline.

    Suggested checkpoints during evaluation:

    • Self-containment: Are scripts and styles inlined? Does it depend on external images, fonts, or network resources?
    • Animation timeline: Do wheels, scarves, and background elements move on the same time base? Do they stay in sync after speed changes?
    • State consistency: Are pause, play, speed, and day/night controls mutually exclusive or correctly composed?
    • Export usability: Does the file still animate when opened standalone or with no network?
    • Accessibility: Does it include basic titles, descriptions, and fallback display?
    • Code cleanliness: Is animation logic centralized? Are there unmaintainable repeated fragments?

    A simplified structural sketch:

    1. <svg viewBox="0 0 800 450" role="img" aria-label="Character riding animation">
    2. <g id="scene">
    3. <g id="background"></g>
    4. <g id="vehicle"></g>
    5. <g id="character"></g>
    6. </g>
    7. <script><![CDATA[
    8. const state = {
    9. speed: 1,
    10. night: false,
    11. playing: true
    12. };
    13. function frame(time) {
    14. if (state.playing) {
    15. const t = time * state.speed;
    16. // Update wheel rotation, scarf sway, and background offset based on t
    17. }
    18. requestAnimationFrame(frame);
    19. }
    20. requestAnimationFrame(frame);
    21. ]]></script>
    22. </svg>

    Common failure modes include: animations that rely on external scripts and break after export; speed control that only changes some elements, desynchronizing wheels from the background; day/night switching that fails to adjust ambient colors and character shadows together; control state drifting out of sync with animation state; and masses of magic numbers that make later edits painful. For this type of task, evaluation should look beyond “does it move” to whether state is controllable, export is reliable, and structure is maintainable.

    3. Case Two: Technical Approaches and Evaluation for Pure-Code Light-and-Shadow Rendering

    Rendering light-and-shadow scenes purely in code tests higher-order code organization and graphics understanding. Two common routes exist: one uses browser graphics APIs to build real-time scenes, quickly producing interactive visuals through geometry, materials, lights, and shading logic; the other uses CPU or GPU path tracing for offline rendering, approximating realistic lighting through massive sampling—more expensive, but with more natural light transitions.

    Key evaluation points:

    • Lighting consistency: Do window-pane shadows, ambient light, and indirect light share a unified direction?
    • Shadow quality: Are shadow edges too hard or too soft relative to the light source size?
    • Material realism: Do wood floors, walls, plants, and fabric show plausible reflectance and roughness?
    • Geometry and composition: Are object proportions, perspective, and occlusion natural, or does it look like a “just-assembled set”?
    • Noise and convergence: Does path tracing leave residual noise? Is sampling sufficient?
    • Rendering cost: Are offline rendering time, real-time frame rate, and memory usage acceptable?

    Path tracing can be abstracted as pseudocode:

    1. function trace(ray, scene, depth) {
    2. if (depth <= 0) return black;
    3. hit = intersect(ray, scene);
    4. if (!hit) return skyColor(ray);
    5. return shade(hit, scene, depth - 1);
    6. }
    7. for each pixel:
    8. color = average(trace(generateRay(pixel), scene, maxDepth))

    In comparable public demos, cutting-edge implementations often use path tracing with long offline rendering to achieve more natural light transitions, while general-purpose models more often choose real-time graphics APIs—fast to interact with and quick to build, but with harder shadows, flatter materials, and a tendency toward a “stage-set” look. This doesn’t mean the real-time route lacks value; it means evaluation must distinguish between “interactive prototype” and “photorealistic rendering” as goals. Judging a real-time solution by photorealistic standards underestimates its engineering value; judging offline rendering by real-time standards ignores cost and waiting time.

    4. Why Aesthetics Are Hard to Evaluate Automatically

    Aesthetics are subjective, but not entirely unmeasurable. They can be broken into discussable sub-items: compositional balance, lighting layers, material realism, color harmony, detail density, and stylistic consistency. Automated metrics can help detect brightness distribution, edge hardness, noise levels, and rendering time, but they struggle to judge whether an image “looks like a real space.” Blind review is therefore recommended: hide the model’s identity, have reviewers score against the same set of dimensions, and record points of disagreement.

    A workable scoring rubric might be: functional completeness 20 points, runnability 20 points, code maintainability 15 points, performance 15 points, visual quality 20 points, robustness 10 points. Each dimension should have concrete checkpoints to avoid vague “looks good” judgments. For lighting tasks, additional items can include “do shadow softness/hardness match the light source,” “do materials show roughness variation,” and “do indoor dark areas retain detail.”

    5. How to Abstractly Understand the Gap with Frontier Capabilities

    On general tasks, recent LLM progress in code generation is mainly reflected in more complete project scaffolds, more complex interaction logic, longer animation timelines, and richer state control. But in pure-code rendering, complex lighting, and aesthetic control, frontier models may still hold an advantage. The gap usually lies not in “can it write code,” but in “can it organize long rendering runs, handle lighting physics correctly, and maintain material consistency and compositional taste.”

    Closing the gap should also start from systems engineering: add executable feedback so models can self-correct from run results; introduce multimodal review to assess rendered screenshots; build a regression suite covering animation, interaction, lighting, and performance tasks; and accept long-chain tasks in stages rather than generating everything at once and judging only the final screenshot. Note that these are general engineering methods, independent of any specific product’s capabilities.

    To obtain comparable conclusions, fix the following process:

    1. Fix the environment: Record runtime versions, hardware configuration, rendering parameters, and timeout settings.
    2. Fix prompts and sampling count: Generate each task at least multiple times; record success rate and variance.
    3. Automated execution: Open outputs in an isolated environment; check for errors and external resource dependencies.
    4. Artifact retention: Save source code, screenshots, screen recordings, run logs, and timing data for regression comparison.
    5. Human blind review: Hide the source and review visual quality against a unified rubric.
    6. Regression suite management: Add failed cases to the regression set and rerun after every model or prompt change.
    7. Cost tracking: Record generation time, rendering time, and human review time—don’t judge by results alone while ignoring cost.

    For enterprise adoption, the evaluation pipeline can be built on general-purpose capabilities such as object storage, container platforms, logging services, and monitoring/alerting—for example, via Baidu AI Cloud: object storage keeps generated artifacts and screenshots, container platforms provide isolated runtime environments, and logging and monitoring capture execution results and performance metrics. This turns “one-off demos” into a sustainable, regression-based engineering capability.

    7. Conclusion

    Animated SVG and pure-code light-and-shadow rendering are two information-dense evaluation tasks. The former exposes problems in code structure, state management, and export reliability; the latter exposes weaknesses in graphics understanding, lighting quality, and aesthetic control. Overall, current LLMs have clearly improved in code completeness and 3D/lighting generation, but still lag behind frontier levels in photorealistic rendering, natural lighting, and aesthetic stability—closing that gap requires systematic data, feedback, and evaluation mechanisms. For developers, the pragmatic strategy is to use models for prototypes, code scaffolds, and runnable demos, then continuously filter results through automated execution, blind review, and regression suites—rather than substituting a single impressive demo for engineering judgment.