fastrag.benchmark.metrics.operational#
Operational metrics: cost of running the pipeline, not quality of its output.
TokenUsage and Cost return None for every sample against a bare
Retriever or a provider that reports no
usage — “not measurable for this sample”
(score()), not a zero, and
it is why a retrieval-only benchmark should not list them: every sample
would come back incomplete.
Classes
|
Dollar cost of one sample's generation call. |
|
Wall-clock time for one sample, in milliseconds. |
Input plus output tokens for one sample. |
- class fastrag.benchmark.metrics.operational.Latency[source]#
Bases:
MetricWall-clock time for one sample, in milliseconds.
Never
None:Benchmarktimes every sample itself, so this metric works against a bareRetrievertoo, with no chat model involved.- name = 'latency_ms'#
- higher_is_better: bool = False#
Which direction improves.
Falseforlatency_ms,total_tokens, andcost_usd.
- async score(sample, outcome)[source]#
Return the sample’s wall-clock latency in milliseconds.
- Parameters:
sample (EvalSample)
outcome (QueryOutcome)
- Return type:
float | None
- aggregate(scores)#
Aggregate this metric’s per-sample scores. Override to change how.
- Parameters:
- Return type:
- class fastrag.benchmark.metrics.operational.TokenUsage[source]#
Bases:
MetricInput plus output tokens for one sample.
Nonewhen either count is missing — a bareRetrievernever generates, andask()does not report usage (in the new query layerChatModel.invokereturns plain text, not aCompletioncarrying token counts).- name = 'total_tokens'#
- higher_is_better: bool = False#
Which direction improves.
Falseforlatency_ms,total_tokens, andcost_usd.
- async score(sample, outcome)[source]#
Total tokens, or
Nonewhen the provider reported no usage.- Parameters:
sample (EvalSample)
outcome (QueryOutcome)
- Return type:
float | None
- aggregate(scores)#
Aggregate this metric’s per-sample scores. Override to change how.
- Parameters:
- Return type:
- class fastrag.benchmark.metrics.operational.Cost(*, input_price, output_price)[source]#
Bases:
MetricDollar cost of one sample’s generation call.
- Parameters:
- name = 'cost_usd'#
- higher_is_better: bool = False#
Which direction improves.
Falseforlatency_ms,total_tokens, andcost_usd.
- async score(sample, outcome)[source]#
Dollar cost from token counts, or
Nonewhen usage is unreported.- Parameters:
sample (EvalSample)
outcome (QueryOutcome)
- Return type:
float | None
- aggregate(scores)#
Aggregate this metric’s per-sample scores. Override to change how.
- Parameters:
- Return type: