Evaluating Front-End Code Generation in LLMs: Benchmark Results and the Case for Open Source
This article presents an end-to-end evaluation of document-driven front-end code generation, comparing a general-purpose LLM against an international mainstream model across login, list, and form pages. It shows a pattern of stepped degradation: simple scenarios are nearly usable, while complex scenarios lose constraint fidelity. The article also outlines a reproducible testing framework, practical engineering recommendations, and why open-weight models matter for private deployment, fine-tuning, and auditability.
1. Background: Why “Generating a Page” Is Not the Same as “Delivering a Project”
Over the past year, general-purpose LLMs with code generation capabilities have been widely adopted to assist front-end development. Marketing claims often state that a model is “on par with leading international models,” but what developers actually care about is not benchmark rankings. They care about three engineering questions: requirement fidelity, interaction completeness, and maintainability.
A real project-level test is more convincing than any score. This article uses “generate a complete front-end project from a requirements document” as the task to conduct an end-to-end validation of a general-purpose LLM (referred to below as the “model under test”), and compares its output against that of an international mainstream model under the same conditions. The goal is to abstract a reusable evaluation framework.
This article does not judge the merits of any specific product. It only discusses the current state and improvement paths of “document-driven front-end code generation” as a general technical capability.
2. Test Design: Making Results Reproducible
The most common mistake in evaluation is drawing conclusions from a casual trial. To ensure comparability, the following variables must be fixed:
- Unified input: the same requirements document, including a page inventory, field definitions, validation rules, interaction descriptions, and visual style constraints.
- Unified output: a runnable project rather than isolated code snippets, with an accessible preview URL.
- Layered scenarios: a login page (simple form plus carousel), a list page (filtering, pagination, and states), and a form page (multi-field linkage plus validation).
- Recording dimensions: number of missing features, field restoration rate, validation coverage, generation time, and visual completeness.
An illustrative evaluation record structure is shown below:
{"scene": "list_page","expected_filters": 4,"implemented_filters": 0,"field_restore_rate": 0.72,"validation_coverage": 0.45,"duration_minutes": 32,"visual_score": 3}
3. Findings: Capability Shows “Stepped Degradation”
The overall experience can be summarized as: engineering usability over visual polish; simple scenarios are close to usable, while complex scenarios reveal insufficient depth of understanding.
3.1 Login Page: Good Completeness
The carousel, form, and basic validation were all implemented according to the document. The page structure was clear, at a level that could go live after minor edits. This type of scenario is characterized by few fields, few states, and linear interactions, which the model can handle by relying on general priors.
3.2 List Page: Understanding Starts to Slow Down
The page skeleton was correct, but the multi-condition filtering, linked reset, empty states, and pagination logic explicitly specified in the document were entirely missing. The same behavior appeared across multiple list pages, indicating a capability gap rather than an occasional issue. The root cause is that “constraint-type requirements” in a long document are crowded out by the visual generation task in terms of priority.
3.3 Form Page: Insufficient Detail Restoration
Field relationships, conditional required fields, and the timing of error messages were not fully implemented. A complex form is essentially a state machine. The model is better at generating static structures, and its modeling of cross-field dependencies and submission timing remains unstable.
3.4 Style and Efficiency
The visual output was average and engineering-oriented, lacking the restraint and consistency of a mature design system (such as a common component library, design tokens, and spacing conventions). Generation time was noticeably longer than the comparison approach, and queuing and rate limiting under the free tier further amplified the waiting cost.
4. Head-to-Head Comparison: The Gap Is in “Depth of Understanding”
Under the same requirements, the international mainstream model restored field structures, filtering logic, and validation relationships on the list and form pages more completely, and took less time. The gap is not “whether it can write the code,” but “whether it understood the constraints.” This suggests that model capability evaluation should shift from “volume of generation” to “constraint satisfaction rate.”
5. Engineering Recommendations: Use the Model in the Right Place
- Structure the document: break requirements into a field table, a state table, and a validation table to reduce natural-language ambiguity.
- Generate in layers: produce the data model and routes first, then the page skeleton, and finally interactions and validation.
- Put constraints first: fix the tech stack, component conventions, naming, and directory structure in the system prompt.
- Automate validation: use type checking, unit tests, and static scanning as gates on generated output.
- Keep a human in the loop: position the model as an “advanced scaffold,” with key business logic confirmed by developers.
Example prompt snippet:
Output requirements:1. Use only the given tech stack and directory structure;2. Output the field definitions and validation rules table first, then the page code;3. All filter conditions must implement reset and linkage;4. When information is missing, list assumptions; do not silently omit features.
6. The Significance of Open Source for AI Development
The value of open weights and an open ecosystem lies not in matching a single benchmark score, but in three points. First, private deployment is possible, meeting data compliance and cost-control needs. Second, fine-tuning and distillation are possible, allowing general capabilities to be pushed down to vertical scenarios. Third, it is transparent and auditable, making it easier for enterprises to conduct security assessments and secondary development. When open-source models are at a stage of “usable in simple scenarios, to be improved in complex scenarios,” this provides the community with clear improvement targets: long-document constraint parsing, state-machine-style form generation, and verifiable code gates.
For developers, the rational conclusion is: treat open-source models as a controllable, modifiable, and integrable productivity foundation, and use engineering processes to compensate for insufficient depth of understanding. This is currently the most cost-effective path.
