How to Choose an LLM: A Practical Guide to Scenario-Based Technical Selection
There is no single "best" large language model. This guide explains how engineering teams can select the right LLM for their own workloads: five evaluation dimensions to define before comparing models, common selection mistakes to avoid, scenario-specific criteria for coding, writing, multimodal tasks, real-time search, and general chat, plus cost estimation formulas, a method for building your own evaluation set, and design practices for availability and compliance. Sample pseudocode is included to help you quantify cost, pass rate, and latency across candidate models.
1. Why “Which Model Is Best” Has No Standard Answer
LLM capability is multidimensional. A model that excels at code generation is not necessarily the leader in long-document understanding or image analysis. A top position on an overall leaderboard has limited value for a specific business. The question an engineering team actually needs to answer is: given our task types, budget, and compliance constraints, which option offers the best combination of quality, cost, and stability?
2. Five Dimensions to Define Before Selection
Task capability: code generation and fixing, text writing, logical reasoning, multimodal input, structured information extraction, and so on. Before comparing models, list the task types that appear most frequently in your business.
Context length: determines how much material a model can process in one request. A large context window does not guarantee good comprehension. Information in the middle of long inputs is easily missed, so test recall of key facts using your real documents.
Recency: a model’s training data has a cutoff date. If your business depends on up-to-date information, confirm whether the model supports web retrieval or can be connected to an internal knowledge base. When using retrieved results, also evaluate the reliability and timeliness of the sources.
Cost: most services bill input and output tokens separately, and output tokens are usually more expensive. At high call volumes, small per-token price differences are amplified significantly, so estimate cost based on your actual call pattern rather than the listed price alone.
Availability and compliance: service access stability, account and identity verification requirements, whether data may leave your jurisdiction, and whether industry regulations are met. This dimension is often overlooked, but it determines whether a solution can run reliably over the long term.
3. Common Selection Mistakes
First, relying only on public benchmark scores. The question distribution of benchmark tests differs considerably from real business workloads. A high score only reflects performance on that specific test set.
Second, looking only at unit price. A cheaper model with a low first-pass rate may require multiple retries or extensive manual correction, making total cost higher, not lower.
Third, treating personal experience as a conclusion. Individual experience has reference value, but the sample size is small and prompting styles vary, so it cannot be generalized directly to a whole team.
Fourth, ignoring dependency risk. Relying on a single provider or a single account can lead to service interruption due to rate limiting, account suspension, policy changes, or price adjustments. Design your system with a fallback plan from the start.
4. Selection Criteria by Scenario
4.1 Code Development
Key concerns: does the generated code pass unit tests, can the model understand an existing codebase, does it support cross-file changes, and can it integrate stably into editors or CI pipelines? Evaluate using real issue tickets from your team’s repositories rather than algorithm puzzles. Record first-pass rate and the number of revision rounds — these two metrics are much closer to real development efficiency.
4.2 Content Writing
Key concerns: tone control, structural clarity, and factual accuracy. Writing quality is hard to judge automatically, so use human blind evaluation with two metrics: the proportion of output that is “directly usable,” and the average amount of editing required. Hide model names during evaluation to avoid subjective bias.
4.3 Multimodal Processing
Key concerns: supported input types (image, audio, video), recognition accuracy for charts and screenshots, and the ability to reproduce small text and table cells. Include blurry, skewed, and low-resolution samples in your test set, as these cases best expose a model’s limits.
4.4 Real-Time Information Retrieval
Key concerns: timeliness of retrieved results, traceability of citations, and whether the model fabricates sources. In high-risk domains such as finance, healthcare, and law, require the model to output cited sources and have a human verify critical conclusions.
4.5 General Conversation and Mixed Tasks
Key concerns: instruction following, the ability to recover after errors, and reliability of tool calling. For teams just starting with LLMs, the stability of default behavior is often more valuable than the top score on any single task, because it lowers the barrier to use and reduces unexpected output.
5. Cost Estimation Method
Cost per call is calculated as:
Cost per call = (input tokens ÷ 1,000,000 × input price) + (output tokens ÷ 1,000,000 × output price)
After accounting for failed attempts and retries, the effective cost per task is:
Effective cost = cost per call ÷ first-pass rate
Sample code (pseudocode):
def call_cost(in_tokens, out_tokens, in_price, out_price):# Prices are per million tokensreturn in_tokens / 1e6 * in_price + out_tokens / 1e6 * out_pricedef effective_cost(cost_per_call, first_pass_rate):return cost_per_call / first_pass_rate
The following numbers are hypothetical and only demonstrate the calculation. Assume a task averages 3,000 input tokens and 1,000 output tokens. Model A has an input price of 2, an output price of 10, and a first-pass rate of 0.9. Model B has an input price of 1, an output price of 4, and a first-pass rate of 0.6.
Model A’s cost per call is 0.016, and its effective cost is about 0.0178. Model B’s cost per call is 0.007, and its effective cost is about 0.0117. Under these assumptions, the cheaper model with the lower pass rate actually has the lower total cost. In real selection work, replace these values with actual prices and test data.
6. Build Your Own Evaluation Set
An evaluation set is the most reliable basis for model selection. Build it as follows:
- Collect real samples. Extract 100 to 300 tasks from business logs or historical tickets, covering both common scenarios and edge cases.
- Define pass criteria. For tasks that can be judged automatically, use unit tests, field validation, or key-fact matching. For tasks that are hard to automate, use double-blind human review.
- Fix experimental conditions. Standardize prompt templates, sampling parameters, and input formats so results are reproducible.
- Record multiple metrics together. Track pass rate, response latency, and cost per task at the same time, instead of focusing on a single dimension.
Sample code (pseudocode):
results = {}for model in candidate_models:scores = []for case in test_cases:output = model.generate(case.prompt, temperature=0)scores.append(case.check(output)) # returns 1 on pass, 0 otherwiseresults[model.name] = {"pass_rate": sum(scores) / len(scores),"avg_latency_s": measure_latency(model, test_cases),"cost_per_task": estimate_cost(model, test_cases),}
7. Availability and Compliance Design
Service availability directly affects business continuity. Design for it in the following areas:
- Timeouts and retries: network fluctuations cause request timeouts and errors. Set timeout values in code and use a retry strategy with exponential backoff.
- Account management: multiple people sharing a personal account can easily trigger risk controls. Use organization-level accounts and assign permissions by role.
- Identity verification: some services require additional verification steps. Reserve a manual handling path in your workflow so automated tasks are not blocked for long periods.
- Data security: define clearly which data may be sent to external models. Content involving personal information or trade secrets should be desensitized first, or processed with a self-hosted deployment instead.
- Multi-model fallback: integrate multiple models behind a unified adapter layer, and switch automatically when the primary service is unavailable.
Sample code (pseudocode):
def ask_with_fallback(prompt, providers, timeout=30, retries=2):for provider in providers:for attempt in range(retries):try:return provider.generate(prompt, timeout=timeout)except (TimeoutError, RateLimitError):sleep(2 ** attempt)raise RuntimeError("All model providers are unavailable")
The core purpose of the adapter layer is to decouple business code from specific providers. When you switch models, you only need to change configuration, not business logic.
8. Conclusion
There is no universal answer to LLM selection, but there is an executable method. First, break down the task types in your business. Then, build an evaluation set from real samples. Finally, compare quality, cost, latency, and stability side by side in a single table. Keep the ability to switch providers to avoid single-point dependency. Model versions and prices change quickly, so re-run your evaluation set every quarter and validate your selection with the latest data.
