An Evaluation Framework for LLM Selection: From Scenario Decomposition to Hands-On Testing
This article offers a practical framework for evaluating and selecting large language models (LLMs). It explains how to turn the open-ended question of “which model is best” into measurable evaluation criteria, decompose common workloads—including code generation, long-context analysis, multimodal input, agent tool-calling, high-concurrency services, and compliance-constrained deployment—and build small-scale test sets with real data. It also defines seven scoring dimensions, discusses architecture patterns such as task-based routing and fallback, and provides a selection checklist for making reproducible decisions.
From “Which Model Is Best?” to an Evaluable Question
Teams often ask which LLM is the best. The question is incomplete. Models differ in code comprehension, long-text analysis, multimodal input, response speed, and call cost—there is no single optimal solution for all scenarios.
A more practical approach is to answer three questions first: What task does the business need to accomplish, what defines success, and what constraints exist. Once these are answered, compare candidate models using the same set of metrics. The selection process can be split into four steps:
- Decompose business scenarios into concrete tasks.
- Define quantifiable metrics for each task category.
- Run small-scale tests with real data.
- Make decisions with budget, compliance, and engineering constraints in mind.
Decompose Typical Scenarios
Different scenarios place very different demands on model capabilities. The main focus areas are described below by category.
Code Generation and Engineering Comprehension
Code scenarios typically include function-level completion, business logic implementation, module design, code review, and defect localization. Evaluation should focus on:
- Whether generated code compiles and passes unit tests.
- Whether the model understands cross-file call relationships, rather than only handling a single function.
- How well it identifies implicit constraints in the requirements, such as concurrency safety, exception handling, and boundary conditions.
- How closely it follows existing code style and naming conventions.
Note that capability differences often appear in complex tasks; results for short or trivial code snippets rarely differ much. Therefore, the test set should include complex problems drawn from real engineering work.
Long-Context Processing
Long-context scenarios include analyzing multiple reports, reviewing lengthy documents, and summarizing meeting records over a long period. The context window size is only one parameter. What matters more is the model’s ability to locate information, maintain consistency, and reason across paragraphs within a long input.
A common practice is the needle-in-a-haystack test: place key information in different positions in a long text, then ask the model and check whether it answers accurately. If accuracy drops significantly when the information sits in the middle, the model has an attention distribution problem in long texts. In that case, retrieval or chunking strategies should be used.
Multimodal Input
Multimodal scenarios include screenshot understanding, design-to-code conversion, chart analysis, and scanned-document parsing. Traditional approaches usually require extracting content with text recognition tools before passing it to a language model, which adds steps and can introduce errors at each stage.
If a candidate model natively supports image and document input, preprocessing can be reduced. Evaluation should check the accuracy of layout reconstruction, the quality of table and formula recognition, and how faithfully spacing, color, and hierarchy in design files are reproduced.
Agent and Tool-Calling
Agent scenarios require the model to plan steps autonomously, call external tools, and process intermediate results. Key evaluation points include:
- Whether the chosen tool is correct and the parameter format is valid.
- Whether the model remembers previous results and stays aligned with the goal across multi-step tasks.
- Whether it can self-correct after an error instead of repeating the same mistake.
- How sharply the success rate drops as the task chain grows longer.
Failures in agent tasks typically appear after the third or fourth step. Therefore, the full trajectory should be recorded, rather than only the final success or failure.
High Concurrency and Low Latency
Customer-facing products are sensitive to response time. Relevant metrics include time-to-first-token (the interval from request to the first output token), output speed (tokens generated per second), and error rates and queue time under concurrent load.
Note that the token-to-character conversion ratio varies by tokenizer, so a fixed coefficient should not be used to estimate reading speed. Measure actual requests instead.
Data Compliance and Deployment
For scenarios involving confidential materials, user privacy data, or regulated industries, deployment often becomes a hard constraint before model capability is considered. Common options include:
- Public cloud API calls: fast to integrate, low maintenance, but data passes across the network.
- Managed services within a private cloud or private network: balances compliance and elasticity.
- On-premises deployment: data stays fully internal, but hardware procurement, maintenance, and model update costs need to be accepted.
For open-weight models, on-premises deployment is more feasible, but license terms, hardware requirements, and the process for security patches must also be evaluated.
Define Unified Evaluation Dimensions
When selecting a model, it is recommended to score candidates across the following seven dimensions, with weights assigned according to business priorities.
| Dimension | What to check | Common metrics |
|---|---|---|
| Task quality | Whether output is correct and complete | Test pass rate, human rating |
| Long context | Whether information in long inputs is accurately located | Needle-in-a-haystack accuracy |
| Multimodal | Whether image and document understanding is reliable | Structure reconstruction accuracy |
| Tool calling | Whether multi-step flows can be completed | End-to-end task success rate |
| Latency | Whether user wait time is acceptable | Time-to-first-token, p95 latency |
| Throughput and concurrency | Whether service remains stable at peak | Error rate under concurrency, queue time |
| Cost and compliance | Whether per-call cost and data boundaries meet requirements | Unit task cost, compliance review result |
Example of weight assignment: an internal code-assistance tool might weight task quality and long context most heavily, while a customer-facing conversational product should put latency and concurrency first.
Build a Small-Scale Benchmark Set
Hands-on testing provides more relevant signal than public leaderboards. The test set does not need to be large, but it should cover the real task distribution, including easy, medium, and hard levels.
Steps for building the test set:
- Sample 100–300 real cases from historical tickets, code repositories, or document collections.
- Write a reference answer or scoring rule for each case.
- Call all candidate models with identical prompts and parameters.
- Record outputs, duration, and cost, and keep the raw results for review.
Below is a generic evaluation script. The call_model function should be replaced with the team’s actual model interface.
import timeimport statisticsfrom dataclasses import dataclass@dataclassclass Case:prompt: strchecker: callable # accepts model output, returns True or Falsedef call_model(model_name: str, prompt: str) -> str:"""Wrap the actual model invocation logic. Teams implement this."""raise NotImplementedErrordef evaluate(model_name: str, cases: list[Case]) -> dict:latencies, passed = [], 0for case in cases:start = time.perf_counter()output = call_model(model_name, case.prompt)latencies.append(time.perf_counter() - start)if case.checker(output):passed += 1latencies.sort()return {"model": model_name,"pass_rate": passed / len(cases),"p50_latency_s": statistics.median(latencies),"p95_latency_s": latencies[int(len(latencies) * 0.95) - 1],}
The script only measures pass rate and latency. To evaluate cost, read the usage information from the model response and calculate the unit price per sample.
Selection Guidance for Typical Scenarios
Based on the dimensions above, the following directions can be considered for common scenarios. These are only examples; final decisions must rely on the team’s own test data.
- Code assistance and code review: prioritize pass rate on complex tasks and cross-file understanding, then latency and developer workflow impact.
- Long-document analysis and knowledge organization: prioritize accuracy in long-context localization. For very long inputs, use retrieval to narrow the scope before passing content to the model, reducing dependence on an oversized context window.
- Design-to-code conversion: prioritize multimodal reconstruction accuracy and verify that the generated code builds successfully.
- Customer-facing conversational products: prioritize time-to-first-token and peak-hour stability, and evaluate whether per-conversation cost is sustainable.
- Batch content generation and automation: prioritize cost per unit task and throughput, and set up quality sampling processes.
- Internal systems that handle confidential materials: decide the deployment boundary first, then compare capabilities within that boundary. Models that do not meet deployment requirements should be excluded.
Architecture Considerations in Production
Many teams eventually use more than one model, routing by task type to balance quality, speed, and cost. Below is a simple routing example.
ROUTES = {"code_review": {"model": "high_quality", "timeout_s": 60},"chat": {"model": "low_latency", "timeout_s": 10},"batch_tag": {"model": "low_cost", "timeout_s": 120},}def route(task_type: str) -> dict:# Fall back to the default route so missing config does not cause downtimereturn ROUTES.get(task_type, ROUTES["chat"])
The following mechanisms should also be considered in production:
- Fallback and retry: when the primary model times out or returns an error, switch to a backup model and log the fallback event.
- Caching: cache results for repeated requests, but set an expiration time and avoid caching responses that contain sensitive data.
- Observability: record task type, model version, latency, usage, and scoring results for every call, so quality regressions can be traced.
- Input validation: add length limits and format checks to user input to prevent oversized prompts from slowing down the service.
- Output validation: run static checks or tests on code output, parse structured output, and do not trust model-generated content without verification.
Risks and Caveats
Version drift. Models are updated frequently, and behavior under the same model name can change. Pin the model version and rerun the benchmark before upgrading.
Hallucination and factual errors. Models can generate plausible but incorrect content. Human review should remain in place for scenarios involving factual judgments, legal decisions, or financial conclusions.
Vendor dependency. If business logic becomes deeply coupled to a particular API’s behavior, migration costs increase. It is recommended to add an abstraction layer at the calling boundary and isolate vendor-specific differences in an adapter.
Data boundaries. Content sent to external services should go through a desensitization review. Teams should clarify which data can leave the network and which must stay internal.
Cost escalation. Agent-based and batch tasks can generate a large number of calls. Set a maximum step count per task, a daily budget limit, and alerts for abnormal usage.
When building these capabilities in a cloud environment, combine the evaluation of model services with general-purpose services such as object storage, logging, and monitoring, and follow the official documentation and contract terms from the provider.
Selection Checklist
Before making a final decision, confirm the following points:
- Business needs have been decomposed into concrete tasks, and success criteria have been defined.
- Tests have been run on at least 100 real samples, with raw outputs recorded.
- Time-to-first-token, p95 latency, and peak-hour error rates have been measured.
- Unit task cost has been estimated, with headroom for usage growth.
- Data egress rules have been confirmed and reviewed by security or compliance teams.
- A fallback plan has been designed, and the switchover process has been verified.
- Model versions have been pinned, and a regression testing process has been established before upgrades.
Once these checks are complete, the model selection is reproducible and can be reviewed after the fact.
