Evaluating LLM-Generated Frontend Pages: How to Measure Requirement Fidelity

    As large language models are increasingly used for code generation, engineering teams face a practical question: can a model turn a product requirements document directly into a working frontend page? Answering this requires a repeatable evaluation method rather than subjective impressions. This article covers how to assess requirement fidelity, including evaluation dimensions, testing techniques, and practical engineering recommendations for adopting LLM-generated UI code.

    Why Requirement Fidelity Deserves Its Own Evaluation

    Whether a page runs and whether it implements the requirements are two different things. Output from a model often looks structurally complete and visually acceptable, yet it may be missing filter conditions, ignore dependencies between fields, or implement only part of the validation rules. These problems are easy to miss during a quick visual check.

    Evaluations should therefore separate “runs correctly” from “implements the requirements.” The former is basic usability; the latter is functional correctness. Only when both pass does the generated result become worth taking into code review.

    Turning Natural Language Requirements into Verifiable Items

    Requirements documents are usually written as paragraphs, which makes them awkward to use for acceptance testing. A better approach is to break the document down into structured items, each describing a single observable behavior. Common breakdown dimensions include:

    • Page inventory: entry points, titles, and layout regions for each page
    • Field tables: field name, type, required or not, default value, and valid range
    • Interaction rules: what happens after a click, an input, or a toggle
    • State descriptions: how loading, empty data, errors, and permission-denied states are displayed
    • Validation rules: when they trigger (on input, on blur, on submit) and the corresponding error messages

    Once broken down, every item maps to a check action. For example, “the phone number is required, and an invalid format should be flagged before submission” translates into two test cases: submitting an empty value, and submitting a malformed value.

    Evaluation Focus for Typical Page Types

    Login Pages

    Login pages are relatively fixed in structure, and models usually handle the basic layout, inputs, and buttons well. The evaluation should focus on details: whether the carousel’s transition behavior and autoplay interval match the document, whether the password field supports show/hide toggling, and whether login failure messages are accurate.

    A high completion score on the login page does not mean other pages will reach the same level. Record results per page type.

    List Pages

    List pages are where requirement fidelity drifts most often. They typically combine filtering, sorting, pagination, bulk operations, and empty states—and these features interact. For example, when filter conditions change, pagination should reset to page one, selected records should be cleared, and URL parameters should update accordingly.

    Check each item individually:

    • Whether every filter exists and uses the correct control type
    • Whether combining multiple filters applies AND or OR logic, and whether that matches the document
    • Whether the reset action restores defaults
    • Whether filter state survives a page refresh as required

    If the page structure is correct but filters are missing, the model has a gap in functional understanding. Adjusting styles will not fix this.

    Form Pages

    Forms reveal the depth of a model’s understanding best. Fields often depend on each other: a “tax ID” field may only appear after selecting “corporate account,” and an amount field’s upper limit may depend on the chosen service type. These relationships are usually scattered across different paragraphs of the document, so the model must synthesize them to reproduce them correctly.

    When evaluating forms, check:

    • Whether all fields are present, with accurate labels, placeholders, and units
    • Whether conditional show/hide logic follows the rules
    • Whether validation covers required fields, length, format, and value ranges
    • Whether validation triggers and error message placement match the specification
    • Whether button states and duplicate-submission protection during submission are reasonable

    Building Acceptance Checklists and Comparison Tests

    Acceptance checklists should be executable, not just manual click-throughs. Here is a simplified example that records requirement items as data and computes coverage:

    1. from dataclasses import dataclass
    2. @dataclass
    3. class Requirement:
    4. page: str
    5. description: str
    6. kind: str # e.g. field / filter / validation / interaction
    7. passed: bool = False
    8. def coverage_report(items: list[Requirement]):
    9. total = len(items)
    10. passed_count = sum(1 for item in items if item.passed)
    11. missing = [item for item in items if not item.passed]
    12. rate = passed_count / total if total else 0.0
    13. return rate, missing
    14. items = [
    15. Requirement("List page", "Status filter has three options", "filter", passed=True),
    16. Requirement("List page", "Reset restores default filters", "interaction", passed=False),
    17. Requirement("Form page", "Invalid phone number is flagged before submission", "validation", passed=True),
    18. ]
    19. rate, missing = coverage_report(items)
    20. print(f"Requirement coverage: {rate:.0%}")
    21. for item in missing:
    22. print(f"Failed: [{item.page}] {item.description}")

    Coverage alone does not measure quality, but it quickly reveals where gaps concentrate—which page types and which feature categories. Comparing each generation run against historical records also shows how stable the model is across versions and prompting strategies.

    For validation rules, you can write unit tests directly. The following example tests a phone number rule:

    1. import re
    2. def is_valid_phone(value: str) -> bool:
    3. return re.fullmatch(r"1\d{10}", value) is not None
    4. def test_phone_rule():
    5. assert is_valid_phone("13800138000")
    6. assert not is_valid_phone("")
    7. assert not is_valid_phone("1380013800")

    The advantage of rule-based tests is that they are stable and repeatable. No matter which run produced the generated code, the same test cases can verify it.

    Common Factors That Affect Fidelity

    Requirement fidelity depends on more than the model itself—how you provide input and structure the workflow matters just as much.

    First, ambiguous requirements amplify errors. “Supports multi-condition filtering” says nothing about whether conditions combine with AND or OR, so the model may pick either interpretation. Requirement authors should specify boundaries, defaults, and edge cases explicitly.

    Second, when a single task is too large, details get lost. Handing an entire system to the model at once works far worse than splitting it into pages or modules and generating and validating each one separately.

    Third, multi-turn correction needs structured feedback. Saying only “this is wrong” has limited effect. Pointing to the specific requirement item, the expected behavior, and the current behavior usually leads to higher fix success rates.

    Fourth, evaluate visual fidelity and functional fidelity separately. A polished interface does not imply correct logic, and correct logic does not imply a usable interface.

    Engineering Recommendations

    When introducing model-generated pages into your team’s workflow, consider the following practices:

    • Split work by page and validate each page independently
    • Fix data structures and API contracts first, then generate the UI, reducing rework caused by coupling
    • Reuse your team’s existing component library and style guidelines so generated code matches your codebase
    • Write automated tests for core logic such as validation and filter queries rather than relying on manual clicking
    • Keep requirement items and acceptance records for traceability and cross-version comparison

    From the perspective of open-source models, their main value to engineering teams lies in private deployment, auditability, and the ability to customize with business data. When choosing a model, base the decision on your own requirement checklist and compare candidates against the same acceptance criteria—not on marketing claims or isolated examples.