hezar.metrics.wer module¶
- class hezar.metrics.wer.WER(config: WERConfig, **kwargs)[source]¶
Bases:
MetricWER metric for evaluating Word Error Rate using jiwer.
- Parameters:
config (WERConfig) – Metric configuration object.
**kwargs – Extra configuration parameters passed as kwargs to update the config.
- compute(predictions: list[str], targets: list[str], concatenate_texts: bool | None = None, n_decimals: int | None = None, output_keys: tuple | None = None, **kwargs)[source]¶
Computes the WER for the given predictions against targets.
- Parameters:
predictions – Predicted texts.
targets – Ground truth texts.
concatenate_texts (bool) – Flag to indicate whether to concatenate texts before WER calculation.
n_decimals (int) – Number of decimals for the final score.
output_keys (tuple) – Filter the output keys.
- Returns:
A dictionary of the metric results, with keys specified by output_keys.
- Return type:
dict
- class hezar.metrics.wer.WERConfig(objective: str = 'minimize', output_keys: tuple = ('wer',), n_decimals: int = 4, concatenate_texts: bool = False)[source]¶
Bases:
MetricConfigConfiguration class for WER metric.
- Parameters:
name (MetricType) – The type of metric, WER in this case.
concatenate_texts (bool) – Flag to indicate whether to concatenate texts before WER calculation.
output_keys (tuple) – Keys to filter the metric results for output.
- concatenate_texts: bool = False¶
- name: str = 'wer'¶
- objective: str = 'minimize'¶
- output_keys: tuple = ('wer',)¶