Evaluating and Deploying Large Language Models for Complex Engineering Generation Tasks
This article discusses how to evaluate large language models (LLMs) for complex engineering code generation tasks, where conventional tests fall short. It outlines design principles for evaluation tasks, a metric system covering quality, reliability, and cost, a four-step testing workflow with automation examples, common pitfalls in result interpretation, and practical recommendations for engineering deployment.
Why Conventional Tests Fail to Differentiate Models
Many teams evaluate LLMs using poetry creation, everyday conversation, and classic logic puzzles. These prompts are short, have few constraints, and mainstream models tend to produce acceptable answers, so test results rarely reflect true engineering capability.
What truly impacts development efficiency are the following abilities:
- Understanding complex constraints and maintaining consistency across multiple rounds of modifications.
- Generating long, well-structured code with correct syntax and dependency relationships.
- Producing artifacts that can run directly and support user interaction.
- Completing tasks within acceptable time and cost.
Therefore, evaluation tasks should mirror real development scenarios, and results should be verifiable on an item-by-item basis.
Design Principles for Evaluation Tasks
2.1 Use Deliverable Artifacts as the Endpoint
The output of an evaluation task should be a complete, runnable deliverable—for example, a single-file web application. After opening the page, testers can check each feature. Responses that only output code snippets or pseudocode are not counted as valid results.
2.2 Include Multi-Round Iteration
Real requirements are rarely finalized in one pass. During evaluation, start with a two-dimensional version of a requirement, then after the model outputs, issue an additional modification instruction—for instance, converting it to a three-dimensional form. This step tests three capabilities:
- Whether the model can accurately read the previous round’s code and business logic.
- Whether the model can make structural changes without breaking existing functionality.
- Whether the model can independently add the dependencies and resources required for the new form, such as lighting, camera, and model loading for a 3D scene.
2.3 Choose Structurally Complex Problems
Structurally complex objects expose problems more easily. Taking a multi-cylinder internal combustion engine visualization as an example, typical requirements include:
- Correct number and positional relationships of components (crankshaft, connecting rods, pistons, valves, etc.).
- Kinematic linkage between moving parts that follows mechanical principles.
- Support for interactive operations such as disassembly, cutaway view, and reset.
- Clear labeling on the interface for readability.
Each requirement in the prompt can be converted into a checklist, facilitating item-by-item scoring.
2.4 Example Prompt Structure
[Task Objective] Generate a single-file web application that demonstrates the motion principle of a multi-cylinder internal combustion engine.[Round 1 Requirement] A 2D schematic with crankshaft, connecting rods, pistons, and valve mechanism, with labeled parts in Chinese.[Round 2 Requirement] Convert to a 3D interactive form while retaining all functionality from Round 1.[Delivery Constraint] Single file, no build step, open and run directly.[Interaction Requirement] Support disassembly, cutaway view, and reset.
Metrics System
Evaluation metrics should cover result quality, runtime reliability, and resource consumption.
| Dimension | Metric | Description |
|---|---|---|
| Task Completion | Requirement Coverage | Score item by item based on the checklist; compute the percentage of passed items |
| Runtime Correctness | Loadability, No-Error Rate | Whether the page opens and whether the console logs unhandled exceptions |
| Interaction Usability | Feature Usability Rate | Whether each interactive control produces the expected effect |
| Timeliness | End-to-End Latency | Wall-clock time from request submission to complete artifact generation |
| Cost | Output Token Count | Count visible output and reasoning-related tokens separately |
| Stability | Truncation Rate, Failure Rate | Whether the process stops due to length limits or fails midway |
| Consistency | Variance Across Runs | Fluctuation of results when the same task is run multiple times |
Latency and token consumption should be interpreted together with quality metrics. Looking at any single metric in isolation can lead to biased conclusions.
Test Workflow and Automation Example
The complete workflow has four steps: unified input, parallel execution, result collection, and manual/automated review.
4.1 Unified Input
The same task must be sent to all tested models with identical text and parameters, including output length limits and temperature settings. Record the version information and timestamp of each request before testing to enable reproduction later.
4.2 Collect Execution Data
The example below shows a basic structure for collecting latency, output tokens, and finish reason. The client interface is illustrative; replace it with your team’s actual calling method.
import timefrom dataclasses import dataclass@dataclassclass CaseResult:model_id: strelapsed_s: floatoutput_tokens: intfinish_reason: strartifact: str # generated single-file web source codedef run_case(client, model_id: str, prompt: str, max_output_tokens: int) -> CaseResult:start = time.perf_counter()resp = client.generate(model=model_id,prompt=prompt,max_tokens=max_output_tokens,)elapsed = time.perf_counter() - startreturn CaseResult(model_id=model_id,elapsed_s=round(elapsed, 2),output_tokens=resp.usage.output_tokens,finish_reason=resp.finish_reason,artifact=resp.text,)def is_truncated(result: CaseResult) -> bool:# Finishing due to length limit indicates the artifact may be incompletereturn result.finish_reason == "length"
Record finish_reason during collection. If the result is truncated by length, treat it as incomplete even if partial code exists, and list it separately in the report.
4.3 Reviewing the Artifact
Review operates on two levels:
- Automated smoke test: Use a headless browser to load the page, check console errors and key elements, and take screenshots.
- Manual interaction test: Follow the checklist and operate each feature, recording the actual behavior.
Screenshot comparison is useful for verifying 3D scene rendering but cannot replace interaction testing.
Common Pitfalls in Result Interpretation
5.1 Longer Latency Does Not Equal Higher Capability
Latency can be affected by queueing, network fluctuation, or internal reasoning processes. Test multiple times at different intervals, use the median, and present latency alongside quality scores in the same table.
5.2 More Output Tokens Do Not Mean More Useful Content
Some models generate a large amount of intermediate reasoning. Those tokens count toward cost but do not appear in the final artifact. When measuring cost, separate reasoning-related tokens from visible output; otherwise, you may over- or under-estimate the actual cost of generated code.
5.3 Page Load Does Not Guarantee Complete Functionality
Even if the page loads successfully, each interactive control must still be checked. Common issues include buttons not responding, wrong toggle states, or 3D models showing only some parts.
5.4 Error Messages May Mask the Real State
Poorly designed fallback logic in generated code may display an error message such as “resource loading failed” even after successful rendering, causing misinterpretation. Testers should verify the conditions that trigger such messages and confirm that the message matches the rendering state. This issue also reminds developers to separate resource loading state from rendering state in the frontend, and to update or hide messages as state changes.
5.5 Single Runs Are Random
Running the same task multiple times can produce significantly different results. Key conclusions should be based on statistical analysis of multiple runs, not a single attempt.
Engineering Deployment Recommendations
- Layer model selection by scenario: Quick drafts, careful deliveries, and long-text processing have different requirements. Build separate evaluation benchmarks for each scenario rather than relying on a single ranking for all cases.
- Add truncation detection in the call chain: Centralize the check of finish reasons. When truncation is detected, automatically retry or switch to a larger output limit.
- Run static checks on generated code: Perform syntax checks and basic smoke tests before delivery to reduce invalid artifacts flowing into downstream processes.
- Build a team-specific evaluation question set: Questions should cover the business patterns that your team commonly encounters, and historical results should be retained for comparison after model version updates.
- Re-test periodically: Model versions change frequently, so previous conclusions may become outdated. Re-run the evaluation set on a fixed schedule.
Summary
To evaluate the engineering capability of large language models, the key is to design tasks that closely resemble real development work, measure artifact quality, runtime reliability, and resource cost with verifiable metrics, and reduce the influence of randomness through multiple runs and layered review. Once the testing framework is in place, teams can accumulate data continuously, allowing model selection and scenario adaptation to be built on reproducible evidence.
