Word Info. Lost¶
Module Interface¶
- class torchmetrics.text.WordInfoLost(**kwargs)[source]
Word Information Lost (WIL) is a metric of the performance of an automatic speech recognition system.
This value indicates the percentage of words that were incorrectly predicted between a set of ground-truth sentences and a set of hypothesis sentences. The lower the value, the better the performance of the ASR system with a WordInfoLost of 0 being a perfect score. Word Information Lost rate can then be computed as:
where:
is the number of correct words,
is the number of words in the reference
is the number of words in the prediction
As input to
forward
andupdate
the metric accepts the following input:preds
(List
): Transcription(s) to score as a string or list of stringstarget
(List
): Reference(s) for each speech input as a string or list of strings
As output of
forward
andcompute
the metric returns the following output:wil
(Tensor
): A tensor with the Word Information Lost score
- Parameters:
kwargs¶ (
Any
) – Additional keyword arguments, see Advanced metric settings for more info.
Examples
>>> from torchmetrics.text import WordInfoLost >>> preds = ["this is the prediction", "there is an other sample"] >>> target = ["this is the reference", "there is another one"] >>> wil = WordInfoLost() >>> wil(preds, target) tensor(0.6528)
- plot(val=None, ax=None)[source]
Plot a single or multiple values from the metric.
- Parameters:
val¶ (
Union
[Tensor
,Sequence
[Tensor
],None
]) – Either a single result from calling metric.forward or metric.compute or a list of these results. If no value is provided, will automatically call metric.compute and plot that result.ax¶ (
Optional
[Axes
]) – An matplotlib axis object. If provided will add plot to that axis
- Return type:
- Returns:
Figure and Axes object
- Raises:
ModuleNotFoundError – If matplotlib is not installed
>>> # Example plotting a single value >>> from torchmetrics.text import WordInfoLost >>> metric = WordInfoLost() >>> preds = ["this is the prediction", "there is an other sample"] >>> target = ["this is the reference", "there is another one"] >>> metric.update(preds, target) >>> fig_, ax_ = metric.plot()
>>> # Example plotting multiple values >>> from torchmetrics.text import WordInfoLost >>> metric = WordInfoLost() >>> preds = ["this is the prediction", "there is an other sample"] >>> target = ["this is the reference", "there is another one"] >>> values = [ ] >>> for _ in range(10): ... values.append(metric(preds, target)) >>> fig_, ax_ = metric.plot(values)
Functional Interface¶
- torchmetrics.functional.text.word_information_lost(preds, target)[source]
Word Information Lost rate is a metric of the performance of an automatic speech recognition system.
This value indicates the percentage of characters that were incorrectly predicted. The lower the value, the better the performance of the ASR system with a Word Information Lost rate of 0 being a perfect score.
- Parameters:
- Return type:
- Returns:
Word Information Lost rate
Examples
>>> from torchmetrics.functional.text import word_information_lost >>> preds = ["this is the prediction", "there is an other sample"] >>> target = ["this is the reference", "there is another one"] >>> word_information_lost(preds, target) tensor(0.6528)