Evaluating LLM Selection: From Capability Testing to Cost and Risk
Selecting the right Large Language Model (LLM) for your business requires more than relying on vendor demos or public benchmarks. This article provides a comprehensive framework for evaluating LLMs, covering how to define business scenarios, test logical reasoning and code generation capabilities, handle long context and specific linguistic nuances, and assess cloud deployment risks. It also includes a practical scorecard and common pitfalls to help engineering teams match model capabilities with business needs while maintaining long-term control.
1. Define Business Scenarios Before Selection
The first step in model selection is clearly defining the problem you want to solve. A model that performs well in code review may not be suitable for contract summarization. Teams should list three to five core tasks—such as “reviewing Pull Requests for Python services,” “extracting financial metrics from hundred-page research reports,” or “answering product questions from a customer service knowledge base”—and then select evaluation dimensions based on these tasks.
It is recommended to record three pieces of information for each task: the typical input length, the required output format, and the acceptable types of errors. For example, a contract summarization task might tolerate minor wording variations but cannot omit breach of contract clauses. These constraints will directly determine subsequent weight settings.
2. How to Evaluate Logical Reasoning Capabilities
Logical reasoning capabilities must be tested through tasks; you cannot rely solely on the model’s self-description. Here is a reproducible approach.
How to build a test set? Prepare 300 to 500 samples per dimension, covering easy, medium, and hard difficulties. Samples should be sourced from real, desensitized business logs rather than solely from public datasets, as public questions may already exist in the model’s training data. Taking “troubleshooting database response latency” as an example, test samples can include different root causes like slow queries, connection pool exhaustion, and disk I/O saturation, requiring the model to provide troubleshooting steps and conclusions.
How to score? Use three categories of metrics. First is the task completion rate, i.e., the percentage of samples with correct output conclusions. Second is human evaluation, where two reviewers independently score from 1 to 5; in cases of significant disagreement, a third person arbitrates, and a consistency coefficient (such as Cohen’s kappa) is calculated. A low coefficient indicates that the scoring criteria need revision. Third is step rationality, checking whether the model skipped critical troubleshooting items.
How to record cost and latency? Record the input and output token counts, time to first token, and overall response time for each task, and calculate P50 and P95 percentile values. Looking only at averages will mask long-tail issues, which are often the primary source of user complaints.
Failure cases and application boundaries. Separately compile failed samples and label the failure types, such as “factual error,” “missing premise,” or “format mismatch.” This list illustrates where the model is unreliable and serves as the basis for designing fallback processes.
3. How to Evaluate Code Generation and Refactoring Capabilities
Code capability evaluations should be runnable. The following example demonstrates how to verify an optimization solution provided by a model: the original version uses a double loop, and the model suggests using a hash set.
# Environment: Python 3.11, no third-party dependencies# Purpose: Verify if the results of the model's refactoring solution are consistent and compare performancedef find_duplicates(arr):"""Original version: Double loop, time complexity O(n^2)."""duplicates = []for i in range(len(arr)):for j in range(i + 1, len(arr)):if arr[i] == arr[j] and arr[i] not in duplicates:duplicates.append(arr[i])return duplicatesdef find_duplicates_optimized(arr):"""Hash set version: Average time complexity O(n), extra space O(n)."""seen = set()duplicates = set()for item in arr:if item in seen:duplicates.add(item)else:seen.add(item)return duplicates# Input and output samplessample = [1, 2, 3, 2, 4, 1, 5, 1]print(sorted(find_duplicates(sample))) # Output [1, 2]print(sorted(find_duplicates_optimized(sample))) # Output [1, 2]# Random test: Results of both versions must be consistentimport randomfor _ in range(200):data = [random.randint(0, 50) for _ in range(random.randint(0, 80))]assert sorted(find_duplicates(data)) == sorted(find_duplicates_optimized(data))print("Random test passed")# Performance comparison: Results vary by machine, re-test in target environmentimport timeitdata = [random.randint(0, 10**4) for _ in range(3000)]t1 = timeit.timeit(lambda: find_duplicates(data), number=3)t2 = timeit.timeit(lambda: find_duplicates_optimized(data), number=3)print(f"Original version {t1:.3f}s, Optimized version {t2:.3f}s")
When verifying, note two things. First, the optimized version returns a set, and the order of results is not fixed; comparisons should be sorted or use set comparisons. Second, if the model provides a solution that only improves speed but changes the semantics—for example, mistakenly changing “duplicate elements” to “seen elements”—the tests must be able to catch such errors. Therefore, code evaluation should include both correctness assertions and performance measurements.
4. Testing Chinese Context and Long Texts
The difficulty of Chinese scenarios lies in polysemy, omitted subjects, colloquial expressions, and professional writing styles. Test samples should be grouped by scenario; common groupings include colloquial QA, official document rewriting, legal clause extraction, and financial report summarization.
Sample sources. Colloquial samples can be taken from desensitized customer service dialogues, official document samples can be provided by business departments using historical materials, and legal and financial samples require annotation by legal or analyst teams. Avoid using only examples provided by the model developer.
Scoring criteria. For extraction tasks, calculate the recall and precision of key information—for example, whether payment terms, penalty rates, and jurisdictional courts in a contract are correctly extracted. For summarization tasks, business personnel score based on “whether core conclusions are covered” and “whether information not in the original text is introduced.” For rewriting tasks, check whether terminology is consistent and whether the format meets official document or standard requirements.
Long text testing. Tests should cover different lengths, such as 5,000 characters, 30,000 characters, and inputs near the model’s context limit. A common issue with long texts is that key information located in the middle of the document is ignored; therefore, key clauses should be placed in the middle for specialized testing. Record the inflection point where accuracy drops as input length increases—this inflection point is more informative than the nominal context window length.
5. Cloud Deployment Considerations
The computing cost, deployment method, and existing IT architecture of a model are closely related. Enterprises typically choose container services, object storage, and message queues provided by mainstream cloud platforms because these services are mature, replaceable, and have complete operations and maintenance toolchains.
Elastic scaling. Inference services can auto-scale GPU nodes based on request volume. Pay attention to cold start times, which affect first responses during peak periods. Scaling thresholds should be set based on P95 latency, not average CPU utilization.
Data storage and asynchronous tasks. Fine-tuning corpora and RAG knowledge bases can be placed in object storage with lifecycle policies set. Data preprocessing and training tasks are scheduled via message queues; failed tasks require retry and dead-letter queues to prevent data loss.
Security and compliance. Data security cannot rely on a single measure, nor can absolute security be guaranteed. A more prudent approach is: first classify data, distinguishing between public, internal, sensitive, and regulated data; process sensitive data under encryption, access control, auditing, and network isolation, and assess whether cross-border transmission is involved; keys should be kept by a dedicated Key Management Service (KMS) and never written into code or logs; logs should be desensitized before writing to avoid storing complete user privacy content. Compliance assessments should involve legal and security teams and be completed before launch.
Observability. Perform full-chain tracing on the model invocation chain, recording request duration, token consumption, error codes, and model versions. When hallucinations or non-compliant outputs occur, this allows you to pinpoint whether the issue is with the prompt, retrieval results, or the model itself.
Fallback processes. Model outputs may be incorrect; business systems should design human review or degradation mechanisms. For example, outputs involving monetary amounts, legal clauses, or medical advice must be confirmed by a human before taking effect.
6. Selection Scorecard
The table below provides an adjustable scoring template. Weights should be modified according to the business scenario, and each dimension is scored from 1 to 5, then weighted to obtain a total score.
| Evaluation Dimension | Weight | Evaluation Method | Scoring Criteria |
|---|---|---|---|
| Logical Reasoning | 20% | Complex task test set, completion rate, and human evaluation | Conclusion accuracy, step completeness |
| Code Generation and Refactoring | 20% | Runnable unit tests and performance comparison | Pass rate, semantic consistency, complexity improvement |
| Chinese Long Text Processing | 20% | Extraction and summarization samples, key information recall rate | Core clause recall, no out-of-text information |
| Context Length | 10% | Accuracy curve across different input lengths | Inflection point position, retention of middle information |
| Concurrency and Latency | 10% | Stress test recording P50 and P95 latency | Whether peak latency meets business requirements |
| Service Level Agreement (SLA) | 10% | Review contracts and historical availability data | Availability commitment, failure compensation, and response time |
| Unit Price and Total Cost | 5% | Calculate per-task cost based on typical tasks | Includes input/output tokens, storage, and network fees |
| Security and Compliance | 5% | Data processing terms, audit, and certification materials | Data classification support, log desensitization, retention policy |
How to use: Run each candidate model on the same test set, score by dimension, multiply by weights, and sum. If two models have close total scores, you should prioritize comparing the severity of failure cases rather than just looking at the total score difference.
7. Common Mistakes and Risk Warnings
The first common mistake is substituting a single benchmark or vendor demo for business testing. Public benchmarks reflect general capabilities, while business data distributions and task requirements may be entirely different.
The second common mistake is only testing successful samples. You should specifically collect failure cases and track the occurrence rate and impact scope of each failure type.
The third common mistake is ignoring version changes. Model suppliers may update underlying models, causing outputs from the same interface to change. Model version numbers should be recorded, and the test set should be re-run after version updates.
The fourth risk is using model outputs directly for decision-making. Models may generate seemingly reasonable but incorrect content. In high-risk scenarios involving money, legal, or medical matters, a human review step must be retained.
The fifth risk is data leakage. Before launch, confirm whether input data will be used for model training, and explicitly specify data retention periods and deletion methods in the contract.
8. Summary of Selection Steps
- List core business tasks, and specify the input length, output format, and acceptable error types for each task.
- Build test sets for each dimension, covering different difficulties and real samples, and record completion rate, human evaluation score, latency, and cost.
- Use the scorecard to calculate the weighted total score, while compiling failure cases to clarify the application boundaries of each model.
- Conduct stress tests in the target cloud environment to ensure that elastic scaling, data storage, and monitoring alerts meet requirements.
- Continuously track real business metrics post-launch, re-run the test set upon version updates, and adjust prompts, retrieval strategies, or model selection based on the results.
There is no one-size-fits-all answer to model selection. A repeatable evaluation process, combined with clear risk boundaries, is the only way to match model capabilities with business needs and maintain control over the long term.
