llm¶
Evaluation of LLM systems, built on compare_methods with an item-level
bootstrap on top; the LLM evaluation guide walks through
it. Needs the eval extra.
Types¶
The shapes compare_llms accepts for its systems, examples and metrics, and
llm_judge returns a Metric. The signatures below spell them as Any, so
any callable or mapping of the right shape passes.
System
module-attribute
¶
A system under evaluation: a callable (inputs, seed) -> outputs that maps
a batch of inputs and an integer seed to a batch of outputs in the same order.
Metric
module-attribute
¶
A metric: a torchmetrics.Metric, or a per-example scorer
(output, reference) -> float.
Example
module-attribute
¶
One evaluation example: a {"input": ..., "reference": ...} mapping, or a
bare input when the metric needs no reference. To attach a reference, use the
mapping form: a bare tuple is treated as the input itself, not as an
(input, reference) pair, so a tuple-valued prompt passes through intact.
compare_llms ¶
compare_llms(
systems,
data,
metric,
seeds=(0, 1, 2, 3, 4),
*,
test="welch",
alpha=0.05,
correction="holm",
cache=None,
item_bootstrap=10000,
clusters=None,
)
compare_scores ¶
compare_scores(
scores,
*,
metric_name="score",
clusters=None,
test="welch",
alpha=0.05,
correction="holm",
item_bootstrap=10000,
)
Compare systems from already-computed per-item scores.
Use this when another harness (inspect-ai, lm-eval-harness, your own runner)
already produced per-item results and you only want the analysis: you get the
same BenchmarkResult, corrections and item-level bootstrap as
compare_llms without handing mushin your execution loop.
scores maps a system name to either
- a 1-D sequence of per-item scores: a single run. There is no seed dimension, so the seed-based columns are masked (a single run says nothing about decoding noise) while the item-level columns are fully populated; or
- a 2-D
(n_seeds, n_items)array, repeated runs, giving both the seed-based test and the item-level bootstrap.
Every system must cover the same items in the same order: item i of
one system is paired with item i of another. Call once per metric.
clusters names each item's group; the item-level bootstrap then draws
whole groups, so items of one group are resampled together. Supply it when
items are grouped (several questions per passage), or the interval will be
too narrow.
llm_judge ¶
Return a pointwise metric (output, reference) -> float that asks judge
(a user-supplied, provider-agnostic judge(prompt, seed) -> reply) to score
each output against rubric, parsing the reply to a float.