Model Selection for LLM-Based Engineering: Once Quality Is Met, Compare Cost per Accepted Deliverable

    When multiple large language models can complete an engineering task to an acceptable standard, the key selection metric is not the price of a single call. It is the cost of producing an accepted deliverable, including failed attempts, retries, and—when relevant—engineer remediation time. This article uses BIOS porting as an example and explains how to build an evaluation set, calculate unit delivery cost, and reduce spending through routing, prompt compression, and cache reuse.

    1. Experimental Results and Cost Scope

    In a BIOS porting experiment, two mainstream large language models worked in parallel on the same task. The acceptance criteria were clear: after compilation and packaging, the generated code had to produce a firmware image that could be flashed directly to the target device. Both models passed acceptance. Their code quality, logical correctness, and handling of edge cases were broadly comparable.

    The difference appeared in the bill. One model cost approximately RMB 6.5, while the other cost about RMB 150—a gap of roughly 23 times.

    These figures indicate only the order of magnitude observed in one experiment. The original records did not specify the model versions, task size, number of calls, token usage, or pricing date, so the result should not be treated as a general conclusion. Model prices change, and the code volume and context length of different firmware projects can vary significantly. Teams should repeat the measurement with their own data rather than copy this ratio.

    The experiment is still useful as a decision-making example. Once two models have both crossed the threshold of “can complete the task,” the key question becomes: how much does it cost to produce an acceptable result?

    2. Designing the Evaluation Tasks

    BIOS porting is a suitable evaluation scenario for four main reasons:

    1. The acceptance criteria are objective. Whether an image compiles, can be flashed, and boots does not depend primarily on subjective scoring.
    2. The task requires multi-file context. The model must understand the existing code structure, chip documentation conventions, and register configuration.
    3. The tolerance for errors is low. An incorrect register address or initialization order can make the firmware image unusable.
    4. The task reflects real production work. The evaluation results can be applied directly to model selection.

    When building an evaluation set, consider the following process:

    1. Select 10 to 30 completed porting tasks from the team’s historical projects, covering different chips and modules.
    2. Store a reference image or key register configurations for each task as a basis for comparison.
    3. Create automated acceptance scripts that perform compilation, linking, and packaging; verify image size and partition layout; and validate startup on hardware or a simulator.
    4. Run each task with every model at least three times to observe result variability.
    5. Record the cost and outcome of every call using fields such as those below.
    Field Description
    Task ID Corresponds to a task in the evaluation set
    Model and version Includes the model name and version
    Call date Used to trace the pricing basis
    Input, output, and cached tokens Recorded separately according to the billing rules
    Number of calls and retries Includes regeneration after failures
    Total cost Calculated using the prices in effect at the time
    Acceptance result Pass or fail, with the failure type specified
    Manual remediation time Used to calculate the complete cost

    Failure criteria should be defined in advance. Common failure types include compilation errors, startup failures, incorrect register configuration, and unnecessary changes to unrelated code. These categories should be tracked separately because their remediation costs can differ substantially.

    3. Quantifying Quality and Cost: Unit Delivery Cost

    Neither the price of an individual call nor the total bill is sufficient for model selection. A more useful primary metric is unit delivery cost:

    Unit delivery cost = Total cost, including failures and retries ÷ Number of accepted deliverables

    If engineering effort is included, use the broader metric:

    Fully loaded unit delivery cost = (Total model cost + Manual remediation cost) ÷ Number of accepted deliverables

    This formula has two important characteristics:

    1. The denominator includes only deliverables that pass acceptance. Failed outputs must not be counted.
    2. The numerator includes failed calls and retries. Otherwise, a low-cost model with a low pass rate may appear cheaper than it really is.

    The following hypothetical figures illustrate the calculation. They are not taken from the experiment described earlier.

    • Model A costs RMB 100 in total and passes 10 tasks, producing a unit delivery cost of RMB 10.
    • Model B costs RMB 300 in total and passes 28 tasks, producing a unit delivery cost of approximately RMB 10.7.

    The costs are close, but Model B has a higher pass rate and may shorten the delivery cycle. Manual remediation time should be considered before making a final decision.

    Two boundaries are important when using this metric. If the two models have similar pass rates, their unit delivery costs can be compared directly. If their pass rates differ substantially, manual remediation cost should be included in the fully loaded metric; otherwise, the result may be misleading.

    4. Cost-Reduction Practices

    Cost-reduction measures generally fall into three categories. Each has specific limits and should be validated against the team’s own workload.

    1. Tiered Routing

    Classify tasks by complexity. Simple tasks, such as formatting changes, comment updates, and documentation generation, can be assigned to a lower-cost model. Cross-file tasks involving interrupts or register configuration should be assigned to a more capable model. If the lower-cost model fails, the task can be automatically escalated to the higher-capability model.

    Before deploying routing rules, validate them through historical task replay. Poorly designed rules may increase the number of retries and raise the total cost instead of reducing it.

    2. Prompt Compression

    Send only the source and header files relevant to the task and remove duplicate context. Organize key sections of chip documentation into structured reference notes instead of providing the full manual. Require the model to use a fixed output structure to reduce unnecessary explanations.

    Compression must not remove critical information, such as register constraints or initialization order. After compressing the prompt, rerun the acceptance scripts to confirm that the pass rate has not declined.

    3. Cache Reuse

    Fixed system prompts and shared reference documents are suitable for placement in a cacheable prefix so they can be reused across repeated calls. Results for identical subtasks may also be cached.

    Before using caching, confirm the provider’s cache validity period and billing rules. When reference documentation is updated, cached content may become outdated. Reference documents should therefore include version numbers, and each cache should be associated with the relevant document version.

    The actual savings from these measures depend on task structure and the provider’s billing rules. A specific savings percentage should not be promised in advance. Validate each measure independently and observe its effect on unit delivery cost.

    5. Risks and Boundaries

    First, cost data changes with model versions, pricing strategies, and task types. Applying the cost gap from the earlier experiment directly to other firmware projects may lead to an invalid conclusion.

    Second, benchmark scores have limited correlation with engineering deliverables. Model selection should be based on the team’s own evaluation set.

    Third, firmware source code and keys are sensitive assets. Before sending code to an external model API, complete the required security review and apply data sanitization according to company policy. The provider’s data-retention policy should also be reviewed on a case-by-case basis.

    Fourth, passing compilation and startup validation does not prove that the code is safe under every hardware state. Code involving power management, secure boot, or storage writes still requires manual review and hardware testing.

    6. Conclusion and Checklist

    The selection process should establish the quality threshold first and compare costs second. Once a model meets the required quality threshold, unit delivery cost—not the price of an individual call—should guide the decision.

    Use the following checklist to review the evaluation and selection process:

    • The task set covers the main chips and modules and includes reference images or key configurations.
    • Acceptance scripts run automatically and produce traceable results.
    • Each model is tested at least three times, with the range of results recorded.
    • The cost scope includes failed calls, retries, and manual remediation.
    • Unit delivery cost is calculated using the stated formula and compared alongside pass rate.
    • Tiered routing rules are validated through historical task replay.
    • Acceptance is rerun after prompt compression to confirm that the pass rate has not declined.
    • Cached content is linked to a specific reference-document version, and the provider’s caching rules are confirmed.
    • Security approval and data sanitization are completed before code is sent externally.

    When these items have been completed, a team can use its own data to reach a verifiable model-selection decision and control model spending without reducing delivery quality.