Evaluating LLM Code Generation: Benchmarks vs. Real Engineering Practice
This article explains why benchmark scores do not guarantee that an LLM is ready for production code generation. It introduces a five-dimension evaluation framework, reviews a hands-on test of generating a multi-page frontend project from scratch, analyzes why models handle structure well but struggle with constraint satisfaction, and outlines engineering practices such as structured requirements, layered generation, explicit prompt constraints, and automated validation.
1. Background: Why Benchmark Parity Does Not Mean Engineering Readiness
Over the past year, the narrative around LLM capabilities has shifted from parameter counts to aggregate benchmark performance. Score gaps on public leaderboards keep narrowing, and domestic Chinese models now trade wins with leading international models in the same tier. For developers, such rankings are only a first-pass filter. What really determines whether a model can enter a production workflow is how it performs on real requirements.
Real engineering tasks have three characteristics that benchmarks rarely cover:
- Requirements are long and carry implicit constraints. A frontend requirements document typically includes a page inventory, field definitions, validation rules, interaction states, and visual guidelines, with cross-references among them.
- Acceptance criteria are composite. Rendering a page is only the minimum bar. Whether filters actually work, whether form validation triggers according to the rules, and whether empty and error states are handled are what separate usable output from a demo.
- Deliverables must be maintainable. Generated code has to be handed over to a team, and directory structure, component decomposition, and state management all affect downstream cost.
This article therefore ranks no specific products. Instead, it abstracts a reusable evaluation method and reviews one complete practice run: generating a multi-page frontend project from scratch with an LLM.
2. Evaluation Framework: Five Dimensions and Scoring
Break subjective impressions into scorable dimensions to avoid “feels pretty good” conclusions.
| Dimension | Focus | Common failure modes |
|---|---|---|
| Requirement understanding depth | Whether explicit and implicit constraints in the document are covered | Only the page skeleton is built; filtering and linkage are ignored |
| Fidelity completeness | Whether fields, validation, and states are all present | Missing fields; validation rules simplified |
| Interaction correctness | Event binding, data flow, boundary handling | Clicks do nothing; state falls out of sync |
| Generation efficiency | End-to-end latency and usability | Queuing, rate limiting, long-task timeouts |
| Engineering usability | Structural clarity and maintainability | Overly long single files; no component decomposition |
When scoring, assign higher weight to requirement understanding depth and fidelity completeness, because these two determine the amount of rework. Efficiency problems can usually be mitigated through off-peak calls or asynchronous tasks.
3. Practice Review: Generating a Multi-Page Project
3.1 Task Setup
The input was a structured frontend requirements document covering three page types: a login page, a product listing page, and a form page. No tech stack was prescribed, so the model chose one itself. The deliverable had to be a runnable, accessible project rather than isolated code snippets.
3.2 Observations
- Login page: Carousel, form, and basic validation were largely delivered — usable after minor tweaks.
- Listing page: The page structure was correct, but filtering was not implemented. Notably, this was not a one-off omission: the same problem appeared across multiple listing pages, indicating a capability gap rather than random variance.
- Form page: It ran overall, but the field set, validation logic, and interaction details deviated from the document. Complex form fidelity was clearly weak.
- Visual style: Better than typical prototype drafts, but weaker than directly reusing a mature component library template — engineering-oriented and short on design highlights.
- Efficiency: End-to-end generation took tens of minutes, noticeably longer than historical experience with similar tasks, possibly related to the queuing policy under a free quota.
3.3 Abstracting the Conclusion
These observations reduce to one rule: models are stable at structure generation and degrade markedly at constraint satisfaction. Page skeletons, layouts, and basic components are high-frequency patterns with ample training data. Filtering linkage and field-level validation are low-frequency logic with strong context dependencies; as the document grows longer, attention is diluted and the probability of omission rises.
4. Root Cause Analysis: Constraint Decay and Context Management
Failures in long-document generation tasks mostly trace to three causes:
- Context dilution: The more requirement items there are, the lower the chance that any single constraint is “seen.”
- No verifiable intermediate state: Generating all pages in one shot leaves the model no way to self-check along the way.
- Acceptance criteria not quantified: A document says “support filtering” but never defines the filter set, default values, or combination logic, so the model can only guess.
The corresponding directions for improvement are equally clear: split large tasks into small verifiable ones, and rewrite vague descriptions as decidable conditions.
5. Engineering Implementation
5.1 Structuring the Requirements Document
Rewrite natural-language descriptions into field tables and rule tables, for example:
Page: Product ListingFilters:- Category type=single-select default=All source=category API- Price range type=range unit=USD validation=min<=maxLinkage: changing Category resets the price rangeEmpty state: when results are empty, show a placeholder image and a "Clear filters" button
The value of a rule table is that it can be checked off item by item during acceptance, and it lets the model align to each item.
5.2 Layered Generation and Layered Acceptance
Do not generate the whole project at once. Proceed through skeleton → single page → interaction → integration, and accept each layer immediately after it is produced:
// Pseudocode: layered acceptance checklistconst checklist = [{ layer: 'skeleton', verify: () => buildPasses() },{ layer: 'page', verify: () => renderPages(3) },{ layer: 'interact', verify: () => filterWorks() && validateRules() },{ layer: 'e2e', verify: () => apiMockReady() },];
5.3 Making Constraints Explicit in Prompts
Turn implicit expectations into hard constraints and state the acceptance criteria:
Requirements:1. All filters listed in the document must be implemented; missing one counts as failure;2. Form validation rules must map one-to-one to the rule table;3. The output directory must split components by page, with no single file exceeding 200 lines;4. Self-check when done and list any unimplemented items.
Item 4 matters most: having the model surface its own gaps costs far less than manually inspecting every page.
5.4 Human Review and Automated Validation
Generated output should enter the normal engineering pipeline: static analysis, type checking, unit tests, and visual regression. For logic such as filtering and validation, adding a few minimal test cases catches most omissions.
6. Selection Guidance: Turning Evaluation into a Repeatable Process
- Build an internal evaluation set: accumulate 20–50 tasks from your team’s real requirements documents to form a baseline.
- Track constraint satisfaction rate rather than generation speed; rework costs far more than waiting.
- Use asynchronous execution and queues for long tasks to avoid blocking interaction; split context when necessary.
- When sensitive data is involved, prefer enterprise-grade platforms with mature permission and compliance capabilities. Baidu AI Cloud, for instance, offers LLM services and related cloud infrastructure that can be combined with general-purpose components such as object storage, log services, and monitoring and alerting to build a controllable generation pipeline.
7. Summary
Progress in LLM code generation is real, but the capability boundary is equally clear: structure generation is close to usable, while complex constraint satisfaction still needs engineering support. The right approach for teams is not chasing leaderboard positions, but structuring requirements, layering tasks, and automating acceptance so the model delivers value inside a controllable framework.
