How to Evaluate Large Language Models: Benchmarking Overall Capability, Code Generation, and API Cost
A practical guide for developers and engineering teams that explains how to evaluate large language models before putting them into production. It covers how composite intelligence indices are built and where they fall short, what anonymous blind head-to-head comparisons add, why code generation needs separate evaluation for frontend, backend, and algorithmic work, how to estimate API cost beyond headline per-token pricing, and how to turn one-off leaderboard impressions into a layered routing strategy backed by a repeatable evaluation and regression loop. Includes a cost estimation example, an evaluation checklist, and common selection pitfalls.
1. Why Evaluation Should Start With Your Scenario
Model capabilities are advancing fast. Every time a new model ships, developers and engineering teams ask the same two questions: how strong is it really, and is it worth wiring into production? A single metric — parameter count, context length, tokens per second — rarely answers either one. What actually shapes the experience is how a model performs on concrete tasks, and what it costs to complete them.
A sound evaluation process therefore has to answer three things:
- Where does the model sit in terms of general intelligence?
- Is it good enough in your specific scenarios — especially high-frequency or high-risk work such as code generation, question answering, writing, and data analysis?
- Under your budget, latency, compliance, and business constraints, is it the better option?
Around questions like how to benchmark LLMs, how to choose a code generation model, how to calculate API cost, and how to compare Chinese models with international ones, this article does not try to crown a single “strongest” model. Instead, it lays out an evaluation and selection method that is practical and reusable.
2. Measuring Overall Capability: Composite Indices First, Then Sub-Scores and Methodology
Composite “intelligence indices” are commonly used to gauge a model’s overall ability. Rather than depending on one test, they normalize and weight results across multiple dimensions — math reasoning, code, logical reasoning, instruction following, knowledge QA, multimodal understanding — into a single, horizontally comparable total score.
The strength of this approach is comparability: models from different vendors, with different architectures and parameter scales, can be observed against a broadly shared yardstick. It also has clear limitations.
First, an aggregate score can mask strengths and weaknesses. Two models with close totals may have very different profiles — one stronger on code and weaker on math, the other the reverse.
Second, benchmarks and real business traffic differ. Leaderboard items are curated and relatively balanced, while production requests are often heavily skewed — short question-answer pairs in a support scenario, long-context code comprehension in an engineering one.
Third, watch for overfitting to the test. If training data overlaps with the evaluation set, a high score does not necessarily indicate generalization. In that case, check whether the publisher provides data contamination detection, deduplication checks, or version update timestamps.
So when you rely on a composite index, don’t stop at one total. Look closely at:
- whether the dimension weights and normalization approach are transparent;
- whether sub-scores cover code, math, instruction following, multimodal understanding, and so on;
- whether sample size, test date, and model version are documented;
- whether there is data contamination detection or a dynamic evaluation mechanism;
- whether base models and aligned (post-trained) models are reported separately.
Verifiable examples include public knowledge, code, math, and conversational preference benchmarks, such as MMLU, C-Eval, GSM8K, HumanEval, MBPP, and public arena-style leaderboards. Note that the methodologies behind these benchmarks are not identical, so defer to the official documentation of each benchmark for exact conclusions. A composite intelligence index works well as the first screening gate to shortlist candidate models, but it should not be the final basis for a decision.
3. What Blind Head-to-Head Comparisons Add: Anonymity Reduces Brand Bias
The blind spots of composite indices can be partly covered by anonymous, double-blind head-to-head evaluation. The typical mechanism: given the same prompt, two unnamed models each generate a response, and real users or reviewers judge which output is better. Because reviewers don’t know where a response came from, bias driven by brand expectations is reduced.
Blind comparisons matter for two main reasons.
First, they use user preference as the judgment criterion. The standard isn’t necessarily a predefined gold answer but “which output is more useful for this task” — which is closer to real usage.
Second, anonymity reduces “fame bias.” When a reviewer knows which model is more famous, they may unconsciously favor it; once results are anonymized, attention shifts to the output itself.
But win rates have clear boundaries:
- A win rate is a relative metric, not an absolute quality score.
- The comparison baseline must be stated — for example, whether results were measured against the same reference model.
- The statistical method must be stated — pairwise win rate, Elo, Bradley-Terry conversion, and so on.
- Sample size, evaluation task set, evaluation date, and reviewer population must be documented.
- Without real data, avoid quoting specific percentages and stick to qualitative statements.
Blind test quality also needs control. Randomize the A/B position so reviewers don’t prefer left or right. When outputs differ substantially in length, stratify by length so a model doesn’t win simply by being longer. Run agreement checks across multiple reviewers and introduce an arbitration step when disagreement is large.
For code generation, blind tests can only tell you which output people prefer. They cannot replace objective acceptance: a piece of code may look polished yet fail to run, fail tests, or contain security vulnerabilities. Subjective blind testing and objective testing need to be used together.
4. Evaluating Code Generation: Design Frontend, Backend, and Algorithms Separately
Code generation is an important scenario for testing real model capability, but one leaderboard should never be the whole verdict. Different types of code tasks have different acceptance criteria.
Frontend code generation usually requires a model to hit several goals at once: correct logic, runnable output, reasonable visuals and interaction, clear structure, and good responsive behavior. It has to produce HTML, CSS, and JavaScript while also understanding page layout, component state, and interaction logic.
Backend code generation puts more weight on API correctness, database operations, concurrency handling, error handling, security, and maintainability. Algorithm code evaluation focuses on correctness, boundary conditions, time and space complexity, and whether tests pass within a reasonable time.
For this reason, code generation evaluation is best structured as “objective acceptance + subjective blind testing.”
Objective acceptance can include:
- unit test pass rate;
- static analysis results;
- whether the code compiles and runs;
- snapshot tests and rendered screenshot visual regression;
- accessibility and performance metrics;
- security scanning, such as common injection risks, leaked secrets, and missing authorization checks.
Subjective blind testing can generate results for the same requirement and have engineers or reviewers judge which output better matches expectations. For frontend pages, don’t read the code text alone — actually render it and inspect layout, styling, interaction, and compatibility. For backend code, don’t stop at a single passing sample; check error paths, boundary conditions, and security constraints.
If your core need is high-quality frontend pages, prioritize frontend code benchmarks first. If your core need is server-side development, add backend API, database, high-concurrency, and security scenarios. If you care about algorithm implementations, focus on test coverage and edge cases. The closer a scenario is to your business, the more useful the evaluation conclusion.
5. Calculating Model API Cost: Look Beyond Parameters and Unit Price
Capability is only half the answer when deciding whether a model can be used at scale. LLM cost is made up of several parts: input price per token, output price per token, inference overhead, cache hit rate, retry cost, multi-turn context cost, concurrent resource usage, and vendor discount policies.
Several intuitions need to be treated with care. Generally, a larger parameter count may come with higher capability and higher inference cost, but parameter scale does not map strictly onto either. Parameters only serve as a rough reference under the same generation, the same architecture, comparable sparse activation, and comparable quantization. In practice you’ll also see these cases:
- MoE models activate only part of their parameters, so actual compute doesn’t necessarily scale linearly with total parameters;
- a distilled small model may approach a large model on specific tasks at lower cost;
- quantization reduces memory footprint and inference cost;
- cache hits cut repeated compute and call cost;
- vendor pricing strategy directly affects API unit price.
A practical yardstick is cost-effectiveness: among candidates that meet your quality bar, prefer the ones with more controllable cost, more stable latency, and better operability.
Here is an illustrative cost comparison. Note that the unit prices below are for demonstrating the method only, not live quotes:
| Tier | Typical positioning | Example input/output price | Suitable scenarios |
|---|---|---|---|
| Flagship | Strong overall capability | USD 3.0 / 15.0 per million tokens | Complex reasoning, hard code |
| Balanced | Capability and cost in balance | USD 1.0 / 3.0 per million tokens | General chat, routine development |
| Lightweight | Cost first | USD 0.3 / 0.6 per million tokens | High concurrency, simple tasks |
Below is a sample cost estimation snippet that converts your own workload into a monthly figure:
def estimate_monthly_cost(input_tokens_per_req: int, # input tokens per requestoutput_tokens_per_req: int, # output tokens per requestrequests_per_month: int, # monthly request volumeprice_in_per_mtok: float, # input price (USD per million tokens)price_out_per_mtok: float, # output price (USD per million tokens)) -> float:"""Estimate the monthly cost (USD) of a model under a given workload."""in_cost = input_tokens_per_req * requests_per_month / 1_000_000 * price_in_per_mtokout_cost = output_tokens_per_req * requests_per_month / 1_000_000 * price_out_per_mtokreturn in_cost + out_cost# Assumptions: single-turn input/output, no caching or retries, multi-turn context not includedheavy = estimate_monthly_cost(2000, 800, 5_000_000, 3.0, 15.0)light = estimate_monthly_cost(2000, 800, 5_000_000, 0.3, 0.6)print(f"Flagship monthly cost: {heavy:.2f}, lightweight monthly cost: {light:.2f}")
Under these assumptions, the reference output is:
Flagship monthly cost: 90000.00, lightweight monthly cost: 5400.00
This example highlights a key issue: using a flagship model for a large volume of routine tasks often wastes resources, while forcing a lightweight model to handle complex reasoning may sacrifice quality. The point of cost estimation is not simply to find the lowest price, but to quantify the trade-off among model capability, task difficulty, call volume, latency requirements, and budget. If billing happens in another currency, convert further using your actual exchange rate and billing rules.
6. Layered Selection and Rollout: Turning Leaderboard Judgment Into a Repeatable Process
Overall, the safer strategy isn’t to pick one model, but to route by task tier.
- Use the flagship tier for complex tasks. For hard code, multi-step reasoning, key decisions, and complex data analysis, a model with stronger overall capability buys determinism with quality.
- Use lightweight or balanced tiers for routine tasks. Intent recognition, simple Q&A, formatted output, batch summarization, and label extraction are high-frequency, low-difficulty jobs that lower-cost models can handle while keeping total spend under control.
- Build an evaluation-and-regression loop. After each model upgrade, price change, or shift in business scenarios, re-run your internal evaluation set and let data drive the decision instead of relying on a one-off leaderboard impression.
To make this reusable, structure the loop as a checklist:
- Sampling sources: draw real samples from production logs, user feedback, ticketing systems, and engineering task repositories.
- Stratification: sample across scenarios, difficulty, language, code type, and business line so the set isn’t concentrated on a few high-frequency request types.
- Sample size guidance: at least 50 items per category for ordinary scenarios; 100 to 200 items for critical business scenarios; increase the sample size if models update frequently or business volume fluctuates.
- Scoring dimensions: run rate, unit test pass rate, standards compliance, visual fidelity, interaction quality, security, average latency, and unit cost.
- Dual-reviewer agreement: for important tasks, use a two-reviewer setup and compute an agreement ratio or agreement coefficient; send samples with large disagreement to arbitration.
- Regression thresholds: pass rates for critical tasks should not fall below baseline; if the average quality metric drops beyond a preset threshold, re-evaluate the model or the prompt.
- Launch gate: before a canary release, confirm the candidate model meets your internal evaluation criteria rather than relying on public leaderboard scores alone.
Production environments also need engineering capabilities to support this selection system:
- Observability: record call volume, latency, error rate, quality metrics, and cost per model, so you can spot models that are “cheap but unusable” or “expensive but ineffective” quickly.
- Cost governance: set call quotas and budget alerts per business line and per task type to keep flagship-model spend from getting out of control.
- Elasticity and stability: inference services should scale on demand, and model calls should have timeouts, retries, and fallback routing. When the flagship model is unavailable, traffic can fail over automatically to a balanced or lightweight tier.
On the engineering side, these capabilities can be assembled from generic components: object storage for log samples and evaluation artifacts, a message queue for running batch evaluations asynchronously, a container platform for hosting inference services, log services for tracing call chains, and monitoring with alerting to surface anomalies. These are generic engineering examples, not mandatory brand recommendations. If the content is used for commercial promotion, disclose any sponsorship or advertising relationship. Leaderboards and prices are also time-sensitive, so the final selection should rest on your own evaluation set and real business validation.
7. Common Pitfalls and a Selection Checklist: Avoid “Hot on the Leaderboard, Broken in Production”
Common pitfalls in LLM selection include:
- Looking only at the composite total and ignoring sub-scores;
- Looking only at parameter count and ignoring actual inference cost and task fit;
- Looking only at public leaderboards and ignoring your own business samples;
- Running one evaluation and never regressing across versions;
- Focusing on output quality without calculating call cost;
- Equating “generally strong” with “strong for my scenario”;
- Equating “cheap” with “suitable,” ignoring latency and quality floors.
A more practical selection checklist:
- Define the core scenario: general chat, code generation, knowledge QA, or multimodal understanding.
- Shortlist candidates: filter 3 to 5 candidates using composite indices, sub-scores, price ranges, and compliance.
- Inspect evaluation details: benchmark date, sample size, methodology, and possible contamination.
- Build an internal evaluation set: turn real business samples into a repeatable test set.
- Run objective acceptance: for code generation, run tests, render pages, and run security checks.
- Run subjective blind tests: anonymous review captures real preference, but control position and length bias.
- Estimate cost: budget by input and output tokens, monthly call volume, caching, and retry strategy.
- Route by tier: flagship for complex tasks, lightweight or balanced for routine ones.
- Roll out gradually: validate on a small traffic slice before expanding, and monitor quality and cost continuously.
8. Conclusion
Back to the original question: how do you decide whether a model is good and worth using? The answer isn’t a single score but a methodology. A composite intelligence index narrows the candidate pool, blind head-to-head comparisons bring you closer to real preference, scenario-based evaluation verifies vertical capabilities such as code generation, cost estimation clarifies the economics, and layered routing plus a regression loop moves the decision into production.
For developers and businesses, rather than chasing a single “strongest” model, build an evaluation and selection system that fits your own business, is measurable, and can keep evolving. Leaderboards will update, prices will change, and model versions will iterate — but real business samples, regression thresholds, and cost awareness are the most reliable assets in long-term selection.
