Evaluating LLM Front-End Code Generation: Prompt Design for Complex Interaction Tasks
This article explains how to evaluate large language models on front-end code generation using complex interaction tasks rather than simple demo prompts. It presents two test tasks—a realistic desktop-style web page and a turn-based strategy game converted into real-time strategy—and analyzes what they reveal about visual fidelity, animation, concept understanding, algorithm modeling, and instruction following. It also offers practical recommendations for building a repeatable evaluation system with fixed test sets, checklist-based scoring, stability checks, and separate measurement of response speed and output quality.
Why Complex Interaction Tasks Are a Better Test
Many teams choose simple tasks such as “build a login page” or “generate a Todo List” when evaluating large language models. The problem is that mainstream models can pass these tasks almost universally, so the results have very low discriminative power and do not reflect model performance in real engineering scenarios.
Tasks with real discriminative power usually have three characteristics:
- Multiple overlapping constraints: They combine requirements across visual reproduction, interaction logic, state management, and other layers. Any omission directly affects the result.
- Implicit knowledge testing: For example, a “real-time strategy game” requires the model to understand the essential features of the genre—no turn-confirmation button, both sides advancing under fair time pressure, and units acting continuously. Models cannot handle these abstract concepts with templated wording alone.
- Completeness in a single generation: Whether the model can cover all requirements in one round directly reflects its planning ability and instruction-following ability.
Test Task 1: A Realistic Desktop-Style Web Page
2.1 Task Design
The first test asks the model to generate a web page in the style of a desktop operating system. Core requirements include:
- Windows can be dragged freely.
- Windows have a translucent glass-like visual style.
- Classic 3D window-switching animations are included.
This task examines visual reproduction and animation orchestration. Translucent frosted-glass effects involve CSS techniques such as background filters, stacking contexts, and transparency blending. 3D window switching requires the model to understand perspective principles for 3D transforms and animation timing control.
2.2 Evaluation Observations
In practice, the same generation of models accessed through different versions or channels can show noticeable differences. Common issues include:
- Lost visual details: The dimensionality of window buttons and the highlight and blur layers of the glass texture are not reproduced accurately.
- Degraded animation implementation: A 3D flip transition that should be implemented is simplified into a simple fade in and fade out.
- Performance fluctuation: When traffic is high shortly after a new model launch, response speed can drop noticeably, and generation quality may regress compared with the internal testing phase. This is especially worth noting when an anonymous preview stage performed better, suggesting possible capability differences between a gray-release version and an official version.
When the first-round result is unsatisfactory, do not reject the model immediately. Iterate on the prompt first: replace vague adjectives such as “make it look better” with specific technical descriptions such as “use a backdrop-filter frosted-glass effect for the window title bar, and use circular highlight styles for control buttons.” Usually, after two or three rounds of iteration, the result improves significantly.
Test Task 2: Turning a Turn-Based Strategy Game into a Real-Time Strategy Game
3.1 Task Design and Evaluation Intent
The second test is more discriminative: generate a web-based strategy game and add four modification requirements. The value of this task is that some requirements are features that do not exist in the original game. The model cannot rely on memorized answers and must truly understand the intent and implement them from scratch.
Requirement 1: Change to real time. This tests the model’s understanding of the abstract concept of “real-time strategy.” A correct implementation means the game loop runs continuously, both sides’ units act synchronously, and there is no turn-confirmation button. In testing, stronger models can get this right in one attempt.
Requirement 2: AI-assisted research system. Add a selectable “AI assistant” that automatically completes technology research when resources allow. This feature does not exist in the original game, so it tests the model’s ability to infer the intent of a new system. A correct implementation requires the model to design resource-check logic, a research queue, and automated trigger conditions on its own.
Requirement 3: All units automatically seek enemies. This involves path planning and target-search algorithms. The model needs to implement targeting logic on a grid map and make all units execute it continuously. This tests algorithm modeling ability.
Requirement 4: Control-related features. These include an adjustable speed slider from 1x to 10x, a hexagonal grid map, keyboard arrow-key control for moving the viewport, and unit and city presentation using icons such as emoji or system character icons. These requirements are miscellaneous but concrete, testing completeness of instruction coverage—missing any one of them indicates a weakness in instruction following.
3.2 How to Organize the Prompt
A suggested prompt structure for this type of complex task is:
Task: Implement a web-based strategy game in a single HTML file.Base requirements:- Hexagonal grid map with viewport movement support.- Cities and units distinguished by emoji icons.Modification requirements:1. Real time: The main game loop runs continuously, with no turn confirmation.2. AI assistant: A selectable toggle that automatically completes research when resources are sufficient.3. Automatic enemy seeking: Units periodically search for the nearest enemy unit or city and attack.4. Control panel: Speed slider (1x–10x), arrow-key viewport panning.Acceptance criteria:- Each requirement can be verified independently and must not be omitted.
Structured, verifiable prompts can raise the quality of model output by a level and also provide a unified scoring basis for later comparative evaluation.
Four Recommendations for Building Your Own Evaluation System
- Use a fixed test set: Prepare three to five fixed tasks with increasing difficulty, covering dimensions such as visual reproduction, game logic, and algorithm implementation. When a new model is released, you can immediately run scoring and comparison.
- Score quantitatively: Break requirements into item-by-item checklists and score each as “implemented / partially implemented / not implemented” to avoid vague evaluations based on “feels good.”
- Track iteration stability: Generate multiple times with the same prompt and observe the variance. Models with high variance are harder to rely on in engineering.
- Separate the reasoning stage from the hosting environment: Slow response does not necessarily mean a model capability problem; it may be a service load issue. Evaluation should record speed and quality as two separate metrics. If stable production access is required, consider deploying and testing through a mainstream cloud platform’s model service, such as the model inference service on Baidu AI Cloud, to obtain more controllable concurrency and monitoring capabilities.
Conclusion
The gap in large-model coding capability is often not about “whether it can write something,” but about “whether it can write it correctly, completely, and well in one pass.” The realistic desktop web page and the real-time strategy game are essentially comprehensive stress tests of a model’s concept understanding, algorithm modeling, and instruction following. Once developers establish a repeatable method of “structured prompts + item-by-item acceptance + multiple rounds of iteration,” they can quickly make objective judgments whenever a new model is released, rather than relying on vendor marketing or scattered impressions.
