How to Choose and Evaluate Open-Source LLMs: A Practical Methodology
This guide presents a reproducible methodology for selecting open-source large language models. It explains why leaderboard rankings alone are insufficient, how to break business needs into measurable capability dimensions, and how to evaluate quality, latency, and cost with a unified harness. It also covers test set construction, anti-contamination practices, inference performance testing, cost calculation, and gradual rollout with rollback.
1. Why “Ranked First on the Leaderboard” Is Not Enough
Open-source large language models iterate quickly, and new evaluation leaderboards appear constantly. A single score rarely reflects real business performance. The reasons are consistent: benchmark questions do not match your business distribution, results are highly sensitive to prompts, evaluation scripts and decoding parameters are not standardized, and data contamination is hard to rule out.
Engineering teams should treat model selection as a reproducible experiment, not a subjective judgment.
A practical principle: define the business task and acceptance criteria first, then shortlist candidate models, and finally run scores through a unified harness. Reversing this order almost always leads to rework.
2. Break Down the Task: Turn “Is the Model Good?” into Measurable Sub-Questions
Break business requirements into four capability dimensions:
- Instruction following and format constraints (stable JSON output, fixed fields, length limits)
- Knowledge and reasoning (multi-hop QA, math and logic, code understanding)
- Long-context handling (long-document summarization, cross-section retrieval, coreference resolution)
- Safety and compliance (refusal boundaries, sensitive content handling, traceable citations)
Each dimension needs its own acceptance threshold. For structured output, for example, you might require “field completeness ≥ 99%, JSON parse failure rate ≤ 0.5%”.
3. Metrics: Track Quality, Efficiency, and Cost Together
For quality, use accuracy, field completeness, hallucination rate (share of unsupported claims), and human preference win rate. For efficiency, track time to first token (TTFT), time per output token (TPOT), throughput (tokens/s), and stability under concurrency. For cost, do not look at unit price alone; calculate “cost per 1,000 successful requests”, including retries, extra-long contexts, and fallback on failures.
Illustrative load-test pseudocode:
# Skeleton of a unified evaluation harness (illustrative)cases = load_cases("biz_eval_v1.jsonl")for m in candidates:for c in cases:out = call_model(m, prompt=c.prompt, temperature=0.0, max_tokens=c.limit)record(m, c, out, ttft=out.ttft, tpot=out.tpot)report = aggregate(records) # Aggregate quality/latency/cost
The key point: temperature, maximum length, and retry strategy must be fixed, otherwise the data is not comparable.
4. Test Set Construction: Match the Real Distribution and Prevent Contamination
The test set should be a de-identified sample of real business logs, stratified by scenario (simple/medium/hard), with a portion of “hard online cases” kept as a regression set. To keep evaluation data out of training corpora, use private paraphrasing, parameterized templates, and random-seed generation of synonymous questions, and rotate versions regularly.
Also build a “minimal discriminative set”: 20–50 questions that clearly separate candidate models, used for fast daily regression to avoid the time cost of full runs every time.
5. Inference Performance and Deployment: Real Constraints on Throughput and GPU Memory
The same model performs very differently under different quantization precisions, batching strategies, and context lengths. Run stepped load tests on the target hardware: concurrency 1/4/8/16, input lengths 512/2K/8K, and observe throughput and latency inflection points. If deploying on a container platform, pair it with monitoring, alerting, and logging services to observe queueing latency and failure rate; model weights can be stored in object storage, and cold-start strategy should be validated in advance.
6. Cost Accounting and Gradual Rollout
Combine quality, latency, and cost into a weighted score; weights are confirmed by the business side and kept on record. Roll out gradually: small traffic validation → shadow traffic comparison → full rollout. During the gradual phase, focus on three metrics: parse failure rate, human spot-check win rate, and cost per successful request. If any metric goes out of bounds, roll back.
7. Common Pitfalls
- Looking only at the total score and not the variance: small-sample fluctuation can mislead decisions
- Ignoring the prompt and parsing layer: many “the model is bad” cases are actually missing templates and validation
- No regression set: comparability is lost after one iteration
- Treating demo results as production metrics: lacking concurrency and long-duration stability tests
8. Conclusion
The essence of model evaluation is building a reproducible experimental system: task decomposition, layered metrics, data anti-contamination, performance load testing, cost conversion, and gradual rollout with rollback. Baidu AI Cloud, with general capabilities such as model services, object storage, container platforms, and monitoring and alerting, can provide the infrastructure to build such an evaluation pipeline; the methodology itself is model-agnostic and can be reused over the long term.
