Evaluating LLM Code Generation: A Six-Dimension Assessment Model and Engineering Practices
Large language models can now generate a complete project from a single-sentence prompt in minutes. But measuring whether that generated code is actually correct—and turning it into something you can ship in production—requires a disciplined evaluation approach. This article lays out a six-dimension scoring model, shows how to turn vague requirements into machine-checkable contracts, explains how to verify behavior with automated assertions instead of eyeballing, and covers the engineering practices needed to make code generation controllable end to end. You'll come away with a concrete framework for scoring models, diagnosing where they fail, and composing a pragmatic, task-tiered strategy.
1. Why “It Runs” Doesn’t Mean “It’s Correct”
Generating a complete project from a single sentence is no longer hard. Hand a model a login page, a list page, and a form page, wrap it around a common component library, add some sample data, and within minutes you have a demo site you can click through and navigate. But the moment you move into a real delivery context, there’s a wide gap between “it runs” and “it’s right.”
The nature of that gap is this: the correctness of generated code depends on how faithfully the model restores the requirement constraints, not on how faithfully it reproduces the page’s appearance. Constraints in a spec fall into roughly three layers—structural (which pages and blocks exist), data (fields, types, enums, relationships), and behavioral (linkage, validation, conditional visibility, exception states). Models usually restore the structural layer reliably, because that’s the most common form in training data. The further you go toward the behavioral layer, the more the constraints depend on implicit reasoning, and the faster restoration degrades.
In practice, I see three recurring misconceptions:
- Judging only by visual polish. A clean screenshot with sensible spacing gets scored as high quality. But visuals are template-driven and can be filled in quickly from a component library, whereas behavioral logic can’t hide behind a template.
- Testing only a single page. A single-page test forces all of the model’s attention onto one page and masks its weakness at cross-page reuse. In real projects, cross-cutting capabilities—filters, pagination, status messages—have to stay consistent across many list pages, and that’s exactly where the weakest points surface first.
- Checking only whether it boots. A successful startup only confirms that syntax and dependency wiring are correct; it says nothing about field mapping, validation rules, or edge-case handling. An evaluation without assertions is no evaluation at all.
The conclusion: evaluation must be scenario-based, reproducible, and quantifiable. A gut-feel verdict like “roughly on par with some international standard” offers no value for engineering decisions.
2. A Six-Dimension Evaluation Model: Turning Gut Feel into Numbers
To compare different models, versions, and prompts, the first step is to break “feel” into weighted dimensions. This scoring sheet works well in practice, and the weights can be adjusted to your business priorities:
| Dimension | Focus | Suggested Weight | Typical Deductions |
|---|---|---|---|
| Requirement coverage | Are all pages/blocks/entry points in the spec present? | 20% | Carousels, empty states, and loading states silently omitted |
| Feature restoration | Are filtering, pagination, search, and linkage implemented? | 25% | Static filter options rendered but clicks do nothing |
| Data consistency | Field names, types, enums, required flags, relationships | 20% | Fields “guessed” and inconsistent with the spec |
| Validation & edges | Required, format, length, uniqueness, async validation | 15% | Front-end-only prompts with no state reset |
| Engineering quality | Component decomposition, type annotations, naming, maintainability | 10% | Oversized single files, implicit any, coupled logic |
| Delivery efficiency | Time to first usable output, task success rate, retry cost | 10% | Queuing failures, long-task timeouts, multiple reruns |
The recommended way to record scores is a structured record that supports side-by-side comparison and version regression:
{"task_id": "list-page-with-filter-v3","model_version": "candidate-A","spec_version": "2026-08-20","scores": {"requirement_coverage": 0.85,"feature_restoration": 0.55,"data_consistency": 0.70,"validation_edge": 0.45,"engineering_quality": 0.65,"delivery_efficiency": 0.40},"weighted_score": 0.64,"failures": ["Filter region rendered but clicking produces no filtering effect","3 form fields missing the format validation required by the spec"]}
The key is the failures field. Scores are only for tracking trends; the failure list is what actually drives improvement. It tells you which constraints your prompt is missing, and which stages must keep a human review in the loop.
3. Input Side: Upgrade a “One-Sentence Requirement” into an Executable Contract
Many restoration problems actually stem from insufficient information on the input side. A doc that “feels clear” to a human and one a model can parse without ambiguity are two different things. The effective approach is to first produce a machine-checkable contract, then have the model generate code from that contract.
Take a list-page filter as an example—convert the natural-language description into a structured definition:
{"page": "product_list","filters": [{ "field": "category", "type": "enum", "multiple": false, "clearable": true },{ "field": "priceRange", "type": "range", "unit": "CNY", "min": 0 },{ "field": "status", "type": "enum", "dependsOn": "category" }],"behaviors": {"filter_mode": "client_side","on_change": "reset_page_to_1","empty_state": "show_reset_action","url_sync": true},"pagination": { "page_size": 20, "show_total": true }}
Pair this with a field dictionary and validation-rules table (field name, type, required, length, format, error message, whether an async uniqueness check applies). Contracting the input yields three direct benefits: first, it removes ambiguity—the model doesn’t have to guess fields; second, evaluation gains a ground truth it can assert against directly; third, the contract itself is reusable, so switching models doesn’t mean rewriting requirements.
I also recommend layered delivery rather than dumping one long document at once: the first layer is global conventions (tech stack, directory structure, naming and styling conventions, an accessibility baseline), the second is the data contract (type definitions and the field dictionary), and the third is the single-page behavior description. Information in the middle of a long context tends to get “diluted,” so putting the most critical constraints last and explicitly asking the model to “implement point by point against them” is measurably more reliable than dropping the whole document in at once.
4. Verification Side: Replace Eyeballing with Assertions
For evaluation to be reproducible, it must be automated. The core idea is to let the contract double as the input to tests: derive a list of assertions from the contract, then run a real interaction pass with browser automation.
# Behavior assertions derived from the contract (pseudocode)assert page.has_region("filter_bar")for f in filters:assert page.has_control(f.field)select(filters[0], option_index=2)assert result_list.every(item => item[filters[0].field] == selected_value)assert pagination.current_page == 1 # on_change resets the page numberclear_filter(filters[0])assert result_list.length == total_unfiltered # restored after clearingassert page.url.contains("category=") # url_syncsubmit_form(invalid_payload)assert error_messages.count == 3 # required + format + length
Supporting engineering measures include static checks (type checking, lint rules), component-level snapshot comparison, and cross-page consistency checks (does the same filter component behave the same on different list pages?). With these three layers of validation stacked, a problem like “the filter isn’t actually implemented” surfaces within tens of seconds as a failing test case—no more manual page-by-page clicking.
5. Root-Cause Analysis: Why the Behavioral Layer Breaks Down Most
Looking at typical failure samples, the degradation concentrates in three places, each with a different cause.
First, weak awareness of reusing cross-cutting capabilities. Logic like filtering, pagination, empty states, and permission prompts is shared across pages, but models tend to implement it page by page in isolation. As the number of pages grows, this degrades into nothing more than a visual placeholder. This is tied to the abundance of single-page examples in training data and the scarcity of multi-page engineering structure. The remedy is to explicitly require extracting a shared layer first (composable logic, generic container components), then reusing it on each page.
Second, insufficient modeling of field relationships in complex forms. Form difficulty isn’t about having many fields; it’s about the dependencies between them: a change in A triggers recomputation of B’s enums, conditional visibility of C, and async uniqueness validation for D, plus overall state consistency at submit time. This kind of constraint is a state-transition relationship, not a pile of independent rules, so it’s inherently hard for a prompt that lists things one by one to cover fully. A workable mitigation is to describe the form as a state machine, put the transition table into the contract, and require the implementation to manage validation state centrally rather than scattering it across individual input controls.
Third, the visual layer stops at “engineering-usable.” The visual result is often clean but lacks a design language: no hierarchy of spacing and font sizes, insufficient color semantics, missing focus states and keyboard accessibility. This isn’t a matter of the model’s taste; it’s that design tokens weren’t provided as input. Injecting an explicit token list for color palette, spacing scale, corner radius, shadow, and breakpoints into the prompt markedly improves the consistency and completeness of the output.
As for delivery efficiency, long task durations and queuing or rate limiting during peak demand are common with shared inference services and are unrelated to model capability per se. Engineering-wise, treat it as an external dependency: set sensible timeouts and backoff retries, split large tasks into independently verifiable subtasks, cache results for identical contracts, and preserve the ability to resume after a failed or interrupted run.
6. Engineering Practices: Build Controllability into the Workflow
To get this kind of capability into a production workflow, the key isn’t which model you pick but four things:
- Contract first. The output of a requirements review is a checkable contract and assertion list, not a prose-style document. Get this right, and the floor of any model gets raised.
- Feedback loop. Generate → static check → automated test → feed failure messages back → regenerate, turning “a human noticed the filter is missing” into “a red test case triggers an automatic fix.” Multi-round iteration usually pays off far more than swapping models.
- Runtime robustness. Queuing, rate limiting, and timeouts need retry and fallback strategies; decouple generation tasks from business requests and execute them asynchronously, passing status through a message queue so long tasks don’t drag down the online path.
- Observability and compliance. Record each task’s prompt version, output version, assertion pass rate, and elapsed time, then track trends with logging and monitoring/alerting. At the same time, define data classification clearly, and desensitize sensitive data before it leaves your boundary or switch to a private deployment model—this is a hard threshold for enterprise adoption.
If you need to host this capability in the cloud, you’ll typically combine a few general-purpose building blocks: a model service to provide the inference entry point, a container platform to run generation tasks and test environments, object storage to hold outputs and snapshots, a message queue to decouple tasks, and logging plus monitoring/alerting to track both quality and stability. Baidu AI Cloud offers corresponding categories for these general-purpose capabilities, though the specific configuration should be assessed against your actual task volume and compliance requirements.
7. Conclusion
Discussions of the form “has some domestic model already caught up to some international leading model” are more usefully reframed with engineering value in mind: on which dimensions is it aligned, on which does a gap remain, and is that gap closed by the process? From what scenario testing consistently shows, structural-layer generation and simple pages like login are highly close across mainstream models. The gaps concentrate in reusing cross-page cross-cutting capabilities, modeling state and validation in complex forms, and the latency stability of long tasks—precisely the areas that can be substantially compensated on the engineering side through contract-driven input, automated assertions, and iterative feedback.
The pragmatic selection strategy is therefore to compose by task tier rather than betting on a single model: route simple pages and code completion through a lightweight, fast lane, route complex business logic through a strong-reasoning lane, and always keep assertion validation and human review for critical deliverables. Once evaluation shifts from “does it look right” to “do the assertions pass,” progress in model capability can be measured accurately and genuinely converted into deliverable productivity.
