Practical LLM Selection: From Evaluation Metrics to Deployment
This article provides a practical guide for selecting Large Language Models (LLMs), emphasizing the trade-offs under various constraints. It covers identifying business constraints, core evaluation dimensions such as parameter scale, context length, modalities, inference efficiency, and deployment compatibility, as well as understanding the limitations of public benchmarks and building a private evaluation pipeline.
I. Why There Is No Universally Optimal Model
The essence of model selection is making trade-offs under constraints. A model that excels in code completion scenarios may be limited by context length in long document summarization tasks. Similarly, a model with controllable costs in cloud services might fail to run on local devices due to insufficient VRAM. Therefore, before comparing models, it is crucial to clearly define business constraints and evaluate each candidate on unified dimensions.
II. Define Constraints Before Selection
At least the following five categories of constraints should be clarified:
- Task Type: Question answering, code generation, information extraction, multimodal understanding, or reasoning-intensive tasks. Different tasks prioritize different capabilities.
- Quality Lower Bound: The acceptable error rate, such as an information extraction accuracy rate that must meet a specific business threshold.
- Latency and Throughput: Time to first token, single generation duration, and peak concurrency.
- Cost: Per-call cost for usage-based billing, or depreciation and electricity costs for self-built hardware.
- Compliance and Data: Whether data can be transferred cross-border, whether calling external APIs is allowed, or whether private deployment is mandatory.
Clearer constraints lead to faster candidate filtering and reduce the risk of being misled by a single metric.
III. Core Evaluation Dimensions
3.1 Parameter Scale and Activation Method
The parameter scale determines the model’s capability ceiling and its resource consumption. For models using a Mixture of Experts (MoE) architecture, the total parameter count can be very large, but only a subset of experts is activated during each forward pass. During selection, two numbers must be distinguished:
- Total parameters determine the storage space and VRAM footprint for weights.
- Activated parameters determine the computation required per token, directly impacting generation speed and unit cost.
The formula for roughly estimating weight VRAM is:
Weight VRAM ≈ Parameters × Bytes per parameterFP16 / BF16: 2 bytesINT8: 1 byteINT4: ~0.5 bytes
Taking a 70B parameter model as an example, FP16 weights occupy about 140 GB, while INT4 quantization reduces this to about 35 GB. This is only the lower bound; you must also add the KV Cache, activations, and the inference framework’s own overhead. For MoE models, all expert weights must reside in VRAM, so the total parameter count remains the primary basis for VRAM planning.
3.2 Context Length: Nominal vs. Effective Values
The nominal context length is the maximum number of input tokens a model supports. The effective length is the range within which the model can still stably utilize information. There can be a significant gap between the two.
For long-context scenarios, it is recommended to conduct a “needle in a haystack” recall test: place key information at different positions within a long document and check whether the model can accurately answer related questions. Record the recall rate changes based on position and length. If a model only has a nominal value without recall testing, it should not be directly used in production for ultra-long documents.
The VRAM footprint of the KV Cache also grows linearly with sequence length. It can be estimated using the following approximate formula:
KV Cache VRAM ≈ 2 × Number of layers × Number of KV heads × Head dimension × Sequence length × Batch size × Bytes per element
When long contexts and high concurrency occur simultaneously, the KV Cache often becomes a bottleneck earlier than the weights.
3.3 Input Modalities
Common modality combinations include text-only, text plus images, and text plus images plus video. The more modalities, the longer the preprocessing pipeline, and the higher the requirements for data formats, image resolution, and video frame sampling strategies.
If your business only processes text, selecting a multimodal model will increase deployment complexity and costs without corresponding benefits. Conversely, if your business requires understanding screenshots, receipts, or product images, you should verify the model’s ability to recognize image details and text within tables during the selection phase, rather than just looking at general metrics.
3.4 Inference Efficiency
Common metrics for measuring inference efficiency include:
- Time to First Token (TTFT): The time from submitting a request to outputting the first token, directly affecting the user-perceived response speed.
- Output Throughput: The number of tokens generated per unit of time, determining the service’s capacity ceiling.
- Tail Latency: P95 and P99 response times under high concurrency, determining service stability.
Factors affecting efficiency include model architecture (e.g., sparse attention can reduce computation for long texts), quantization methods, batching strategies, and inference engines. The performance of the same model can vary significantly across different engines. Therefore, efficiency data must be tested on target hardware and should not directly adopt numbers reported by others.
3.5 Open Source Licensing and Compliance
“Open source” does not mean “unrestricted use.” Open-source model weights may adopt different licensing agreements, and clause differences typically manifest in the following areas:
- Whether weights can be freely downloaded and redistributed;
- Whether commercial use is permitted;
- Whether derivative models must adopt the same license;
- Whether there are restrictions on user scale, industry, or use cases.
Enterprise users should have legal or compliance personnel verify licensing clauses item by item and archive the conclusions. This step often dictates whether a model can enter a project earlier than technical evaluations do.
3.6 Deployment Compatibility
Deployment compatibility requires checking the following:
- Supported inference frameworks and versions;
- Supported quantization formats, such as GPTQ and AWQ;
- Hardware adaptation, including GPU models, VRAM capacity, and support for domestic accelerator cards;
- Whether the service interface format is compatible with existing calling code;
- Whether streaming output and tool calling are supported.
If your team has already established a mature inference service system, prioritizing models that can directly integrate into it can significantly reduce migration and operational costs.
IV. Using Evaluation Benchmarks Correctly
Public evaluation benchmarks typically cover general knowledge, mathematical reasoning, code repair, and multimodal understanding. They are suitable for horizontal reference but have three limitations:
- Data Contamination: Training data may overlap with evaluation questions, so high scores do not necessarily represent true capabilities.
- Distribution Bias: There are huge differences in language style, length, and difficulty between academic questions and business corpora. For example, standard exam questions and customer service tickets are hardly comparable.
- Inconsistent Settings: Prompt templates, sampling temperature, number of examples, and scoring rules all affect scores. Scores from different sources are often not directly comparable.
Therefore, public benchmarks are only suitable for initial screening. The final decision should rely on a private evaluation dataset.
V. Building a Private Evaluation Pipeline
The core of private evaluation is comparing the quality, latency, and cost of candidate models under fixed conditions using real business samples. It is recommended to follow these steps:
- Sampling: Extract 200 to 500 samples from real business logs, covering both high-frequency and long-tail scenarios.
- Define Scoring Criteria: Clarify the scoring method for each sample. This can be exact match, rule validation, manual scoring, or assisted scoring by a stronger model.
- Fix Inference Parameters: Unify temperature, maximum generation length, and system prompts, and record version numbers.
- Record Three Types of Metrics: Quality score, latency percentiles, and single-call cost.
- Weighted Scoring: Assign weights based on business priorities and output a comprehensive ranking of candidate models.
The example code is as follows, where the functions are illustrative pseudocode:
def evaluate(model, dataset, judge):results = []for sample in dataset:start = now()output = model.generate(prompt=sample["prompt"],temperature=0.0, # Fix sampling parameters to ensure reproducibilitymax_tokens=sample["max_tokens"],)latency = now() - startscore = judge(output, sample["reference"]) # Returns a quality score from 0 to 1results.append({"id": sample["id"],"score": score,"latency": latency,"tokens": count_tokens(output),})return aggregate(results) # Aggregate into mean, P95 latency, and unit costdef select_model(candidates, dataset, judge, weights):report = {}for name, model in candidates.items():m = evaluate(model, dataset, judge)# Before actual use, quality, latency, and cost must be normalized to the same dimension; otherwise, weighting is meaninglessreport[name] = (weights["quality"] * m["score_mean"]- weights["latency"] * m["latency_p95"]- weights["cost"] * m["cost_per_1k"])return max(report, key=report.get)
Evaluation results should be archived alongside model versions, inference parameters, and dataset versions for reproducibility and subsequent comparisons.
VI. Selection Strategies for Typical Scenarios
- Intelligent Customer Service and Knowledge Q&A: Further
