Evaluating LLM-Generated Interactive Web Pages: A Benchmarking and Prompt Iteration Guide

    This article explores how to objectively evaluate large language models (LLMs) on the task of generating interactive web pages from natural language descriptions. It introduces a reproducible evaluation pipeline, defines five weighted scoring dimensions, and details two typical scenarios: recreating classic desktop window effects with 3D transitions, and converting turn-based strategy gameplay into real-time strategy (RTS). Practical code examples, prompt engineering techniques, and multi-round iteration pitfalls are covered, along with a browser-based automation checklist for turning subjective impressions into measurable results.

    Why Interactive Web Page Generation Is a Strong Test of Code Models

    In code capability evaluation, function-level completion, unit test generation, and bug-fixing tasks are already mature. However, they all share a common limitation: the task boundaries are clear and the acceptance criteria are explicit, so the model only needs to be locally correct to score points. Generating a working, playable, visually complete web application from a natural language description is the opposite. It requires the model to handle requirement understanding, architecture selection, state management, rendering implementation, and style restoration in a single pass—and the result can be instantly judged by a human in a browser.

    This type of task is highly discriminative for three reasons:

    1. Multiple interlocking constraints. A single sentence often contains interaction behavior, visual style, and performance requirements that constrain each other. The model must make trade-offs rather than simply concatenate features.
    2. Long-output consistency. The artifact is often over a thousand lines. Naming conventions, state fields, and event bindings must remain self-consistent. “Forgetting earlier conventions” is a common failure mode.
    3. High abstraction level. For example, “make it real-time strategy instead of turn-based” requires the model to fill in domain knowledge—both sides share equal time, no manual end-turn button, units need continuous pathfinding and combat—rather than just changing a button label.

    Therefore, building a reproducible evaluation pipeline for such tasks is far more valuable than casually “trying one prompt here and another there.”

    Turning Subjective Impressions into Reproducible Experiments

    The same prompt can produce unstable results across different times, entry points, and concurrent load conditions. To make conclusions trustworthy, at least the variables must be fixed. Record them in an “experiment card” as shown below:

    Variable What to Fix
    Input Full prompt text (with version number), system prompt, attached files
    Sampling Temperature, max output length, whether reasoning mode is enabled
    Execution API entry point, concurrency window, timeout and retry policy
    Environment Browser version, viewport size, whether low-end device emulation is used

    One important caution: when generation becomes noticeably slower, first determine whether the cause is server-side queueing or model capability change. Throughput drops during high concurrency are common. Compare results only after off-peak runs, fixed sampling parameters, and repeated sampling. Do not directly attribute latency issues to model degradation.

    The scoring dimensions can be simplified to five, with suggested weights for model selection:

    • Runnability (weight 0.25): Can the artifact open in a browser with zero changes and complete the main flow?
    • Constraint adherence (0.25): Check each requirement item and count how many pass.
    • Visual fidelity (0.2): Are target style details correct, such as translucency, border highlights, and shadow layers?
    • Interaction correctness (0.2): Count defects like out-of-bounds dragging, state loss, or unresponsive clicks.
    • Iteration stability (0.1): After multiple rounds of added requirements, are previously working features broken?

    Scenario 1: Recreating Classic Desktop Windows with 3D Switching Effects

    The target look-and-feel for this type of task is usually “classic desktop window dragging plus 3D layered switching.” The common problem is not that the model cannot write code, but that it only reproduces a static screenshot: windows display but cannot be dragged, or the switching lacks perspective layers and the glass blur turns into a white smudge.

    The real engineering difficulty centers on three points:

    • Dragging coordinate system and boundaries. Mouse coordinates and element offsets must be computed by difference, and constrained within the viewport; otherwise windows can be dragged off-screen and become unrecoverable.
    • Stacking and hit-testing. Bringing a window to the front requires a monotonically increasing z-index, while also avoiding all windows being on the same layer, which would cause click-through issues.
    • Performance. Large-area blur (frosted glass) significantly raises compositing cost. When multiple windows overlap, frame drops can occur.

    Reference implementation (pointer events unify mouse and touch):

    1. const state = { dragging: null, offsetX: 0, offsetY: 0 };
    2. let topZ = 10;
    3. function onDown(e) {
    4. const bar = e.currentTarget;
    5. state.dragging = bar.parentElement;
    6. state.offsetX = e.clientX - state.dragging.offsetLeft;
    7. state.offsetY = e.clientY - state.dragging.offsetTop;
    8. state.dragging.style.zIndex = ++topZ; // monotonic bring-to-front
    9. bar.setPointerCapture(e.pointerId); // keep receiving events outside element
    10. }
    11. function onMove(e) {
    12. if (!state.dragging) return;
    13. const el = state.dragging;
    14. const maxX = innerWidth - el.offsetWidth;
    15. const maxY = innerHeight - el.offsetHeight;
    16. const x = Math.min(Math.max(e.clientX - state.offsetX, 0), maxX);
    17. const y = Math.min(Math.max(e.clientY - state.offsetY, 0), maxY);
    18. el.style.transform = `translate3d(${x}px, ${y}px, 0)`;
    19. }
    20. function onUp(e) {
    21. state.dragging?.releasePointerCapture(e.pointerId);
    22. state.dragging = null;
    23. }

    The 3D switching relies on perspective and preserve-3d to create real depth, not fake scale effects:

    1. .stage { perspective: 1200px; transform-style: preserve-3d; }
    2. .win { transition: transform .45s cubic-bezier(.2,.8,.2,1), opacity .45s;
    3. backface-visibility: hidden; will-change: transform; }
    4. .win.active { transform: translateZ(120px) rotateY(0deg); opacity: 1; }
    5. .win.left { transform: translateX(-140px) translateZ(-320px) rotateY(35deg); opacity: .55; }
    6. .win.right { transform: translateX( 140px) translateZ(-320px) rotateY(-35deg); opacity: .55; }

    When evaluating, add three hard checks: does dragging stop at the boundaries, does rapid back-and-forth dragging avoid jank, and does switching again mid-animation cause frame drops or misplaced layers?

    Scenario 2: Converting Turn-Based Strategy into Real-Time Strategy

    Transforming a classic turn-based strategy gameplay into real-time strategy (RTS) is a strong test of the model’s domain understanding. The compound difficulty lies in adding a real-time loop while also stacking auto-research, auto-pathfinding, hexagonal grids, speed control, and iconification into a set of coupled requirements.

    A breakdown of what each requirement tests:

    Requirement Capability Tested Typical Failure Mode
    Turn-based to RTS Domain knowledge completion (fair time for both sides, no end-turn button) Still keeps an “End Turn” button, merely hiding the countdown
    AI assistant auto-research Understanding intent for a new system not in original gameplay Only a checkbox, not connected to real tech tree state
    Units auto-find opponents and cities Target seeking + pathfinding algorithm Units jitter in place, clip through walls, or get permanently stuck
    Speed slider 1x–10x Decoupling logic from rendering Only animation duration changes, causing combat resolution errors
    Hexagonal grid Coordinate system and adjacency Uses square tiles as a disguise, adjacency checks wrong
    Keyboard arrows to move viewport Event handling and camera model Arrow keys are hijacked by page scrolling
    City/unit iconification Balance between information density and readability Icons too large block cells, or all use the same symbol

    The key is decoupling logic from rendering: use a fixed time step for simulation, and let the speed slider control how many logic frames are advanced per unit of real time.

    1. const TICK = 100; // logic step 100ms
    2. let acc = 0, last = performance.now(), speed = 1; // speed ∈ [1, 10]
    3. function loop(ts) {
    4. // clamp per-frame delta to avoid massive catch-up when tab is inactive
    5. acc += Math.min(ts - last, 250) * speed;
    6. last = ts;
    7. while (acc >= TICK) { simulate(); acc -= TICK; } // combat, research, pathfinding here
    8. render();
    9. requestAnimationFrame(loop);
    10. }

    Hexagonal coordinates use axial coordinates; distance and adjacency are pure arithmetic, less error-prone than odd-even row offsets:

    1. const HEX_DIRS = [[1,0],[1,-1],[0,-1],[-1,0],[-1,1],[0,1]];
    2. function hexDistance(a, b) {
    3. const dq = a.q - b.q, dr = a.r - b.r;
    4. return (Math.abs(dq) + Math.abs(dr) + Math.abs(dq + dr)) / 2;
    5. }
    6. // Breadth-first search returns the next cell to move to; called each tick per unit
    7. function nextStep(start, goal, isPassable) {
    8. const queue = [start], from = new Map([[key(start), null]]);
    9. while (queue.length) {
    10. const cur = queue.shift();
    11. if (cur.q === goal.q && cur.r === goal.r) break;
    12. for (const [dq, dr] of HEX_DIRS) {
    13. const nb = { q: cur.q + dq, r: cur.r + dr }, k = key(nb);
    14. if (from.has(k) || !isPassable(nb)) continue;
    15. from.set(k, cur); queue.push(nb);
    16. }
    17. }
    18. // backtrack to first cell after start; that is the move target for this frame
    19. return backtrack(from, start, goal);
    20. }

    The async research assistant is a separate state machine driven by the main loop rather than setTimeout, so it accelerates with the speed multiplier:

    1. const assistant = { enabled: false, current: null, progress: 0 };
    2. function simulate() {
    3. if (assistant.enabled && !assistant.current) assistant.current = pickResearch();
    4. if (assistant.current) {
    5. assistant.progress += researchRate(); // affected by resources and population
    6. if (assistant.progress >= costOf(assistant.current)) {
    7. unlock(assistant.current);
    8. assistant.current = null;
    9. }
    10. }
    11. }

    Multi-Round Prompt Iteration: Why It Gets Worse

    A common frustration: the first-round result is decent, but after two rounds of modifications, the output degrades. This is usually not a drop in model capability but constraint pollution and instruction forgetting. Modification requests are appended in natural language at the end, and older implicit preferences (e.g., “don’t use external dependencies”) get diluted in the long context. The model starts patching old code instead of rewriting it.

    A reusable practice is to make aesthetic and engineering constraints explicit, structured, and minimal-change per iteration.

    1. [Artifact form] Single HTML file that runs by double-click, no external resources, no build tools.
    2. [Hard constraints]
    3. 1. Windows are draggable and cannot go out of the viewport;
    4. 2. 3D switching uses real perspective, not scaling simulation;
    5. 3. Logic advances with a fixed time step; the 1x–10x speed slider only affects the number of logic frames;
    6. 4. The map is hexagonal; adjacency and distance use axial coordinates;
    7. 5. Arrow keys move the viewport and prevent page scrolling.
    8. [Style] Frosted-glass windows with translucency; blur radius ≤ 12px; avoid large-area stacking that drops frames.
    9. [Output] Provide the full code first, then list 3 manual testing steps I can run in the browser.
    10. [Self-check] Before generating, check each hard constraint; if any cannot be met, explicitly state why.

    Three iteration disciplines to follow:

    • One variable at a time: change only one point per iteration, keep the rest of the prompt identical, so regressions can be traced to a specific change.
    • Version the prompt chain: map prompt@v3 to its artifact; when regression occurs, use binary search to locate the problematic change.
    • Require a self-test checklist: ask the model to restate constraints before generating output—this significantly reduces omission rates.

    Turning Evaluation into a Pipeline

    Manual visual inspection cannot scale. Build automation around a “question bank + assertion-based acceptance” approach:

    1. // browser automation pseudocode: translate requirements into executable assertions
    2. await page.goto(artifactUrl);
    3. // assertion 1: dragging works
    4. const before = await page.$eval('#win', el => el.getBoundingClientRect().x);
    5. await page.mouse.move(handle.x, handle.y);
    6. await page.mouse.down();
    7. await page.mouse.move(handle.x + 200, handle.y + 120, { steps: 10 });
    8. await page.mouse.up();
    9. assert((await page.$eval('#win', el => el.getBoundingClientRect().x)) > before);
    10. // assertion 2: speed slider changes advancement rate
    11. await page.$eval('#speed', el => { el.value = 10; el.dispatchEvent(new Event('input')); });
    12. assert(await measureTurnsPerSecond() > baseline * 5);
    13. // assertion 3: visual regression screenshot
    14. await page.screenshot({ path: `shots/${caseId}-r${round}.png` });

    On the cloud side, generic capabilities can be layered: container platforms provide isolated sandbox execution environments; object storage archives artifacts and screenshots; message queues distribute batch evaluation tasks; logging and monitoring track failure distributions and latency trends. On the model side, a unified large-model service (e.g., Baidu AI Cloud’s Large Model Platform) can be used for version canary, quota management, and cost allocation. The final output is a set of four key reports: first-pass success rate, constraint coverage rate, average iteration rounds, and defect type distribution.

    Checklist for Implementation

    • Build 10–20 custom tasks covering three difficulty levels: “static restoration / interaction logic / long-output consistency.”
    • Write fixed acceptance assertions for each task; avoid concluding with “looks good.”
    • For comparative experiments, fix sampling parameters and runtime environment; when latency anomalies appear, first suspect server-side queueing.
    • Focus on regression rather than peak performance: whether old features survive after multiple added requirements is a better predictor of engineering usability than a single impressive round.
    • Turn frequently failing prompt patterns into team templates, e.g., explicitly declaring “zero external dependencies” or “decouple logic from rendering.”

    In summary, evaluating whether a code model is suitable for front-end delivery is not about whether it can create a beautiful one-off demo, but whether it can stay stable in a real workflow that involves multiple constraints, long outputs, and repeated iteration. Fixating the task set, the prompts, and the acceptance assertions as reusable assets is the key to making model selection reproducible and iteration returns cumulative.