Evaluating LLM Frontend Generation from Requirements Documents
This article presents a practical framework for evaluating how well large language models turn requirements documents into frontend projects. It covers fixed sample design, six evaluation dimensions with 0–2 scoring, structured scoring records, common failure modes, verifiable requirement specifications, and automated structural checks. It also discusses where generated code fits into team workflows and why requirement quality and a repeatable evaluation system matter.
1. Background: From Requirements Documents to Runnable Pages
Large language models can already generate complete frontend projects from natural language descriptions. “Requirements document to page” has moved from concept to a testable scenario. However, whether generated output can enter a development workflow depends on how faithfully it reproduces the requirements. There is a clear gap between a page that runs and a page whose features, fields, and interactions all match the document. Evaluation should therefore separate “can it run?” from “does it understand the requirements?”
2. Designing Evaluation Samples
Evaluation needs fixed input. The same requirements document should be provided to every model under test, and the document structure should be clear. A recommended document includes:
- Page goals and user roles;
- Page structure, including sections, components, and navigation relationships;
- Interaction rules, such as filter combination logic, default values, and reset behavior;
- A field list, including types, required status, value ranges, and dependencies;
- Validation rules and error message copy;
- Exceptions and edge cases, such as empty data, API failures, and duplicate submissions.
Samples should cover three page types: display pages (such as a login page with a carousel), search pages (lists with filters), and data-entry pages (complex forms). The three types differ significantly in difficulty. Evaluating them together reveals where a model falls short.
3. Evaluation Dimensions and Criteria
- Runnability: Can the generated project start directly? Can the page be opened through a URL or local command? Record the time from submitting requirements to obtaining a usable result, and repeat tests to observe stability issues such as queuing and rate limiting.
- Page completeness: Compare against the requirements checklist and count implemented components item by item. Display pages usually have the highest completeness and can serve as a baseline.
- Functional understanding: Are all filters on a search page implemented? Do multiple filters interact according to the documented combination logic? Are reset and pagination consistent with filter state? This dimension best reflects how deeply a model understands the requirements.
- Form fidelity: Are all fields present? Are required and optional fields correct? Do validation rules take effect before submission? Does field linkage work, such as showing a corresponding field only after a certain type is selected?
- Visual consistency: Does the interface conform to the design specification? This item is relatively subjective. Screenshot comparison or unified design tokens can help support judgment.
- Cost and stability: Record elapsed time, retry count, and cost to estimate the expense of scaled use.
Use a 0–2 score for each item: 0 means missing, 1 means partially implemented, and 2 means consistent with the document. Once scoring rules are fixed, teams no longer need vague judgments such as “it looks about right.”
4. Example Scoring Record
Save scoring results as structured data so they can be compared across models and versions:
{"page": "order_form","model_version": "candidate-A","checks": {"fields_complete": 1,"required_rules": 0,"linkage": 1,"validation_on_submit": 0},"elapsed_minutes": 32}
5. Common Causes of Lost Points
- Implicit constraints are not written down. For example, if “select the most recent seven days by default” appears only in a note, the generated result will likely ignore it.
- Multi-condition combinations. When filters have “AND” or “OR” relationships, models tend to implement only individual conditions. Use a table in the document to make combination logic explicit.
- Scattered field dependencies. The value of one field determines the display and validation of other fields. When these descriptions are spread across multiple paragraphs, models can easily miss part of them.
- Unclear validation timing. Validation on input, validation on blur, and validation on submit are three different behaviors. If the document does not distinguish them, generated code often implements only one.
- Cross-page state. Whether filter conditions on a list page are retained after returning from a detail page is unpredictable if the document does not specify it.
6. Writing Requirements in a Verifiable Form
The closer a requirements document is to an executable specification, the more stable generation quality becomes. The structured description below is easier to reproduce accurately than a prose paragraph:
page: registration_formfields:- name: participant_typetype: radiooptions: [individual, team]required: true- name: team_nametype: textvisible_when: participant_type == teamrequired_when: participant_type == teammax_length: 30validation:trigger: on_submitmessage_on_empty: Please enter the team name
This form of writing fixes dependencies, trigger timing, and message copy, so acceptance can be checked item by item.
7. Automated Acceptance Checks
Manual item-by-item review takes time. Key rules can be converted into automated checks. The example below checks whether every required field in the generated form description exists and has validation configured:
def check_required_fields(spec: dict, generated: dict) -> list[str]:problems = []for field in spec["fields"]:if not field.get("required"):continuematch = next((g for g in generated["fields"] if g["name"] == field["name"]),None,)if match is None:problems.append(f"Missing field: {field['name']}")elif not match.get("validators"):problems.append(f"Field has no validators: {field['name']}")return problems
This code only performs structural checks and cannot replace business testing. Its role is to quickly find obvious gaps before manual review.
8. Implications for Teams
With open-source models, teams can deploy privately, review the reasoning process, and fine-tune models for specific business data. This is especially valuable for data-sensitive businesses. However, open source only solves part of the “can we use it?” question. “Using it well” still depends on requirement quality and an evaluation system.
In practice, generation tools are suitable for prototyping, low-complexity admin pages, and project scaffolding. Pages involving complex business rules still require human review and additional testing. Teams should first build a sample library and a scorecard, and then compare different models side by side. Only conclusions reached this way are comparable.
