Evaluating LLM Front-End Code Generation: A Practical Testing and Scoring Framework
Front-end code generation has become a key benchmark for large language models, but casual testing often leads to unreliable conclusions. This article presents a practical evaluation framework covering high-signal test prompts, a five-layer scoring rubric, prompt versioning, sampling strategies, and the separation of capability metrics from service metrics. It also includes advanced rule-based simulation tasks and a reusable regression workflow for consistent model selection.
1. Why “Generate a Web Page” Became a Hard Benchmark for LLMs
In recent model capability competitions, front-end code generation has shifted from a demo feature to a productivity metric. The reason is straightforward: the web page is the closest interface to the end user. Whether a model can translate a natural-language intent into a runnable, interactive, and visually acceptable UI tests its semantic understanding, abstraction, code organization, and visual fidelity all at once.
However, many teams make mistakes during model selection: they throw a few prompts at a model, glance at a few screenshots, and draw conclusions. The problem is that front-end generation tasks have extremely high variance—the same model can perform noticeably differently across time windows, workloads, and prompt granularity. To reach a trustworthy conclusion, you need to upgrade “user experience” into “evaluation.”
2. A High-Discrimination Test: Recreating a Classic Desktop Interaction
A high-value prompt is to build a desktop-style web page with draggable windows and a classic 3D window-switching effect. This task is effective because it compresses several hard requirements at once:
- Layering and hit testing: correct z-index management, boundary constraints while dragging, and click-through control.
- Visual fidelity: translucent glass texture, button highlights, and layered shadows—details models tend to “simplify away.”
- Interactive animation: 3D switching involves perspective, transform matrices, and animation timing; one wrong property breaks the whole effect.
A sample requirement description can be written as:
Generate a single-file web page:1. Desktop background + top taskbar;2. At least 3 windows, draggable, minimizable/maximizable, closable;3. Window style: translucent glass texture with highlights and shadows;4. Provide a 3D stacked switching view with transition animation;5. Pure front-end implementation, no external resource dependencies.
The value of this task is that it breaks “looking good” into verifiable atomic items, making item-by-item scoring possible.
3. Evaluation Dimensions: Turning Subjective Feel into Quantifiable Metrics
Split scoring into five layers, score each independently, then apply weights:
- Runnability: does it run on the first try, and is the console error-free?
- Requirement coverage: how many explicitly listed requirements are implemented, and is anything “fake-implemented”?
- Interaction correctness: do dragging, clicking, and switching actually work, rather than only producing a static appearance?
- Visual fidelity: are transparency, border radius, shadows, and color scheme close to the target style?
- Code quality: is the structure clear, self-contained in a single file, and easy to iterate on?
The failure mode to watch most closely is “fake implementation”: a button is placed on the UI but has no click logic, or the 3D switching is only a static tilt effect. Such cases should be marked as a direct fail, not given partial credit.
4. Controlling Variables: Prompts and Iteration Strategy
It is common that performance drops after multiple rounds of prompt iteration. There are three typical causes:
- Prompt bloat: continuously appending constraints dilutes the model’s attention, and key requirements get buried.
- Constraint conflicts: newly added requirements contradict earlier ones, forcing the model to compromise and satisfy neither.
- Randomness: sampling randomness makes the same prompt produce different quality across runs, so a single comparison is not conclusive.
A more reliable approach is to maintain a “baseline prompt,” make only single-point changes when necessary, and keep each version with result screenshots:
# Baseline v1 (frozen, no further changes)[Requirement list 1-5]# Iteration logv2: only add "make the glass texture more obvious", everything else unchangedv3: roll back v2, change to "softer window shadows"
Also sample each version at least 2–3 times and evaluate the median, so you do not mistake luck for capability.
5. Load and Speed: Do Not Misread Queueing Delay as Capability Regression
It is common to hear “too many users, it is very slow.” This happens frequently in evaluation. Generation tasks under high concurrency experience queueing, rate limiting, and timeout retries, showing up as high time-to-first-token, longer total latency, and even mid-run failures. Two metric types must be distinguished clearly:
- Capability metrics: whether the output is correct, complete, and visually acceptable.
- Service metrics: time-to-first-token, total latency, and success rate.
Service metrics vary heavily by time window, so the report should separately note the test time and concurrency environment; capability evaluation should be repeated during low-load periods. Mixing both into one table is the most common source of distorted conclusions.
6. Advanced Task: Stress-Testing Abstraction with a Rule-Based Simulation Game
What separates models more than UI recreation is an interactive application with implicit rules, such as a simplified real-time strategy mini-game. The key is whether the model understands the concepts themselves rather than copying the literal wording:
- Changing turn-based to real-time means the model must understand the abstract trait of “time fairness for both sides, no manual turn ending”;
- Adding an auto-research assistant system is an extension absent from the original rules, testing intent transfer;
- Unit auto-targeting involves pathfinding and target addressing, testing algorithm implementation;
- Control-panel requirements test state management and UI linkage.
Scoring for this type should emphasize “rule self-consistency”: whether resource generation, tech unlocking, and unit pathfinding form a closed loop, rather than how flashy the visuals are. A workable acceptance script idea: run without input and observe whether units move and engage autonomously; enable auto-research and observe whether tech progress advances over time.
7. A Reusable Evaluation Workflow
- Build a question bank: 3–5 fixed tasks covering static recreation, interaction logic, and rule modeling.
- Freeze prompts: version the baseline and keep a change log.
- Sample multiple times: at least 3 runs per task, recording success rate and median quality.
- Record on two dimensions: log capability scores and service metrics separately, noting the test window.
- Regression validation: rerun the same question bank after a model or platform update to form a trend curve.
For enterprise adoption, store evaluation artifacts in object storage, use logging and monitoring/alerting to track generation success rate and latency distribution, and run batch concurrency stress tests on a container platform, turning “personal perception” into reusable baseline data for the team.
8. Conclusion
A single good generation does not equal strong capability, and a single poor result does not mean the model is weak. The reliable approach is: fixed question bank, frozen prompts, multiple samples, and capability evaluated separately from performance. Under this framework, whether recreating a classic desktop interaction or building a rule-based real-time strategy mini-game, you get comparable, regression-testable, and explainable conclusions—moving model selection from “looking at screenshots” to “looking at data.”
