Building a Base Model Evaluation Framework: From Benchmark Rankings to Model Selection

    This article explains how to build a reproducible evaluation framework for base large language models and use it for model selection. It covers why a top benchmark ranking does not guarantee the best business fit, a six-layer framework spanning data, access, protocol, scoring, statistics, and cost, executable assertions instead of text similarity, paired significance testing and multiple-comparison correction, data contamination checks, and cost and latency metrics such as effective cost per passing case. It also outlines a practical rollout workflow and common pitfalls to avoid.

    1. Why “Ranked First on the Leaderboard” Does Not Mean “Best for Your Business”

    At the base model stage, a model has only completed next-token prediction training and has not been aligned to human preferences. As a result, its behavior depends heavily on prompt format, decoding parameters, and evaluation script details.

    A common industry claim is that a new flagship model, together with several peer candidates, was placed into the same unified framework and led in 24 out of 30 benchmarks. Results like this are worth noting, but from an engineering perspective they are a signal rather than a conclusion. The real question is whether that framework matches your business distribution.

    The cost of a wrong selection is usually not “a few points of quality.” It is three types of hidden costs:

    • Metrics decoupled from the live user experience: offline scores improve while user complaints rise.
    • Prompts and post-processing logic tightly coupled to one model’s output habits, forcing a full rewrite during migration.
    • An out-of-control cost structure, where long context and chain-of-thought output multiply the cost per request several times over.

    The first principle of an evaluation system is therefore: define the decision first, then define the metrics.

    2. Six Layers of a Unified Evaluation Framework

    A reproducible framework can be split into six layers, decoupled from each other through explicit contracts.

    1. Data layer: corpus sources, versions, licenses, and splits; training contamination detection (n-gram overlap, near deduplication, time-based holdout splits).
    2. Access layer: a unified inference interface that hides differences between model services in authentication, streaming responses, and batch capabilities.
    3. Protocol layer: centralized management of prompt templates, few-shot organization, stop conditions, maximum generation length, and decoding parameters such as temperature and top-p.
    4. Scoring layer: rule matching, unit-test-style checks, and model-assisted scoring (inter-rater agreement must be reported when a model acts as judge).
    5. Statistics layer: confidence intervals, paired significance tests, and multiple-comparison correction.
    6. Cost layer: input and output token counts, latency distributions, and failure retry rates converted into comparable unit costs.

    A sketch of the access layer (pseudocode that expresses structure only and does not point to any specific product):

    1. # Unified adapter: every candidate model implements the same protocol
    2. class BaseAdapter:
    3. def complete(self, prompt: str, *, max_tokens: int,
    4. temperature: float, stop: list[str]) -> Completion:
    5. ...
    6. def run_matrix(adapters, cases, decode_cfg):
    7. records = []
    8. for case in cases:
    9. for name, adapter in adapters.items():
    10. # Same prompt, same decoding config, same random seed strategy
    11. out = adapter.complete(
    12. render_prompt(case, template_version="v3"),
    13. max_tokens=decode_cfg.max_tokens,
    14. temperature=decode_cfg.temperature,
    15. stop=decode_cfg.stop,
    16. )
    17. records.append(Record(case.id, name, out.text,
    18. usage=out.usage, latency=out.latency))
    19. return records

    The key constraint: prompt templates and decoding configurations must be versioned and written into the result records. Otherwise nobody will be able to reproduce the ranking three months later.

    3. Metric Design: Breaking “Capability” into Verifiable Assertions

    A single accuracy number hides failure modes. Each case should carry executable assertions instead of only comparing text similarity:

    1. # Case structure: input plus executable check
    2. {
    3. "id": "reasoning-014",
    4. "prompt_template": "v3",
    5. "assert": lambda t: extract_number(t) == 42,
    6. "tags": ["multi-step reasoning", "unit conversion"],
    7. "max_tokens": 512
    8. }

    Common assertion families include exact match and normalized match, parseability of structured output (all fields present, correct types, valid enum values), sandboxed unit tests for code cases, and citation verifiability for long-document retrieval cases. For generative tasks, a dual track of “judge model plus human spot checks” works well; report the agreement rate between judge and humans regularly. When the agreement rate falls below a threshold, judge scores must not be used as a decision input.

    4. Statistical Rigor: Is a 24/30 Lead Significant?

    Leading in 24 of 30 items looks overwhelming, but it needs two checks. The first is a paired test: compare the outputs of different models on the same case in a paired fashion, using a sign test or paired resampling to estimate the confidence interval of the difference. The second is multiple-comparison correction: the more items, the higher the chance of winning by luck, so a correction such as Holm’s is needed to control the family-wise error rate.

    1. import random
    2. def paired_bootstrap(a, b, n=10000, seed=0):
    3. rng = random.Random(seed)
    4. diffs = [x - y for x, y in zip(a, b)]
    5. means = []
    6. for _ in range(n):
    7. s = [diffs[rng.randrange(len(diffs))] for _ in diffs]
    8. means.append(sum(s) / len(s))
    9. means.sort()
    10. return means[int(0.025*n)], means[int(0.975*n)]

    If the confidence interval crosses zero, the result should be stated as “no stable difference was observed on this case set.” Also distinguish the number of wins from the size of the wins: a narrow lead on most items combined with a large deficit on a few critical ones can be a net negative for the business. A weighted total score is recommended, with weights derived from real traffic distribution.

    5. Contamination and Fairness: Prerequisites for a Trustworthy Ranking

    The biggest risk in base model evaluation is data leakage. Practical measures include: building a holdout set from a time window after the evaluation set was published; running near deduplication and longest common substring screening on prompts and corpora; and preparing “rewritten parallel forms” for memorization-style questions. If the two forms differ too much in score, the model relies more on memory than capability. For fairness, unify the maximum generation length and stop conditions so that no model “looks more comprehensive” simply because it outputs more, and report the proportion of untruncated samples alongside the results.

    6. Cost, Latency, and Engineering Constraints

    Beyond offline scores, the engineering side must evaluate: input and output token cost per request, percentiles of time to first token and overall latency, rate limiting and failure rates under concurrency, and the retry amplification factor after structured output failures. A practical metric is “effective cost = total spend / number of cases passing assertions,” which puts retries and failures into the same measure. If the business is latency sensitive, also evaluate small-parameter models with retrieval augmentation, or tiered routing (simple requests go to a lightweight model, complex requests escalate), and compare them against a single large model baseline.

    7. A Practical Workflow and Common Pitfalls

    Recommended workflow: clarify the decision and thresholds → freeze the evaluation set and template versions → run a small-sample smoke test to validate the pipeline → run the full set and retain raw outputs → aggregate statistics and cost → align with live metrics on a small traffic canary → lock in a regression dashboard that automatically reruns whenever the model or prompts change.

    There are five common pitfalls: reporting only the mean and not the percentiles; using similarity instead of executable assertions; hand-tuning prompts for one model before comparing across models; ignoring truncation and retries; and treating judge model scores as objective ground truth. All of them point to the same fix: treat evaluation as a versioned, auditable engineering asset rather than a one-off report.

    8. Conclusion

    Information like “a new flagship leads on most benchmarks under a unified framework” is valuable because it signals that the candidate set has changed and your own evaluation is worth rerunning. A robust decision comes from a case set aligned with the business distribution, executable assertions, paired significance testing with multiple-comparison correction, and putting cost and latency into the same measure. Once this system is in place, model iteration no longer means passive rework, but a reproducible, comparable, and rollback-safe routine regression. If the evaluation and inference pipelines run on Baidu AI Cloud’s container platform, object storage, and logging service, unified monitoring, alerting, and quota management can turn evaluation jobs into a continuously running pipeline.