espnet3.contract.metrics.check_metric_inputs
Less than 1 minute
espnet3.contract.metrics.check_metric_inputs
espnet3.contract.metrics.check_metric_inputs(metric: Any, inputs: Any) → Mapping[str, str] | None
Validate metric input bindings without inspecting an inference model.
inputs maps each name declared by the metric to a source: either an inference artifact stem or dataset:<column>. Whether an inference artifact exists is checked when the source is resolved for a test set.
- Parameters:
- metric – A
BaseMetricinstance (or any object exposinginputs). - inputs – The config’s
inputsbinding: a mapping from declared name to source, or a list of names that are their own sources.
- metric – A
- Returns: The bindings as a
dictfrom declared name to source, orNonewhen the metric declares no inputs.
Examples
>>> from espnet3.systems.esp2_asr.metrics.wer import WER
>>> check_metric_inputs(WER(), {"ref": "dataset:text", "hyp": "text"})
{'ref': 'dataset:text', 'hyp': 'text'}
>>> check_metric_inputs(WER(), {"ref": "text"})
Traceback (most recent call last):
espnet3.contract.metrics.MetricContractError: WER inputs: missing ...