How to Evaluate LLM Capabilities: A Developer's Guide to Model Selection and Deployment

    This guide explains how to evaluate large language models with a structured, reproducible process instead of relying on anecdotal impressions. It covers core capability dimensions, how to build a test set that reflects real business workloads, how to calculate cost and latency accurately, and a weighted framework for choosing a model, with code examples for running evaluations and checking coding output.

    1. Why Evaluate LLMs Systematically

    In developer communities, discussions about whether a large model is “good” usually stay at the level of personal experience. One person finds the responses fast, and another finds it handy for writing code. These impressions have some value, but they are hard to use for team decisions, for three reasons.

    First, personal experience depends heavily on how a question is phrased and what kind of task is involved. The same model can perform very differently across scenarios.

    Second, public leaderboards do not use consistent methods. Test sets may overlap with training data, so the scores are not necessarily comparable.

    Third, the cost, speed, and parameter counts in marketing materials usually lack a common calculation basis.

    A more reliable approach is to break capability into several dimensions, measure each one with a test set that matches your own business data, and place cost and stability in the same evaluation table.

    2. Core Capability Dimensions

    2.1 Code Generation and Understanding

    Coding ability can be divided into five tasks: generation, completion, explanation, refactoring, and defect localization. Evaluation should check three things at once: functional correctness (whether the code passes unit tests), runnability (whether it passes syntax and static checks), and style consistency (whether it follows the team’s conventions). Reviewing generated code only by whether it “looks right” can miss boundary-condition errors.

    2.2 Mathematics and Complex Reasoning

    Reasoning tasks suit questions that can be checked automatically, such as numerical problems, logic puzzles, or multi-step derivations with standard answers. Checking should not stop at the final answer. It should also confirm that the intermediate steps are internally consistent. An answer that is correct but reached through a flawed derivation can still cause problems in a business setting.

    2.3 Translation and Cross-Lingual Understanding

    Translation evaluation should consider terminology accuracy, semantic completeness, and appropriate expression. For technical documentation, consistent translation of proprietary terms matters more than whether sentences read smoothly. You can prepare a glossary, calculate the term hit rate, and then manually sample sentence-level quality.

    2.4 Information Extraction and Knowledge Q&A

    This dimension measures whether a model can accurately extract information from a given source and clearly answer “cannot be determined” when the source is insufficient. The evaluation set should include a dedicated group of unanswerable questions to see whether the model invents content. This kind of hallucination carries high risk in business systems, so it should be measured separately.

    2.5 Long-Text Processing

    Long-context ability should not be judged only by the advertised maximum input length. Test the model’s recall of information located later in the text. Place key facts at different positions in the input, and plot how the recall success rate changes as the text gets longer.

    2.6 Instruction Following and Format Stability

    When downstream systems parse model output, format stability matters more than polished wording. Common metrics include the JSON validity rate, the completeness rate for required fields, and the rate of compliance with word-count limits. These metrics can be calculated automatically and suit regression testing.

    3. Building a Reproducible Evaluation Set

    Building an evaluation set follows a few basic principles.

    • Match the business distribution: Questions should come from real tickets, real codebases, or real documents, not from casually written examples.
    • Cover edge cases: Include empty inputs, very long inputs, ambiguous questions, and questions with traps.
    • Fix experimental conditions: Record the model version, decoding parameters (such as temperature), and the system prompt so that results can be reproduced.
    • Keep a hidden set: Set aside some questions that are never used for tuning and reserve them for final comparison.

    The following is a general evaluation framework. The model call function is wrapped by the user, so the code does not depend on any specific service interface.

    1. from dataclasses import dataclass
    2. from typing import Callable
    3. @dataclass
    4. class EvalCase:
    5. category: str
    6. prompt: str
    7. checker: Callable[[str], bool]
    8. def run_eval(model_call: Callable[[str], str],
    9. cases: list[EvalCase]) -> dict[str, float]:
    10. """Compute the pass rate for each category. The caller wraps model_call, which sends the request and returns the text."""
    11. results: dict[str, list[bool]] = {}
    12. for case in cases:
    13. output = model_call(case.prompt)
    14. results.setdefault(case.category, []).append(case.checker(output))
    15. return {cat: sum(v) / len(v) for cat, v in results.items()}

    For coding questions, the checker can first extract the code block from the model output and then run a syntax check:

    1. import ast
    2. import re
    3. def extract_code_block(text: str) -> str:
    4. match = re.search(r"```(?:python)?\n(.*?)```", text, re.S)
    5. return match.group(1) if match else text
    6. def is_valid_python(output: str) -> bool:
    7. try:
    8. ast.parse(extract_code_block(output))
    9. return True
    10. except SyntaxError:
    11. return False

    Correct syntax is only the minimum requirement. A more reliable approach is to write unit tests for each question, run the generated code in an isolated environment, and use the test pass rate as the metric.

    4. Calculating Cost and Efficiency

    4.1 Per-Request and Monthly Cost

    The cost of a single request is calculated as follows:

    Cost per request = input tokens × input price + output tokens × output price

    Monthly cost also requires multiplying by the average daily request volume and 30 days, and accounting for the retry rate and the billing rules for failed requests. Many teams estimate costs under ideal conditions only, and actual bills are often noticeably higher.

    4.2 Latency Metrics

    Record both time to first token (TTFT) and total completion time, and report them as p50 and p95 percentiles. Reporting only the average hides the experience of slow tail requests, and those tail requests often cause user complaints.

    4.3 Training Cost Definitions

    Published training cost figures vary widely and usually exclude early experiments, data construction, staffing, and hardware depreciation. These numbers can provide background context but should not be used as a basis for model selection. For users of a model, inference cost and their own call volume determine their spending.

    4.4 Architecture and Compute

    Sparse mixture-of-experts (MoE) architectures activate only some parameters for each token, which reduces the compute required per inference. This is an engineering trade-off. It introduces new problems such as routing, load balancing, and GPU memory usage. Whether it actually saves money depends on the throughput and unit price of the real deployment.

    5. Practical Use in Programming

    Common uses of LLMs in programming include generating code templates, suggesting refactorings, flagging potential defects, drafting test cases, and explaining error messages. These uses can improve efficiency, but their output must be verified.

    The recommended verification process is as follows:

    1. Run the generated code in an isolated environment.
    2. Execute unit tests and static checks.
    3. Run a security scan to check for leaked secrets, injection risks, and dependency vulnerabilities.
    4. Have a person review the business logic and boundary handling.

    A fast response does not mean a correct result. Code returned within seconds has close to zero value to a team if it fails tests. When evaluating coding ability, the main metrics should be pass rate and defect rate, not generation speed.

    6. A Framework for Model Selection

    The table below gives a reference weight distribution. Teams can adjust it to fit their own business.

    Dimension Suggested Weight Measurement Method Notes
    Code ability 25% Unit test pass rate Measure separately for each programming language used in the business
    Reasoning ability 15% Validation against standard answers Spot-check intermediate steps
    Information extraction and Q&A 20% Combined answerable and unanswerable question sets Focus on the hallucination rate
    Format stability 15% JSON validity rate and field completeness rate Affects the stability of downstream parsing
    Cost and latency 15% Cost per request and p95 latency Convert using actual call volume
    Data compliance 10% Deployment method and data retention terms Exclude the model directly if it fails compliance requirements

    When selecting a model, you can first screen candidates using the compliance criteria, then score the remaining candidates with weights. Scoring results should be checked against performance on the hidden test set to avoid overfitting to known questions.

    7. Operational Considerations

    • Data security: Sensitive code and customer data should be desensitized first. Then decide whether to use an internal deployment or a compliant external service.
    • Version drift: When the provider updates a model, rerun the evaluation set. Do not reuse conclusions from the old version.
    • Traceability: Outputs involving factual claims should include their sources so that people can verify them.
    • Human in the loop: Key decisions and code entering production must be reviewed by people.

    8. Summary

    Model selection should be based on reproducible test results. Comparing code, reasoning, information extraction, format stability, cost, latency, and compliance within one framework produces conclusions that hold up in real business use. The same framework also makes it easier to track models over time as they are updated.