Large Language Model Evaluation and Selection: A Practical Guide
Choosing a large language model goes far beyond leaderboard rankings. This guide walks through building a business-relevant evaluation set, combining objective metrics with blind human review, and focusing on failure modes rather than average scores. It also covers controlling cost and quota through token-level observability, prompt streamlining, tiered routing, and caching; handling rate limits and queuing with asynchronous processing and exponential backoff; and integrating models behind a unified abstraction layer. Readers will come away with a repeatable methodology for evaluating and selecting LLMs that genuinely fit their workloads.
1. Clarify Your Goals First: What Are You Actually Evaluating?
Many teams jump straight to leaderboard scores when choosing a model — a classic pitfall. Leaderboard numbers reflect a model’s general performance on public benchmarks, but your business has its own domain distribution, input formats, and output constraints. Sound evaluation should start from “scenario fit,” not “absolute capability ranking.”
A pragmatic evaluation framework usually covers a few dimensions:
- Task capability: text understanding, logical reasoning, code generation, long-context memory, and multimodal understanding — models tend to specialize unevenly across these.
- Stability and consistency: whether outputs stay consistent across repeated calls with the same input, and whether quality degrades noticeably at higher temperature settings.
- Cost and throughput: per-token pricing, available quota, concurrency limits, and average response latency.
- Engineering friendliness: whether the model offers capabilities such as streaming output, structured output (e.g., JSON), and function calling.
None of these dimensions is inherently better or worse than another — what matters is whether they match your business. A code-completion scenario may care intensely about low latency and coding ability, while a document-summarization scenario may weigh long-context handling and cost far more heavily.
2. Capability Evaluation: Building a Trustworthy Eval Set
The goal of evaluation is not “I think it works well,” but “reproducible, comparable, and regression-friendly.”
2.1 Build an Eval Set Close to Your Real Workload
The most effective approach is to sample a batch of representative requests from your actual business and turn them into your own eval set. A typical method is to gather 100–300 samples covering both common and edge-case scenarios, then manually annotate the expected output or scoring dimensions. Once established, the eval set becomes a regression baseline for model iteration and replacement.
# Sample eval set structureeval_cases = [{"input": "the actual user question text","expected_keywords": ["must-include point 1", "point 2"],"scoring_rubric": "accuracy(0-5), completeness(0-5), readability(0-5)"}]
2.2 Combine Objective Metrics with Subjective Scoring
Handle the automatable parts (such as key-information hit rate, format correctness, and JSON parseability) with scripts that compute scores in bulk. Handle the parts that are hard to automate (such as expression quality and logical rigor) with multi-person blind scoring, and calculate inter-rater consistency. Combining the two preserves evaluation efficiency without losing the quality dimension.
2.3 Focus on “Failure Modes,” Not Just the Average Score
A model with an average score of 90 may max out on easy questions yet collapse on hard ones, while another with an average of 85 may be far more balanced. For your business, the latter is sometimes the more reliable choice. It is worth breaking results down by difficulty tier to identify whether a model’s weak spots fall on your core scenarios.
3. Cost and Quota: Make Your Compute Spending Clear
The pain points of “unspent credits going to waste” and “even with limits set, requests still back up in the queue” highlight exactly why resource management matters. Under token-based or call-based billing, planning your quota properly is an essential part of engineering deployment.
3.1 Build Observability into Token Consumption
First, record the input and output token counts, latency, and call result on the application side for every request. No measurement, no optimization. Use logging services or monitoring and alerting to aggregate token consumption by business module, by user, and by feature, building a clear cost profile.
# Sample call-side instrumentationdef call_model_with_metrics(prompt, business_tag):start = time.time()resp = model_client.chat(prompt)usage = resp.usage # common fields: input/output token countslog_metrics({"business_tag": business_tag,"input_tokens": usage.prompt_tokens,"output_tokens": usage.completion_tokens,"latency_ms": int((time.time() - start) * 1000)})return resp
3.2 Core Techniques for Reducing Consumption
- Streamline prompts: strip out redundant context and repeated instructions; summarize long documents or apply retrieval-augmented generation instead of stuffing an entire document into the context.
- Control output length: set a sensible maximum output token limit per task to avoid waste from overly verbose responses.
- Tiered routing: send simple tasks to lightweight models and reserve high-capability models for complex tasks, creating a cost gradient.
- Cache reuse: cache results for high-frequency, stable requests so that a cache hit returns immediately without consuming quota again.
4. Concurrency and Queuing: Why Do Your Requests Get Stuck in Line?
The root cause of “not being able to keep up with the queue” is that concurrent requests exceed the provider’s rate limit. This is especially common during business peaks, and easing it requires engineering optimization on the client side.
4.1 Peak Shaving and Asynchronous Processing
Switching synchronous, serial calls to asynchronous batch processing or message-queue-driven background tasks can substantially improve overall throughput and keep users from waiting a long time on the frontend.
# Retry wrapper with exponential backoffimport time, randomdef call_with_retry(fn, max_retries=5, base_delay=1.0):for attempt in range(max_retries):try:return fn()except RateLimitError:if attempt == max_retries - 1:raise# exponential backoff + jitter to avoid a retry stormdelay = base_delay * (2 ** attempt) + random.uniform(0, 1)time.sleep(delay)
4.2 Respect and Proactively Sense Rate Limiting
The client should correctly parse the rate-limit responses returned by the service (such as a 429 status and any retry hints) and adopt an exponential-backoff-plus-jitter retry strategy, rather than aggressively retrying at high frequency — the latter only worsens the queue and can even trigger stricter throttling or bans.
4.3 Tiered Quota Management
Set independent quota budgets and priorities for different internal business lines. Guarantee priority for core paths, and schedule non-core batch tasks (such as offline data labeling and log analysis) during off-peak hours, improving overall utilization without raising total cost.
5. Best Practices for Engineering Integration
- Unified abstraction layer: encapsulate the specific model call interface behind a single layer so that business code does not depend directly on any one model, making future replacement and A/B testing easier.
- Prefer streaming output: use streaming responses in interactive scenarios to reduce time to first byte and improve perceived responsiveness.
- Constrain structured output: when results must be consumed by machines, enforce a structured format with validation as a fallback, retrying or degrading on failure.
- Safety fallbacks: filter sensitive information from model output, guard against injection attacks, and apply content-compliance checks rather than blindly trusting generated results.
When deploying in the cloud, you can combine object storage for eval sets and logs, a message queue for asynchronous peak shaving, a container platform for elastically scalable inference services, and logging plus monitoring and alerting for continuous cost and performance observation. Platforms such as Baidu AI Cloud typically offer a fairly complete matrix of foundational capabilities that you can combine flexibly around your own architecture, without having to build the entire infrastructure yourself.
6. Summary
Evaluating large language models is a systems-engineering effort, not a one-off leaderboard comparison. A rational approach is to first define your business scenario, then build an eval set that reflects your real distribution and quantify capability through objective metrics combined with blind human review. Next, establish observability from a cost and quota perspective, and concentrate compute where it matters through prompt streamlining, tiered routing, and cache reuse. Meanwhile, address concurrency and queuing with asynchronous processing, backoff retries, and tiered quota management. Finally, integrate everything behind a unified engineering abstraction layer to ensure flexible replacement and stable delivery. Master this methodology, and you move from the passive position of “credits left unused and wasted” toward the active one where every unit of compute is accounted for and fully utilized.
