Dev Notes
Guides

Benchmark Your LLM: A Practical Engineering Guide

Build internal benchmarks around real use cases rather than leaderboard tasks, then run them continuously as your model changes.

Your production traffic is the benchmark that matters. MMLU, HumanEval, HellaSwag, and other leaderboard scores measure broad ability on carefully designed academic tasks. Your application needs a measure of performance on the specific requests users make, judged by the standards your team defines as correct.

An internal benchmark takes a few days to set up. Keeping it running is mainly an infrastructure task. This guide covers both parts.

Why Leaderboard Scores Do Not Transfer

Leaderboard tests help compare models during selection. A much higher MMLU score likely signals stronger general reasoning, which predicts quality for many tasks. That relationship weakens in specialized applications. A coding assistant ranked top-5 on HumanEval may still struggle with your code patterns, terminology, or required output format.

The underlying problem is that leaderboards measure peak ability, not the distribution seen in production. Their examples are curated and difficult. Real traffic is messier, with edge cases, unclear queries, and inputs right at the model's capability boundary. A model can ace a curated test yet fail on the ambiguous middle that makes up much of your traffic.

Build your internal benchmark from the distribution of real traffic. That makes its results predictive of actual performance.

Building Your Golden Dataset

Every internal benchmark starts with a golden dataset, a set of (input, expected output) pairs reviewed and labeled as correct. There are two ways to create one.

Forward sampling: Randomly select recent production inputs. Have a human review the current output for each, marking it correct or incorrect. Keep correct outputs as positive examples and sample incorrect ones as hard negatives. Begin with 200-500 examples, enough for a useful benchmark, then grow it over time.

Scenario design: Create representative inputs from scratch for the task types users encounter most often. This takes longer but lets you control the distribution. It also helps cover rare production edge cases that still matter.

Weight the dataset toward forward-sampled examples. They show the actual difficulty distribution. Constructed examples reflect the scenarios their author happens to imagine.

Choosing Your Scoring Criteria

Each dataset example needs a way to judge whether the output is correct. That is difficult for open-ended generation and is where many teams invest too little.

Three scoring methods, ordered roughly by investment:

Exact or structural match: For structured outputs such as JSON extraction, classification, or form filling, exact or schema matching is quick and dependable. Calculate precision and recall against ground-truth fields. It is the least expensive option when the task has a definite correct form.

Rubric scoring: For open-ended generation, define specific evaluation criteria. A support bot rubric might ask whether the answer was accurate (0/1), cited a real product feature (0/1), used the right tone (0/1), and stayed under 200 words (0/1). An LLM judge can apply the rubric at scale. This works across most text-generation tasks.

Embedding similarity: Calculate cosine similarity between the output and reference in embedding space. It captures meaning but misses factual precision. Use it as a supporting signal with rubric checking, never as the sole quality measure.

Running Your Benchmark Continuously

A benchmark run only before a model upgrade reveals little. Its value comes from running after every significant change, including model swaps, prompt edits, and retrieval configuration updates. It therefore must run quickly enough for CI.

A workable setup stores the golden dataset as a JSON file in the repository. A script accepts a model or prompt configuration, runs every example through the stack, scores the results, and writes JSON with pass rates for each rubric dimension. Put the script in CI and run it on pull requests touching inference code.

# benchmark.py (simplified)
import json
from futureagi import Client

fagi = Client(api_key=os.environ["FAGI_API_KEY"])

with open("benchmarks/golden_dataset.json") as f:
    dataset = json.load(f)

results = []
for example in dataset:
    response = run_pipeline(example["input"])
    score = fagi.evaluate(
        response=response,
        rubric=example["rubric"],
        reference=example["reference_output"]
    )
    results.append({
        "id": example["id"],
        "score": score.score,
        "passed": score.score >= 0.75,
        "flags": score.flags
    })

pass_rate = sum(1 for r in results if r["passed"]) / len(results)
print(f"Pass rate: {pass_rate:.1%}")

if pass_rate < 0.85:
    print("FAIL: Below threshold")
    exit(1)

Set a minimum pass rate and fail CI when the benchmark falls below it. That failure condition is what blocks regressions from shipping. Without it, the benchmark only reports problems.

Interpreting Changes Over Time

With continuous runs, system changes will produce score changes. These patterns usually point to different causes:

A sharp fall after a model update suggests a changed capability profile on your task distribution. Compare example-level results from the old and new runs to find the rubric dimensions that fell. This identifies the capability gap.

A steady decline over several weeks without an obvious model or prompt change often signals data drift. The golden dataset no longer matches current inputs. Add recent production examples to recalibrate it.

A decline limited to one rubric dimension usually points to the prompt. If tone appropriateness fails more often while factual accuracy remains steady, the model may be interpreting tone instructions differently.

What This Does Not Replace

CI benchmarking does not replace production monitoring. It measures performance on a fixed golden dataset, while production traffic changes in ways the dataset cannot predict. A CI pass rate of 95% can still coexist with production decline when users ask uncovered questions.

The layers are complementary. Benchmarking catches regressions from deliberate changes, such as model updates and prompt edits. Production evaluation catches unplanned degradation from distribution shifts, retrieval changes, and subtle model behavior changes. Using only one leaves half the detection system uncovered.

Evaluate your AI calls

Add Future AGI to your LLM client. Three lines of code starts evaluation on each call.