Shortcuts

Word Info. Lost

Module Interface

class torchmetrics.WordInfoLost(compute_on_step=None, **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:

wil = 1 - \frac{C}{N} + \frac{C}{P}

where:

  • C is the number of correct words,

  • N is the number of words in the reference

  • P is the number of words in the prediction

Parameters
  • compute_on_step (Optional[bool]) –

    Forward only calls update() and returns None if this is set to False.

    Deprecated since version v0.8: Argument has no use anymore and will be removed v0.9.

  • kwargs (Dict[str, Any]) – Additional keyword arguments, see Advanced metric settings for more info.

Examples

>>> from torchmetrics import WordInfoLost
>>> preds = ["this is the prediction", "there is an other sample"]
>>> target = ["this is the reference", "there is another one"]
>>> metric = WordInfoLost()
>>> metric(preds, target)
tensor(0.6528)

Initializes internal Module state, shared by both nn.Module and ScriptModule.

compute()[source]

Calculate the Word Information Lost.

Return type

Tensor

Returns

Word Information Lost score

update(preds, target)[source]

Store predictions/references for computing Word Information Lost scores.

Parameters
  • preds (Union[str, List[str]]) – Transcription(s) to score as a string or list of strings

  • target (Union[str, List[str]]) – Reference(s) for each speech input as a string or list of strings

Return type

None

Functional Interface

torchmetrics.functional.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
  • preds (Union[str, List[str]]) – Transcription(s) to score as a string or list of strings

  • target (Union[str, List[str]]) – Reference(s) for each speech input as a string or list of strings

Return type

Tensor

Returns

Word Information Lost rate

Examples

>>> from torchmetrics.functional 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)