liveBook · Manning

Benchmark

As explained in LLMs in Production

A benchmark dataset is a curated dataset used to evaluate and compare model performance on defined tasks.

Choosing between a smaller, cheaper model and a larger, stronger one requires more than intuition: compare both on the same tasks with a metric and dataset. A benchmark dataset is a curated set of tasks whose results can be compared against ground truth. section 4.2

Benchmarks make evaluation repeatable, but they are not automatically realistic. Many established benchmarks use multiple-choice questions because they are easy to collect and score, even though real users usually ask freeform questions. A benchmark can also become obsolete when models surpass it. section 4.2.4 section 12.2.4

Use benchmarks pragmatically:

  • Start with established benchmarks to compare general capability, then add prompts and expected responses for specialized edge cases such as sarcasm or chess. section 4.2 section 4.2.4
  • Evaluate more than task performance: segment prompts across groups and measure toxicity, polarity, hurtfulness, or other bias-related behavior. section 4.2.3
  • Treat dataset curation as an operational responsibility; private data may require a separate evaluation workflow, and underrepresented languages can expose coverage gaps. section 4.2.4 section 12.2.4
Listing 4.7 Using the Evaluate library to run SQuAD
import evaluate

squad_metric = evaluate.load("squad")      #1
predictions = [
    {"prediction_text": "Saint Bernadette", "id": "5733be284776f41900661182"},
    {"prediction_text": "Salma Hayek", "id": "56d4fa2e2ccc5a1400d833cd"},
    {"prediction_text": "1000 MB", "id": "57062c2552bb89140068992c"},
]                           #2
references = [
    {
        "answers": {
            "text": ["Saint Bernadette Soubirous"],
            "answer_start": [515],
        },
        "id": "5733be284776f41900661182",
    },
    {
        "answers": {
            "text": ["Salma Hayek and Frida Giannini"],
            "answer_start": [533],
        },
        "id": "56d4fa2e2ccc5a1400d833cd",
    },
    {
        "answers": {"text": ["1000 MB"], "answer_start": [437]},
        "id": "57062c2552bb89140068992c",
    },
]
results = squad_metric.compute(
    predictions=predictions, references=references
)
print(results)
# {'exact_match': 33.333333333333336, 'f1': 79.04761904761905}

Run the SQuAD metric with predictions and reference answers to see how a benchmark dataset feeds an evaluation method. section 4.2.4

How LLMs in Production covers it

How deep it goes
Defines benchmark datasets, discusses custom and responsible variants, but stops short of a complete curation procedure.
Examples
Uses SQuAD, custom edge-case prompts, WinoBias, CALM, WinoQueer, and multiple-choice evaluation datasets.
What it assumes
Assumes familiarity with models and tasks, while defining metrics, datasets, and ground truth from the evaluation context.
What you can do after
Evaluate models with the Evaluate library, compare task results, and identify capability, bias, and coverage gaps.
How it connects
Connects metrics, ground truth, model evaluation, bias evaluation, toxicity, and language representation.

Also explained in

Compare how 23 books explain benchmark →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of LLMs in Production. The section links point to the parts of the book it draws on.