How to Evaluate LLM Reasoning and Choose the Right Model

    A practical guide to evaluating large language model capabilities across measurable dimensions, building a small but stable evaluation set, running reproducible tests with fixed decoding settings, and making weighted model selection decisions based on quality, cost, latency, and compliance. It also covers common pitfalls and how to build a continuous regression loop.

    1. The Problem: Why “Generation Rankings” Are Not Enough

    In real engineering selection, developers often notice something counterintuitive: a newer-generation foundation model is stronger on most tasks, yet on specific capability dimensions it lands between the previous generation’s higher-tier variant and the current generation’s standard variant. At the same time, flagship tiers from different vendors show overlapping capabilities.

    This observation is reasonable. A “generation” describes an overall leap in training data scale, post-training strategy, and inference budget, while performance on a concrete task is also shaped by prompt design, decoding parameters, context length, and tool-calling constraints.

    For this reason, choosing a model based on version numbers is unreliable. A more rigorous approach is to break model capability into measurable dimensions, run reproducible comparisons with a fixed evaluation set and fixed decoding configuration, and then make a weighted decision that also accounts for cost, latency, and compliance requirements.

    2. Breaking Down Capabilities: Turning “Feel” into Metrics

    Cover at least the following six dimensions, each with its own independent samples to avoid cross-contamination:

    • Instruction following and format constraints: whether the model reliably produces strict structures (such as JSON), plus field-missing rate and invalid-character rate.
    • Multi-step reasoning and constraint satisfaction: deriving a unique solution from a set of conditions, checking consistency of intermediate steps.
    • Long-context information retrieval: locating a specified fact in a long document while handling distracting passages.
    • Code understanding and modification: making the minimal change to fix a defect in existing code, rather than generating from scratch.
    • Tool calling and structured output: parameter extraction accuracy and number of failed retries.
    • Refusal and uncertainty expression: whether the model clearly states when information is insufficient instead of fabricating an answer.

    The key is “automatable judgment.” Subjective scoring is easily influenced by writing style, so design tasks that can be verified programmatically wherever possible.

    3. Building the Evaluation Set: Small and Stable Beats Large and Messy

    A practical evaluation set needs only 50–150 items per dimension. The focus is a stable distribution and version control. Samples should cover three categories: typical scenarios, boundary scenarios (very long inputs, empty values, conflicting conditions), and adversarial scenarios (containing misleading prompts). Keep all samples and expected results under version control, and treat any change to prompts or parameters as a new version so historical data stays comparable.

    4. A Reproducible Evaluation Script

    The example below shows how to run a batch with a unified configuration and perform hard validation, making it easy to compare different model services horizontally on the same machine:

    1. import json, re, time
    2. CONFIG = {"temperature": 0.0, "max_output_tokens": 1024, "timeout": 60}
    3. def strict_json(text: str):
    4. m = re.search(r"\{.*\}", text, re.S)
    5. if not m:
    6. return False, None
    7. try:
    8. return True, json.loads(m.group(0))
    9. except Exception:
    10. return False, None
    11. def run_case(call_model, case):
    12. prompt = case["prompt"] + "\nOutput JSON only, no explanation."
    13. t0 = time.time()
    14. raw = call_model(prompt, **CONFIG)
    15. latency = time.time() - t0
    16. ok, obj = strict_json(raw)
    17. passed = ok and obj == case["expect"]
    18. return {"id": case["id"], "passed": passed, "latency": latency,
    19. "raw_len": len(raw)}
    20. def evaluate(call_model, cases):
    21. results = [run_case(call_model, c) for c in cases]
    22. pass_rate = sum(r["passed"] for r in results) / len(results)
    23. p95 = sorted(r["latency"] for r in results)[int(len(results) * 0.95) - 1]
    24. return {"pass_rate": pass_rate, "latency_p95": p95, "details": results}

    Key points: temperature is set to 0 to reduce randomness; timeout and output limits are fixed; judgment uses dual validation of “valid structure + semantic equivalence”; latency percentiles are recorded as well, because average latency hides the long tail.

    5. Reading the Results: How to Interpret Overlapping Ranges

    When results show that a model is close to the previous generation’s higher-tier variant on reasoning and close to the current generation’s standard variant on code, do not simply conclude it is “stronger” or “weaker.” Look at task weights instead. If the business is mainly structured extraction, weight format compliance and long-context retrieval more heavily; if it is mainly code assistance, raise the weight of the code-modification pass rate. A weighted score is recommended:

    1. Score = 0.3 * instruction following + 0.25 * reasoning accuracy + 0.2 * code pass
    2. + 0.15 * long context + 0.1 * tool calling

    Weights must be confirmed and documented by the business side to avoid conclusion drift from after-the-fact adjustments.

    6. Cost and Engineering Constraints: Quality Is Not the Only Factor

    At least three types of cost should be evaluated in parallel for production: cost per call, tail latency, and the hidden overhead of failed retries. A unified gateway can handle routing and fallback: switch to a backup model when the primary model fails or exceeds a threshold, and cache and deduplicate results. For observability, connect logging services and monitoring alerts, and build dashboards for pass rate, latency percentiles, and error-code distribution. Batch jobs can use a message queue to smooth out peaks, static assets and evaluation data can be stored in object storage, and the compute side can run evaluation tasks on a container platform to keep the environment consistent.

    7. Common Pitfalls

    • Using only public leaderboards instead of your own evaluation: distributions differ greatly, so conclusions often fail to hold.
    • Comparing models without fixing the prompt: differences get drowned out by prompt noise.
    • Ignoring the output length limit: a truncated long answer gets misjudged as a capability gap.
    • Skipping regression: after a model service update, historical conclusions may no longer hold.

    8. Conclusion

    The core of model selection is not chasing generation labels, but building a closed loop of “dimension breakdown → fixed evaluation → weighted decision → continuous regression.” On Baidu AI Cloud, developers can combine general capabilities such as the container platform, object storage, logging services, and monitoring alerts to make the evaluation workflow engineered and reproducible, so that selection conclusions genuinely serve business metrics.