Shortcuts

torcheval.metrics.functional.word_error_rate

torcheval.metrics.functional.word_error_rate(input: Union[str, List[str]], target: Union[str, List[str]]) Tensor[source]

Compute the word error rate of the predicted word sequence(s) with the reference word sequence(s). Its class version is torcheval.metrics.WordErrorRate.

Parameters:
  • input (str, List[str]) – Predicted word sequence(s) to score as a string or list of strings.
  • target (str, List[str]) – Reference word sequence(s) as a string or list of strings.

Examples

>>> import torch
>>> from torcheval.metrics.functional import word_error_rate
>>> input = ["hello world", "welcome to the facebook"]
>>> target = ["hello metaverse", "welcome to meta"]
>>> word_error_rate(input, target)
tensor(0.6)
>>> input = ["this is the prediction", "there is an other sample"]
>>> target = ["this is the reference", "there is another one"]
>>> word_error_rate(input, target)
tensor(0.5)

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources