Shortcuts

Match Error Rate

Module Interface

class torchmetrics.MatchErrorRate(**kwargs)[source]

Match Error Rate (MER) is a common metric of the performance of an automatic speech recognition system.

This value indicates the percentage of words that were incorrectly predicted and inserted. The lower the value, the better the performance of the ASR system with a MatchErrorRate of 0 being a perfect score. Match error rate can then be computed as:

mer = \frac{S + D + I}{N + I} = \frac{S + D + I}{S + D + C + I}

where:
  • S is the number of substitutions,

  • D is the number of deletions,

  • I is the number of insertions,

  • C is the number of correct words,

  • N is the number of words in the reference (N=S+D+C).

As input to forward and update the metric accepts the following input:

  • preds (List): Transcription(s) to score as a string or list of strings

  • target (List): Reference(s) for each speech input as a string or list of strings

As output of forward and compute the metric returns the following output:

  • mer (Tensor): A tensor with the match error rate

Parameters

kwargs (Any) – Additional keyword arguments, see Advanced metric settings for more info.

Examples

>>> preds = ["this is the prediction", "there is an other sample"]
>>> target = ["this is the reference", "there is another one"]
>>> mer = MatchErrorRate()
>>> mer(preds, target)
tensor(0.4444)

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

Functional Interface

torchmetrics.functional.match_error_rate(preds, target)[source]

Match error rate is a metric of the performance of an automatic speech recognition system. This value indicates the percentage of words that were incorrectly predicted and inserted. The lower the value, the better the performance of the ASR system with a MatchErrorRate 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

Match error rate score

Examples

>>> preds = ["this is the prediction", "there is an other sample"]
>>> target = ["this is the reference", "there is another one"]
>>> match_error_rate(preds=preds, target=target)
tensor(0.4444)