Evaluating UI Generation Quality: Methods and Prompting Practices
This article explores practical methods for evaluating UI code generation quality using large language models. It addresses the common challenge where preview models seem to outperform official releases by shifting the focus from subjective aesthetics to reproducible engineering problems. Topics include identifying sources of visual discrepancies, building reproducible sample sets, defining checkable visual constraints, structured prompt iteration, and enterprise-level implementation strategies for stable and maintainable UI generation.
Shift the Problem from “Which Looks Better” to “Which is More Reproducible”
When developers try new generations of code models, they often encounter a contrast: during anonymous or preview phases, the generated interfaces look closer to the design mockups, but the official release produces flatter, more utilitarian results with weaker control hierarchies for the same tasks. Window buttons, translucent glass textures, shadow layers, and spacing rhythm are usually where these differences first appear. If you repeatedly tweak prompts without fixing the inputs and acceptance criteria, it is easy to conflate “model behavior changes” with “prompt drift,” leaving you unable to recover the previous effects even after several iterations.
A more robust approach is to treat UI generation as a regression engineering problem: fix the tasks, fix the constraints, and fix the visual standards, then compare different model versions or prompting strategies. The following discussion does not bind to any specific model or platform; it only covers general industry practices for evaluation and prompting.
Where Do Visual Differences Usually Come From?
UI code is extremely sensitive to details. A simple instruction like “create a modern desktop-style window” can lead to completely different implementations based on different sampling and decoding preferences. Common reasons include:
- Changes in training and alignment goals. Before an official release, safety, formatting, and general code correctness are often strengthened. Bold visual styles like heavy translucency, frosted glass, and fine borders might be suppressed by a more conservative default aesthetic.
- Changes in system prompts or hidden templates. The default role, output length, and whether a component library is forced in preview channels versus official channels will all alter the structural hierarchy.
- Different decoding parameters. When temperature, top-p, or maximum length change, the probability of button border radius, transparency, and backdrop effects appearing also shifts.
- Prompts becoming longer and conflicting during iteration. To remedy a single failure, developers often append numerous adjectives, causing the model to average out the styles rather than emphasizing a specific visual key point.
- Too few evaluation samples. A single good-looking screenshot does not guarantee the same stability across forms, lists, popups, and dark modes.
Therefore, “the preview looked better” should first be recorded as a phenomenon, and then controlled experiments should be used to determine whether the difference comes from the channel, parameters, or broken prompts.
Build a Minimum Reproducible Sample Set
Do not use an open-ended single sentence as your only test case. It is recommended to prepare 6 to 10 fixed tasks, specifying the layout, components, and mandatory visual attributes for each. For example:
- Desktop-style main window: title bar, three types of buttons (minimize, maximize, close), draggable area, and content area padding.
- Translucent panel: background must have layers, foreground text contrast must meet standards, and it should not rely on a solid white base.
- Form page: labels, inputs, primary and secondary buttons, error states, with spacing using the same scale.
- List with sidebar: selected state, hover state, and consistent divider thickness.
- One version each for dark and light themes, preventing a scenario where it only “accidentally looks good” under one theme.
- One version each for narrow and wide screens, checking if buttons are squished or if glass layers blur into a solid color block.
For each sample, simultaneously save: the original prompt, generated code, rendered screenshot, and failure notes. When comparing the “previous version” and the “current version,” only swap the model or channel, keeping the prompts and rendering environment unchanged. The rendering environment includes the browser viewport, fonts, and whether background blur is enabled. Background blur support varies across different runtimes; what looks like model regression is sometimes just the style being downgraded to a solid color.
Write Visual Requirements as Checkable Clauses
Stacking adjectives is less effective than defining verifiable constraints. Examples of checkable clauses include:
- The title bar height is fixed within a specific range, and the three window button sizes are similar and aligned.
- The panel background uses a translucent color and provides blur or an equivalent layering method; if the environment does not support blur, borders and shadows must be used to preserve layers rather than degrading into a solid white board.
- The contrast between body text and the background meets common readability requirements; do not write text into unreadable gradients just for the “glass” effect.
- Primary and secondary buttons are distinguishable by fill, border, and font weight.
- Border radius, spacing, and shadows use only a few tiers, preventing each component from having its own set of magic numbers.
These clauses serve both visual inspection and subsequent automated checks: statically scanning styles for transparency, blur-related declarations, and button grouping structures. Automated checks cannot replace human perception, but they prevent situations where “the model verbally agrees to a glass effect but outputs a solid background in the code.”
An illustrative acceptance snippet can be very short, expressing only constraints without binding to any framework:
Acceptance:1. A title bar exists and contains three distinguishable controls: minimize, maximize, and close.2. The main panel background is less than fully opaque and has a border or shadow.3. If background blur is used, the text area must have a sufficient contrasting backing.4. Spacing only uses multiples of 4, and border radius does not exceed two tiers.
The Order of Prompt Iteration
In the original scenario, it is common to tweak prompts for two rounds and still not achieve the earlier results. It is recommended to follow this sequence instead of changing everything at once:
- Reproduce first. Run the original prompt, same length limits, and sampling settings several times to see if the previous good effect was stable or just a lucky sample.
- Diff next. Compare only the structure of the two outputs: are the title bar buttons missing? Was translucency written as a solid color? Was blur written into a non-functional property?
- Add a failure clause instead of rewriting the entire persona. For example, just add “the close button must be visible, and the panel must not use opaque pure white as its only background.”
- Remove conflicting style words. If you demand both “minimalist flat” and “heavy glass and highlights,” the model will compromise into a mediocre solid card.
- Control length. Overly long prompts dilute critical visual sentences. Placing mandatory items in a short list at the end is usually more effective than burying them in a long background introduction.
- Fix randomness before discussing style. If each run varies wildly, lower the randomness or sample multiple times to take the median visual perception before judging if the prompt is effective.
During iteration, keep the “best historical prompt” intact; do not continuously overwrite the only copy. Otherwise, you cannot prove whether the model changed or the prompt was broken.
How to Interpret “Official Version is Worse Than Preview”
After aligning the channel, parameters, and prompts, if the official output still systematically lacks layers, you can conclude that the default style is more conservative, not that your prompt is “wrong.” At this point, reasonable expectations are:
- Use more specific structural and style constraints to pull the style back, accepting that the prompt will become longer and its generalization to other tasks may decrease.
- Put visual styles into reusable style snippets or design tokens, letting the model fill in the layout and copy, rather than inventing frosted glass from scratch every time.
- Do manual finishing for key pages, treating the model as a draft generator rather than the final visual arbiter.
What you should not do is grade an entire model based on a single screenshot, or treat a single anonymous trial as a stable capability in public conclusions. The system prompts and post-processing for preview traffic and official traffic may differ, and the samples are not public, so they cannot be directly extrapolated.
Implementation Suggestions for Enterprise Scenarios
If a team integrates UI generation into daily R&D, it is recommended to:
- Version control prompts and sample sets, just like code. Run the same UI regression suite for every model or channel upgrade.
- Score across multiple dimensions instead of using a single total score. At least separate: structural completeness, visual hierarchy, accessible contrast, code maintainability, and first-time run rate.
- Log failure modes. For example, “buttons drawn as pure decoration,” “transparency optimized away,” or “blur only written in comments.” These are much better at guiding the next constraint than simply saying “it doesn’t look good.”
- Write the rendering environment into the evaluation documentation. Fonts, viewport, and whether background blur is supported must be specified, otherwise screenshots are not comparable.
- Assume manual review for outputs by default. Generated code must be readable and editable, avoiding layers of nested inline styles that cannot be handed off.
Cloud object storage is suitable for storing screenshots and prompt versions, while logs and monitoring are good for viewing failure rates and retry counts. These are just general engineering practices used to preserve evidence; they do not replace human judgment on visual hierarchy and contrast.
Summary
The highlight of UI generation lies not in how exquisite a single screenshot is, but in whether the same task can consistently deliver results with complete structure, clear hierarchy, and passing contrast. A better-looking preview often indicates the existence of a stronger style sampling. When using the official release, apply fixed sample sets, checkable clauses, and restrained prompt iteration to recover it. If it cannot be recovered, record the difference as a default style or channel difference, and bridge the gap using style tokens and manual review, rather than endlessly stacking adjectives.
