fastrag.benchmark.metrics.base#
The Metric contract, its input, and how scores aggregate.
Metrics consume the retrieval and query layers:
Retriever returns
Document — there is no ScoredDocument any more —
so a metric reads a document’s score/rank out of its metadata
dict (stamped by VectorStore.search) instead of off its .score/
.rank attributes.
Classes
|
A run's scores for one metric, never collapsed to a single mean. |
|
One measurement, computed per sample and aggregated over a run. |
|
What the pipeline produced for one sample — a metric's whole input. |
- class fastrag.benchmark.metrics.base.QueryOutcome(answer, sources, latency_ms, input_tokens=None, output_tokens=None)[source]#
Bases:
objectWhat the pipeline produced for one sample — a metric’s whole input.
answeris""andinput_tokens/output_tokensareNonewhenrun()targets a bareRetrieverrather than aQueryEngine.- Parameters:
- class fastrag.benchmark.metrics.base.Metric[source]#
Bases:
ABCOne measurement, computed per sample and aggregated over a run.
A metric carries its own dependencies as class attributes, so
Benchmarkcan refuse an unsatisfiable request at construction rather than silently returning a number that means nothing.- needs_answer: bool = False#
Truewhenscore()readsoutcome.answer— never satisfied by a bareRetriever.
- higher_is_better: bool = True#
Which direction improves.
Falseforlatency_ms,total_tokens, andcost_usd.
- abstractmethod async score(sample, outcome)[source]#
This sample’s score, or
Nonewhen it is not measurable.- Parameters:
sample (EvalSample)
outcome (QueryOutcome)
- Return type:
float | None
- class fastrag.benchmark.metrics.base.DistributionSummary(count, missing, mean, median, std, min, max, percentiles=<factory>)[source]#
Bases:
objectA run’s scores for one metric, never collapsed to a single mean.
missingcounts theNonescores, dropped beforemean/median/std/min/max/percentilesare computed over what is left. An empty or all-Noneinput yieldscount=0and zeros everywhere, never aZeroDivisionError.- Parameters:
- classmethod of(scores)[source]#
Build a
DistributionSummaryfrom raw per-sample scores.- Parameters:
- Return type: